手元の環境でdocker使って試してみた
CentOS7.2にdockerを立ててその中にelasticsearchを立ち上げた感じです
単純にDockerfileのバージョン指定を5に上げただけでは動きませんでした。
そもそもkopfとかHQとか入れていたのですが、そういうプラグインは別のアプリケーションとして動かすようになったようで、Dockerfileからはずしました。
あと、bin/pluginもファイル名が変わったようで「/usr/share/elasticsearch/bin/elasticsearch-plugin」になっていました
それぞれ直して起動すると
elasticsearch | # elasticsearch | # There is insufficient memory for the Java Runtime Environment to continue. elasticsearch | # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory. elasticsearch | # An error report file with more information is saved as: elasticsearch | # /tmp/hs_err_pid1.log elasticsearch | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12) elasticsearch exited with code 1
メモリ足りん。。。ホストのメモリがそもそも1Gしかなかったのでとりあえず4Gに上げて環境変数ES_HEAP_SIZEを512にして再度起動
elasticsearch | Error: encountered environment variables that are no longer supported elasticsearch | Use jvm.options or ES_JAVA_OPTS to configure the JVM elasticsearch | ES_HEAP_SIZE=512: set -Xms512 and -Xmx512 in jvm.options or add "-Xms512 -Xmx512" to ES_JAVA_OPTS elasticsearch exited with code 1
おや、JAVA_OPSに書けとのことなので環境変数をセットします
ES_JAVA_OPTS: '-Xms2048m -Xmx2048m'
search | [2017-02-09T12:12:56,159][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead elasticsearch | [2017-02-09T12:13:06,451][INFO ][o.e.n.Node ] initialized elasticsearch | [2017-02-09T12:13:06,451][INFO ][o.e.n.Node ] [VRXn0VR] starting ... elasticsearch | [2017-02-09T12:13:06,899][WARN ][i.n.u.i.MacAddressUtil ] Failed to find a usable hardware address from the network interfaces; using random bytes: d7:dd:91:a9:b6:1e:9d:3e elasticsearch | [2017-02-09T12:13:07,195][INFO ][o.e.t.TransportService ] [VRXn0VR] publish_address {172.18.0.4:9300}, bound_addresses {[::]:9300} elasticsearch | [2017-02-09T12:13:07,208][INFO ][o.e.b.BootstrapChecks ] [VRXn0VR] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks elasticsearch | ERROR: bootstrap checks failed elasticsearch | max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] elasticsearch | [2017-02-09T12:13:07,241][INFO ][o.e.n.Node ] [VRXn0VR] stopping ... elasticsearch | [2017-02-09T12:13:07,335][INFO ][o.e.n.Node ] [VRXn0VR] stopped elasticsearch | [2017-02-09T12:13:07,338][INFO ][o.e.n.Node ] [VRXn0VR] closing ... elasticsearch | [2017-02-09T12:13:07,387][INFO ][o.e.n.Node ] [VRXn0VR] closed
oh…
dockerを動かしているホスト機で下記を実行して解決
sudo sysctl -w vm.max_map_count=262144
最終的に下記で起動できるところまで持ってけました
- elasticsearch/Dockerfile
FROM elasticsearch:5 RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji COPY config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml EXPOSE 9200 9300
- elasticsearch/config/elasticsearch.yml
CORS系の設定を追加(自分の環境で使うため)
network.host: 0.0.0.0 http.cors.enabled: true http.cors.allow-origin: '*' http.cors.max-age: 0 http.cors.allow-credentials: true
- docker-compose.yml
elasticsearch: container_name: elasticsearch build: context: ./elasticsearch ports: - "9200:9200" - "9300:9300" environment: ES_JAVA_OPTS: '-Xms2048m -Xmx2048m' kibana: container_name: kibana image: kibana links: - elasticsearch ports: - "5601:5601"
RESTAPI経由のindex mappingやドキュメント追加などの操作は以前と同じ感じで問題なく使えたので良かったです