https://blog.csdn.net/m0_49683806/article/details/123755430

docker pull elasticsearch:7.7.0

https://www.jianshu.com/p/b4b6a7d8c35c

https://huaweicloud.csdn.net/637eeededf016f70ae4c9e98.html

https://www.elastic.co/guide/en/elasticsearch/reference/8.6/configuring-stack-security.html

https://localhost:9200/

http://localhost:5601/

1.docker下载elasticsearch镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.6.0

2.docker创建网络, 方便关联Elasticsearch和Kibana


docker network create elastic

3.运行elasticsearch服务


 docker run --name es01 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e "discovery.type=single-node" --net elastic  -p 9200:9200 -p 9300:9300  -d docker.elastic.co/elasticsearch/elasticsearch:8.6.0



 docker run --name es01 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e "discovery.type=single-node" -e "network.host=0.0.0.0"  --net elastic  -p 9200:9200 -p 9300:9300  -d docker.elastic.co/elasticsearch/elasticsearch:8.6.0

3.运行elasticsearch服务(windwow)



docker run --name es01 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e "discovery.type=single-node" --net elastic  -p 9200:9200 -p 9300:9300   -v C:\0_project\docker\opt\elasticsearch\config\elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -d docker.elastic.co/elasticsearch/elasticsearch:8.6.0

docker run --name es01 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e "discovery.type=single-node" --net elastic  -p 9200:9200 -p 9300:9300   -v C:\0_project\docker\opt\elasticsearch\config\elasticsearch.yml:/usr/share/elasticsearch/config -v C:\0_project\docker\opt\elasticsearch\data:/usr/share/elasticsearch/data  -d docker.elastic.co/elasticsearch/elasticsearch:8.6.0

4.重置密码 M-xOTp3D2Y7HzyjQGiE7


docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -uelastic

/usr/share/elasticsearch/elasticsearch.yml

5.复制 http_ca.crt 证书文件到本地

docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-certutil ca

docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .


docker cp es01:/usr/share/elasticsearch/config/certs/http.p12 /usr/share/elasticsearch/config

6.测试访问(通过网页访问)

http://localhost:9200/


curl --cacert http_ca.crt -u elastic https://localhost:9200

进入容器


docker exec -it es01 bash

bin\elasticsearch-create-enrollment-token.bat --scope kibana


eyJ2ZXIiOiI4LjYuMCIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiYmM3ZWQyZGEyYTg3YmI1NTAyMDYzNTZlZDQ4MzJhODBiZWVjYjNmMTI4ZWZjMzg4YzFhYWE3ZTc4ODNhOWRmNSIsImtleSI6Im90Wjh2SVlCeVRmYVhpUmhEbXAyOmtVZU8yZGxKVHY2a2dwT1hPYW85NXcifQ==

7.设置JVM参数(可以不操作)


docker run -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -e ENROLLMENT_TOKEN="tokenelastic" --name es01 -p 9200:9200 --net elastic -it docker.elastic.co/elasticsearch/elasticsearch:8.6.0

8.docker拉取kibana镜像


docker pull docker.elastic.co/kibana/kibana:8.6.0

9.启动kibana服务

http://localhost:5601/

docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.6.0

重装密码 RN9nBqIaGnhyz5fHnjgi

bin\elasticsearch-reset-password.bat --username kibana_system

/usr/share/elasticsearch/bin/elasticsearch-reset-password -u kibana_system

10.docker卸载

docker network rm elastic
docker rm es01
docker rm kib01
文档更新时间: 2023-03-09 19:54   作者:admin