我正试图在此tutorial之后将Elasticsearch 5.5.2连接到Django 2项目:
在终端上运行:curl -X GET 'http://localhost:9200'
时,我收到此错误:curl: (7) Failed to connect to localhost port 9200: Connection refused
而localhost:9200
在我的浏览器上运行良好。
以下是我的elasticsearch.yml文件的概述:
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
# Elasticsearch performs poorly when the system is swapping the memory.
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
/var/log/elasticsearch/
为空。
请问卷曲有什么问题?
答案 0 :(得分:4)
ok eureka!,你有一个java堆空间错误。看看那个错误:
# There is insufficient memory for the Java Runtime Environment to continue
你可以增加/减少 - 我不知道问题是否出现是因为你的机器内存太少而无法启动,或者你已经分配了太少的内存 - 在java虚拟机中专用于弹性的空间编辑此文件/etc/elasticsearch/jvm.options
要分配2 GB的RAM,您应该更改:
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms2g
-Xmx2g
然后你必须重启服务
sudo service elasticsearch restart
再次使用curl
答案 1 :(得分:0)
我有同样的问题,但原因与卢帕诺德回答的原因不同。为其他人添加我的发现。
我也在ip:9200上拒绝连接,但是localhost:9200正常工作。当我尝试“ network.host:0.0.0.0”时,该服务无法启动。如下所示,我将值更改为“ http.host”,这允许该服务启动并通过ip调用。
/etc/elasticsearch/elasticsearch.yml
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
http.host: 192.168.1.199
#
# Set a custom port for HTTP:
#
http.port: 9200
#
之前:
[root@Loki-03 ~]# curl localhost:9200
"name" : "Loki-03"
[root@Loki-03 ~]# curl 192.168.1.199:9200
curl: (7) Failed to connect to 192.168.1.199 port 9200: Connection refused
之后:
[root@Loki-03 ~]# systemctl restart elasticsearch.service
[root@Loki-03 ~]# curl 192.168.1.199:9200
{
"name" : "Loki-03",
希望这会有所帮助。 另外,我正在跑步:
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
答案 2 :(得分:0)
就我而言,问题出在Java版本上,我之前安装过open-jdk 11。这就是在启动服务时造成的问题。我将其更改为open-jdk 8,并开始工作
curl localhost:9200
{
"name" : "My First Node",
"cluster_name" : "mycluster1",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "2016-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}