gpt4 book ai didi

curl - Elasticsearch 错误 curl : (7) Failed to connect to localhost port 9200: Connection refused but localhost:9200 works on browser

转载 作者:行者123 更新时间:2023-12-02 22:15:30 30 4
gpt4 key购买 nike

我正在尝试将 Elasticsearch 5.5.2 连接到这个 tutorial 之后的 Django 2 项目:

运行时:curl -X GET 'http://localhost:9200'在终端上,我收到此错误:curl: (7) Failed to connect to localhost port 9200: Connection refusedlocalhost: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/是空的。

请问 curl 有什么问题?

最佳答案

好的, Eureka !,您有一个 Java 堆空间错误。看看那个错误:

# There is insufficient memory for the Java Runtime Environment to continue

您可以增加/减少-我不知道问题是否出现是因为您的机器内存太少而es无法启动,或者您为es分配的内存太少-Java虚拟机中专用于elastic的空间编辑此文件 /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 再试一次

关于curl - Elasticsearch 错误 curl : (7) Failed to connect to localhost port 9200: Connection refused but localhost:9200 works on browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48903999/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com