一、安装elasticsearch
1、拉取镜像
docker pull elasticsearch:7.12.1
2、构建容器&运行
docker run --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.12.1
3、修改配置
1、进入容器&打开文件
docker exec -it es bash
cd config
vi elasticsearch.yml
2、编辑文件
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
3、重启es并设置密码
cd bin
elasticsearch-setup-passwords interactive
// 输出
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]Y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
4、退出&重启
exit
docker restart es
二、安装kibana
1、拉取镜像
docker pull kibana:7.10.0
2、构建容器&运行
YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:Elasticsearch容器的名字或容器ID
docker run --name kibana -d --link YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:elasticsearch -p 5601:5601 kibana:7.10.0
3、修改配置
1、进入容器&打开文件
docker exec -it kibana bash
cd config
vi kibana.yml
2、编辑文件
IpAddress:docker inspect es查看es容器内部的ip地址
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://{IpAddress}:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: "elastic"
elasticsearch.password: "password"
i18n.locale: "zh-CN"
3、退出&重启
exit
docker restart kibana
Elasticsearch界面
Kibana界面