一.下载ElasticSearch和kibana镜像
docker pull ElasticSearch:7.17.0
docker pull kibana:7.17.0
(注:两者版本号必须一致)
二.配置
在虚拟机目录下的创建文件夹
mkdir -p /root/software/elasticsearch/config
mkdir -p /root/software/elasticsearch/data
并执行下述两个命令
echo "http.host: 0.0.0.0" >> /root/software/elasticsearch/config/elasticsearch.yml
chmod -R 777 /root/software/elasticsearch/
三.启动elasticsearch镜像
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx512m" \
-v /root/software/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /root/software/elasticsearch/data:/usr/share/elasticsearch/data \
-v /root/software/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.17.0
其中:-e ES_JAVA_OPTS="-Xms256m -Xmx512m
设置 ES 的初始内存和最大内存
使用docker ps查看镜像是否运行成功
四.创建kibana实例
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://<ip地址>:9200 -p 5601:5601 \
-d kibana:7.17.0
浏览器输入:ip:5601即可登录kibana可视化界面
# 查看所有节点
GET /_cat/nodes
# 查看 es 健康状况
GET /_cat/health
# 查看主节点
GET /_cat/master
# 查看所有索引
GET /_cat/indices