1.关闭虚拟机防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
systemctl status firewalld.service #查看firewall的状态
2.在docker hub 上拉取镜像
docker pull elasticsearch:7.4.2
3.创建挂载目录
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
4.写入配置
echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml
5.授权目录
chmod -R 777 /mydata/elasticsearch/
6.启动docker
注:此处应指明容器启动内存,否则容器启动会占用大量虚拟机内存而导致容器卡死。
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-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.4.2
kibana 安装
1.拉取镜像
docker pull kibana:7.4.2
2.启动kibana
这里的坑来了:拉取后正常启动
==访问5601端口却一直报错Kibana server is not ready yet==
<html>
可能是前面没有关闭防火墙导致,关闭防火墙后回导致:自定义链DOCKER由于某种原因被清掉,此时应重启docker容器即可解决
</html>
docker run -it --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.1.101:9200 -p 5601:5601 -d kibana:7.4.2
进入容器内部
docker exec -it 容器ID /bin/bash
查看容器ip
docker inspect 容器ID
网友评论