在 Lubuntu 21.10 上启动 Docker 版 Elastic Stack

工作的回顾。出于某种原因,版本使用 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
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 文件。

在 Docker 上运行 Elastic Stack | 入门指南 [7.14] | 遵循 Elastic 的基本要求。
此次我们要更换版本。

--- 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

After starting up, please verify.

以这种状态运行 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
Screen Shot 2022-03-06 at 21.31.29-fullpage.png

突然感到厌倦。

广告
将在 10 秒后关闭
bannerAds