#创建网络,可以使用已经创建的网络
sudo docker network create es_network
#创建挂载文件夹
sudo mkdir -p /mydata/elasticsearch/{config,data,plugins,logs}
# elasticsearch.yml 配置文件
network.host: 0.0.0.0 # 禁止自动创建索引 action.auto_create_index: false xpack.security.enabled: true http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization
#配置完成,执行命令启动elasticsearch并挂载配置文件到虚拟机目录: sudo docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms2621m -Xmx2921m" --network es_network -v /home/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/elasticsearch/logs:/usr/share/elasticsearch/logs -v /home/elasticsearch/data:/usr/share/elasticsearch/data -v /home/elasticsearch/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.14.0
#修改es密码
sudo docker exec -it es01 bash
进入到 es 容器的 bin 目录下修改密码
elasticsearch-setup-passwords interactive
# 查看 es 容器对外暴露的 IP
sudo docker inspect elasticsearch | grep IPAddress
# 事先要把 /home/kibana/config/kibana.yml 这个文件创建好
sudo docker run -d --name kibana -p 5601:5601
--restart=always
--network es_network
-e TZ=Asia/Shanghai
-e "ELASTICSEARCH_HOSTS=http://172.18.0.2:9200"
-v /home/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
kibana:7.14.0
# kibana.yml 配置
server.host: "0" server.shutdownTimeout: "5s" monitoring.ui.container.elasticsearch.enabled: true elasticsearch.hosts: [ "https://192.168.0.109:9200" ] elasticsearch.username: kibana_system elasticsearch.password: "123456" i18n.locale: "zh-CN"
#查看容器运行的日志
sudo docker logs -f 容器ID
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)