🐷

ElasticSearchのアクセス元変更トラブル対応

2022/05/16に公開

Ubuntu20.04にElasticSearchをインストールしてhttp://localhost:5601 以外からのアクセス許可設定したい際にトラブったので備忘録として。

elasticsearch.ymlの設定変更

デフォルトのままだとIPアドレス指定でアクセスが出来ないのでelasticsearch.ymlを編集しました。
編集内容は下記のとおりです。network.host: 0.0.0.0を追記しただけです。
これはよくある手法と思います。

/etc/elasticsearch/elasticsearch.yml
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1 ★コメントアウト
network.host: 0.0.0.0      ★追記
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200

再起動できなくなる。。。

ubuntu@elasticsearch-kibana-210384:~$ sudo -i service elasticsearch restart
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.

error内容

/var/log/elasticsearch/elasticsearch.log
node validation exception[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.

解決方法

elasticsearch.ymlを下記のとおり編集すれば無事起動しました。

# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.host: 0.0.0.0

#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200           ★コメントアウト
http.port: 9200            ★追記

transport.host: localhost  ★追記
transport.tcp.port: 9300   ★追記

Discussion