下载elastic search和kibana
docker pull elasticsearch:7.6.2
docker pull kibana:7.6.2
配置
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0" >/mydata/elasticsearch/config/elasticsearch.yml
chmod -R 777 /mydata/elasticsearch/
启动Elastic search
docker run --name elasticsearch -p 9200:9200 -p 9300:9300
-e "discovery.type=single-node"
-e ES_JAVA_OPTS="-Xms64m -Xmx512m"
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
-d elasticsearch:7.6.2
开机自启
docker update elasticsearch --restart=always
启动kibana
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.162.139:9200 -p 5601:5601 -d kibana:7.6.2
这里192.168.162.139是我的虚拟机ip地址,启动后发现进不去kibana的ui页面(192.168.162.139:5601),如果能进去,请忽略以下步骤。
查看日志:docker logs kibana
删除kibana容器
先docker stop kibana,再docker rm kibana
查看es在docker的ip
docker inspect elasticsearch | grep IPAddress
重新运行kibana
并修改es的hosts,与上图对应
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://172.17.0.2:9200 -p 5601:5601 -d kibana:7.6.2
运行成功。
kibana开机自启
docker update kibana --restart=always