特定 version の Elasticsearch 構築手順 [Docker 編]

Tadashi Shigeoka ·  Tue, February 12, 2019

特定 version の Elasticsearch を Docker で構築する手順をご紹介します。

前提条件

  • Elasticsearch: version 2.3.1 を利用したい
  • OS: macOS Mojave

特定 version の Elasticsearch を docker で起動する

docker image 取得 & 初回起動

docker run -d \\       
--name elasticsearch2.3.1 \\
-p 9200:9200 \\
-p 9300:9300 \\
-e "discovery.type=single-node" \\
elasticsearch:2.3.1

docker logs で Elasticsearch 起動確認

$ docker logs elasticsearch2.3.1 -f
[2019-02-13 06:44:50,342][WARN ][bootstrap                ] unable to install syscall filter: seccomp unavailable: your kernel is buggy and you should upgrade
[2019-02-13 06:44:50,530][INFO ][node                     ] [Gertrude Yorkes] version[2.3.1], pid[1], build[bd98092/2016-04-04T12:25:05Z]
[2019-02-13 06:44:50,530][INFO ][node                     ] [Gertrude Yorkes] initializing ...
[2019-02-13 06:44:51,209][INFO ][plugins                  ] [Gertrude Yorkes] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2019-02-13 06:44:51,250][INFO ][env                      ] [Gertrude Yorkes] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda1)]], net usable_space [52.3gb], net total_space [58.4gb], spins? [possibly], types [ext4]
[2019-02-13 06:44:51,251][INFO ][env                      ] [Gertrude Yorkes] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-02-13 06:44:53,848][INFO ][node                     ] [Gertrude Yorkes] initialized
[2019-02-13 06:44:53,848][INFO ][node                     ] [Gertrude Yorkes] starting ...
[2019-02-13 06:44:53,955][INFO ][transport                ] [Gertrude Yorkes] publish_address {172.17.0.3:9300}, bound_addresses {0.0.0.0:9300}
[2019-02-13 06:44:53,963][INFO ][discovery                ] [Gertrude Yorkes] elasticsearch/YB8vdaQeTCOkuXtPp33vUg
[2019-02-13 06:44:57,035][INFO ][cluster.service          ] [Gertrude Yorkes] new_master {Gertrude Yorkes}{YB8vdaQeTCOkuXtPp33vUg}{172.17.0.3}{172.17.0.3:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2019-02-13 06:44:57,063][INFO ][http                     ] [Gertrude Yorkes] publish_address {172.17.0.3:9200}, bound_addresses {0.0.0.0:9200}
[2019-02-13 06:44:57,063][INFO ][node                     ] [Gertrude Yorkes] started
[2019-02-13 06:44:57,095][INFO ][gateway                  ] [Gertrude Yorkes] recovered [0] indices into cluster_state

curl で Elasticsearch への接続確認

最後に、curl コマンド経由で docker 上に構築した Elasticsearch へ接続確認しておきましょう。

$ curl http://localhost:9200/_cat/nodes\\?v        
host       ip         heap.percent ram.percent load node.role master name            
172.17.0.3 172.17.0.3            3          97 0.05 d         *      Gertrude Yorkes

の起動・停止コマンド

Elasticsearch の停止

docker stop elasticsearch2.3.1

Elasticsearch の起動

docker start elasticsearch2.3.1

以上、たまに古い version の Elasticsearch が使いたくなる現場からお送りしました。