仕事の復習。故あってバージョンは 7.14.1 で。
仮想マシンは vCPU 2 コア, メモリーは 4 GB とする。
$ free
total used free shared buff/cache available
Mem: 4020176 191448 3134412 1224 694316 3605380
Swap: 0 0 0
/etc/os-release
PRETTY_NAME="Ubuntu 21.10"
NAME="Ubuntu"
VERSION_ID="21.10"
VERSION="21.10 (Impish Indri)"
VERSION_CODENAME=impish
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=impish
docker-compose.yml 作成
基本的には Running the Elastic Stack on Docker | Getting Started [7.14] | Elastic に従う。
今回はバージョンを変更する。
docker-compose.yml
--- docker-compose.yml.bak 2022-03-06 23:32:58.217482346 +0900
+++ docker-compose.yml 2022-03-06 23:33:51.532126137 +0900
@@ -1,7 +1,7 @@
version: '2.2'
services:
es01:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.14.1
container_name: es01
environment:
- node.name=es01
@@ -22,7 +22,7 @@
- elastic
es02:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.14.1
container_name: es02
environment:
- node.name=es02
@@ -41,7 +41,7 @@
- elastic
es03:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.14.1
container_name: es03
environment:
- node.name=es03
@@ -60,7 +60,7 @@
- elastic
kib01:
- image: docker.elastic.co/kibana/kibana:7.14.2
+ image: docker.elastic.co/kibana/kibana:7.14.1
container_name: kib01
ports:
- 5601:5601
vm.max_map_count 変更
初期状態では以下のエラーが発生して Elasticsearch が起動しないので, vm.max_map_count を変更する。
es01 | ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
es01 | bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
es01 | ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/es-docker-cluster.log
基本的には Virtual memory | Elasticsearch Guide [7.14] | Elastic に従う。
$ cd /etc/sysctl.d; pwd
/etc/sysctl.d
$ echo 'vm.max_map_count = 262144' | sudo tee local.conf
vm.max_map_count = 262144
$ ls -l local.conf
-rw-r--r-- 1 root root 26 3月 6 21:20 local.conf
$ cat local.conf
vm.max_map_count = 262144
$ sudo systemctl reboot && exit
# 再起動が完了するまで待機する。
$ sudo sysctl -a | grep -F vm.max_map_count
vm.max_map_count = 262144
起動後確認
この状態で docker-compose up
すると無事に起動する。
docker-compose.yml
に記載されているけども,
- Elasticsearch は localhost:9200 で,
- Kibana は localhost:5601 で,
それぞれ接続できる。
$ curl -X GET "localhost:9200/_cat/nodes?v&pretty"
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.18.0.3 44 94 46 2.81 1.90 0.77 cdfhilmrstw - es02
172.18.0.5 66 94 46 2.81 1.90 0.77 cdfhilmrstw * es01
172.18.0.4 69 94 46 2.81 1.90 0.77 cdfhilmrstw - es03
どっとはらい。