CentOS7 Docker安裝 ElasticSearch8、Kibana8

一、Docker安裝

yum install -y docker
#開機自啓
systemctl enable docker
#啓動 docker
systemctl start docker

二、安裝 ElasticSearch

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.6.2
vi /etc/sysctl.conf
在/etc/sysctl.conf文件最後添加一行
vm.max_map_count=262144
docker network create elastic
docker run --name es01 --net elastic -p 9200:9200 -it docker.elastic.co/elasticsearch/elasticsearch:8.6.2
#運行成功後,會出現:
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.

ℹ️  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  fahCf24pIcF6ytXOY95=

ℹ️  HTTP CA certificate SHA-256 fingerprint:
  860a07d87cd669c5e83fd1228c8dbdc35afe40802f80661d7990770bf93e58b1

ℹ️  Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjYuMiIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiODYwYTA3ZDg3Y2Q2NjljNWU4M2ZkMTIyOGM4ZGJkYzM1YWZlNDA4MDJmODA2NjFkNzk5MDc3MGJmOTNlNThiMSIsImtleSI6Ii1VMy1NWWNCZUxJWDZldDJ0bW5BOmozbzQ2ejJrUjFpaERfSEExS1BNdEEifQ==

ℹ️ Configure other nodes to join this cluster:
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjYuMiIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiODYwYTA3ZDg3Y2Q2NjljNWU4M2ZkMTIyOGM4ZGJkYzM1YWZlNDA4MDJmODA2NjFkNzk5MDc3MGJmOTNlNThiMSIsImtleSI6Ii0wMy1NWWNCZUxJWDZldDJ0MmsyOlF1TVktVWhVVHE2T1lhcFZLSnZ2SFEifQ==

  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.6.2`

三、安裝 Kibana

docker pull docker.elastic.co/kibana/kibana:8.6.2
docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.6.2
#運行成功後,會讓你訪問:
Go to http://0.0.0.0:5601/?code=989981 to get started.
0.0.0.0 替換成你服務器的地址
然後將上一步生成的的Kibana token 輸入,最後輸入用戶名elastic,生成的密碼,即可訪問

四、其他配置

#如果想要自定義 ElasticSearch 密碼:
docker exec -it es01 /bin/bash
elasticsearch-reset-password -u elastic -i
#如果你的 ElasticSearch 佔用內存過高,可以進行如下修改:
docker exec -it es01 /bin/bash
cd config/jvm.options.d
#文件名隨便取,只要後綴是 options就行
vi heapmemory.options -Xms512m -Xmx512m
#如果沒有 vi 命令,以root用戶進入容器
docker exec -it --user root es01 /bin/bash
apt-get update
apt-get install vim

五、如果你要訪問ES,需要使用 https 協議

如果你直接用地址比如:110.212.33.123:9200,是沒法訪問的,需要帶上 https://110.212.33.123:9200。

六、記得安全組開放端口、防火牆開放端口

參考:https://www.cnblogs.com/tanghaorong/p/16324481.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章