一、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
五、如果你要访问ES,需要使用 https 协议
如果你直接用地址比如:110.212.33.123:9200,是没法访问的,需要带上 https://110.212.33.123:9200。