1. 下载镜像
必须指定版本,否则会报错
adc@adc-vm:~/db/es/config$ docker pull elasticsearch
Using default tag: latest
Error response from daemon: manifest for elasticsearch:latest not found: manifest unknown: manifest unknown
可以去https://registry.hub.docker.com/
搜索镜像查看版本,我选择的是8.5.3
docker pull elasticsearch:8.5.3
docker pull kibane:8.5.3
2. kibana和elasticsearch需要互联,因此创建一个网络
docker network create es-net
3. 创建elasticsearch容器
mkdir -p ~/db/{config,data,logs,plugins}
docker run -d --name elasticsearch \
-e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" \
-e "discovery.type=single-node" \
-v ~/db/es/data:/usr/share/elasticsearch/data \
-v ~/db/es/logs:/usr/share/elasticsearch/logs \
-v ~/db/es/plugins:/usr/share/elasticsearch/plugins \
--privileged --restart=always --network es-net \
-p 9200:9200 -p 9300:9300 elasticsearch:8.5.3
3.1 elasticsearch不允许kibana通过elastic登录
别的版本我不知道,反正8.5.3不允许这么干,后面创建kibana的容器时会报错
adc@adc-vm:~/db/es/config$ docker logs kibana
[2023-01-02T00:03:08.415+00:00][INFO ][node] Kibana process configured with roles: [background_tasks, ui]
[2023-01-02T00:03:23.664+00:00][INFO ][plugins-service] Plugin "cloudExperiments" is disabled.
[2023-01-02T00:03:23.673+00:00][INFO ][plugins-service] Plugin "profiling" is disabled.
[2023-01-02T00:03:23.699+00:00][FATAL][root] Error: [config validation of [elasticsearch].username]: value of "elastic" is forbidden. This is a superuser account that cannot write to system indices that Kibana needs to function. Use a service account token instead. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/8.0/service-accounts.html
at ensureValidConfiguration (/usr/share/kibana/node_modules/@kbn/core-config-server-internal/target_node/src/ensure_valid_configuration.js:25:11)
at Server.preboot (/usr/share/kibana/src/core/server/server.js:188:5)
at Root.preboot (/usr/share/kibana/src/core/server/root/index.js:48:14)
at bootstrap (/usr/share/kibana/src/core/server/bootstrap.js:99:9)
at Command.<anonymous> (/usr/share/kibana/src/cli/serve/serve.js:216:5)
FATAL Error: [config validation of [elasticsearch].username]: value of "elastic" is forbidden. This is a superuser account that cannot write to system indices that Kibana needs to function. Use a service account token instead. Learn more: https://www.elastic.co/guide/en/elasticsearch/reference/8.0/service-accounts.html
3.2 elasticsearch修改用户密码
elasticsearch-reset-password -u ${username} -i
# -i 表示交互式执行,可以用来自己指定密码,没有此参数系统将会自动生成一个密码
# eg:
elasticsearch-reset-password -u elastic -i
3.3 创建新的超级用户用于kibana登录
# 登录容器
adc@adc-vm:~/db/es/config$ docker exec -it elasticsearch bash
# 创建用户 es_admin
elasticsearch@3a95706ce9c9:~$ bin/elasticsearch-users useradd es_admin
Enter new password:
Retype new password:
elasticsearch@3a95706ce9c9:~$
# 为用户es_admin增加超级用户权限
elasticsearch@3a95706ce9c9:~$ bin/elasticsearch-users roles -a superuser es_admin
4. 安装kibana容器
docker run -d --name kibana -p 5601:5601 \
--network es-net \
-e ELASTICSEARCH_URL=http://192.168.1.99:9200 \
-e ELASTICSEARCH_HOSTS=http://192.168.1.99:9200 \
-e ELASTICSEARCH_USERNAME="kibana" \
-e ELASTICSEARCH_PASSWORD="HDLJD1lzsx--" \
-v ~/db/kibana/data:/usr/share/kibana/data \
-v ~/db/kibana/plugins:/usr/share/kibana/plugins \
--privileged kibana:8.5.3
简单介绍一下上面的命令:
es_admin
是之前创建的用于kibana登录的超级用户es_admin_password
是我创建用户时为其设置的密码文章来源:https://www.toymoban.com/news/detail-645617.html
后记: 我一直失败,反复删除和安装容器,各种尝试,最后也不知道怎么成功的,真的要哭了
docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-reset-password -u kibana -i文章来源地址https://www.toymoban.com/news/detail-645617.html
到了这里,关于docker中安装elasticsearch的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!