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

posted @ 2023-03-30 18:34  M-Anonymous  阅读(296)  评论(0编辑  收藏  举报