简体   繁体   中英

Can't start ElasticSearch on Mac

I installed elasticsearch by brew install elasticsearch and started it with brew services start elasticsearch , however, curl http://127.0.0.1:9200 shows connection refused . I checked the port: netstat -a -n | grep tcp | grep 9200 netstat -a -n | grep tcp | grep 9200 netstat -a -n | grep tcp | grep 9200 and some ipv4 is running there. Ok, so I opened /usr/local/etc/elasticsearch/elasticsearch.yml and changed the port to 9300 and also uncommented and changed: network.host: 127.0.0.1 . Still shows connection refused when I do curl http://127.0.0.1:9300 . The OS is MacOS High Sierra 10.13.4 . If we open /usr/local/var/log/elasticsearch/elasticsearch_nikitavlasenko.log the error seems to be:

Cluster name [elasticsearch_nikitavlasenko] subdirectory exists in data paths [/usr/local/var/lib/elasticsearch/elasticsearch_nikitavlasenko]. All data under these paths must be moved up one directory to paths [/usr/local/var/lib/elasticsearch]

Did you have an older version (2.x or before) installed before? It sounds a lot like this PR to check that you're not using the old behavior when there was the node name in the path .

What I would do:

  • If you don't need the data any more, just remove /usr/local/var/lib/elasticsearch/elasticsearch_nikitavlasenko and start fresh.
  • If you need the data, you could either change path.data in your config or move the folder one level up (just like the log message says).

PS: I wouldn't use port 9300 for HTTP, because that's generally the port used for communication of the nodes in a cluster itself.

This was the result of a bug in the Homebrew formula for Elasticsearch. It was creating a directory with the node name which is no longer allowed for Elasticsearch.

The formula has been updated to remove node name from path.data and no longer create the invalid directory which should resolve this problem.

Ran into this issue some time back, Please add a minimal Elastic config file. for me it looks like below

http.port: 9200
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

path.data: /usr/local/var/elasticsearch/
path.logs: /usr/local/var/log/elasticsearch/
# Set both 'bind_host' and 'publish_host':
network.host: 127.0.0.1

# 1. Disable multicast discovery (enabled by default):
discovery.zen.ping.multicast.enabled: false
script.engine.groovy.inline.aggs: on

I think I wasn't having below config which caused the issue:

network.host: 127.0.0.1

Please check if its there in your config? Also properly set your data and logs folder path.

Let me know if you face any issue and have questions on these configs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM