使用Docker安装Elasticsearch&Kibana 8.x系列

212 阅读2分钟

8.x版本的es安装和7有点不同,尤其是启动的时候不能设置挂载。我按7的方式配置挂载之后出现启动闪退等问题,所以在此记录下。

1.elasticsearch

下载镜像

 docker pull elasticsearch:8.4.3

启动镜像

 docker network create elastic
 ​
 docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -t elasticsearch:8.4.3

-t一定要加,因为这样才会在终端输出密码等信息。

如果访问 https://localhost:9200成功则说明启动成功。

需要登录账号和密码。 必须是https

202210281832626.png

202210281834878.png

日志最后一段有用户名:elastic 密码:sZR5GJNx1P+S7hbeyk*Z

 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -> 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`):
   sZR5GJNx1P+S7hbeyk*Z
 ​
 ->  HTTP CA certificate SHA-256 fingerprint:
   f7d9d76d9c1c4173b8620351c8b83966d2472cb3df5327ee3e9ad53cbfbcd24b
 ​
 ->  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):
   eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiZjdkOWQ3NmQ5YzFjNDE3M2I4NjIwMzUxYzhiODM5NjZkMjQ3MmNiM2RmNTMyN2VlM2U5YWQ1M2NiZmJjZDI0YiIsImtleSI6Ik9CNWNIb1FCVGtxcVhlencyVW15OnZPRHhRQ1RGU3RLZWtCTGl5SFZodXcifQ==
 ​
 -> 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):
   eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiZjdkOWQ3NmQ5YzFjNDE3M2I4NjIwMzUxYzhiODM5NjZkMjQ3MmNiM2RmNTMyN2VlM2U5YWQ1M2NiZmJjZDI0YiIsImtleSI6Ik9SNWNIb1FCVGtxcVhlencyVW15OlMtNWpWeHBxVGd1d2tic0Q3cy1yWVEifQ==
 ​
   If you're running in Docker, copy the enrollment token and run:
   `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.3`
 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 ​
 ​

2.kibana

注意:kibana的版本必须和Elasticsearch版本一样

 docker pull kibana:8.4.3
 ​
 docker run --name kib-01 --net elastic -p 5601:5601 kibana:8.4.3

启动后有日志:

 ...
 i Kibana has not been configured.
 ​
 Go to http://0.0.0.0:5601/?code=088789 to get started.

按提示访问网站:http://0.0.0.0:5601/?code=088789

并将上面的token填入,注意这个token有效期只有30min

image-20221028192828250

成功

image-20221028193231985

image-20221028193305994