ElasticSearch – How to Configure ElasticSearch on a Remote Host

configurationelasticsearchmagento2.4

I'm new to ES and just want to set up Magento 2.4 and ES in its simpelst way, just to get a impression.

Magento is on host A, ES on host B. Both on RHEL systems in the same network. I've installed ES and did not configure it, so it runs with its default configuration (which is a 'single node' instance?). On host B I can execute curl -XGET 'localhost:9200/_cat/health?v&pretty' successfully. But if I try that on Host A with curl -XGET 'host_B:9200/_cat/health?v&pretty' I get:

curl: (7) Failed to connect to colop_dev port 9200: Connection refused

And I guess that has something to do with the ES option network.host in /etc/elasticsearch/elasticsearch.yml, which is set to default value _local_, afaik. This does not allow connections from other machines. Is that correct? I tried the value 0.0.0.0, but when I restart ES I get the error

Aug 11 09:19:51 itsrv2493.esrv.local systemd-entrypoint[21543]: ERROR: [1] bootstrap checks failed
Aug 11 09:19:51 itsrv2493.esrv.local systemd-entrypoint[21543]: [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
Aug 11 09:19:51 itsrv2493.esrv.local systemd-entrypoint[21543]: ERROR: Elasticsearch did not exit normally - check the logs at /var/log/elasticsearch/elasticsearch.log
Aug 11 09:19:51 itsrv2493.esrv.local systemd[1]: elasticsearch.service: Main process exited, code=exited, status=78/CONFIG
Aug 11 09:19:51 itsrv2493.esrv.local systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Aug 11 09:19:51 itsrv2493.esrv.local systemd[1]: Failed to start Elasticsearch.

I think it has something to do with this. I have disabled SELinux and the firewall. I've tried telnet. Without success, though other ports on host B can be accessed normally from host A (e.g. web server).

According to the Recommended configuration in the Installation Guide, I should set up a web server on host B as well. But is it really necessary if port 9200 is not public? If not, how should I configure ES on host B? I'm also wondering about the suggested verification of the ES installation with curl -XGET '<host>:9200/_cat/health?v&pretty': it does not use the port 8080 that is suggested for Apache and nginx. Why?

Update: According to simonthesorcerer's answer, it is possible to have ES on a different machine, without the need of another web server in order to use ES.

Best Answer

First:

  • curl -XGET 'host_A:9200/_cat/health?v&pretty' should be curl -XGET 'host_B:9200/_cat/health?v&pretty'. You may want to try with local/public IP of that server, to exclude the possible problem that the host name isn't working correctly
  • network.host: 0.0.0.0 should actually work, according to this answer: https://stackoverflow.com/questions/33696944/how-do-i-enable-remote-access-request-in-elasticsearch-2-0 You may want to look through the answers, as sometimes, [0.0.0.0] seems to work, and sometimes, additional configuration seems to be necessary:
node.name: elasticsearch-node-1

cluster.initial_master_nodes: ["elasticsearch-node-1"]

Also, I'd recommend looking through the other variables that occur in the error message and read the docs.

You might find more help in the official ES forums though, as this question doesn't seem to be Magento-specific.

Related Topic