3分钟完成Macbook m1芯片使用docker安装Elasticsearch和Kibana
1、下载镜像文件
elasticsearch:存储和检索数据;
kibana:可视化检索数据
docker pull elasticsearch:7.16.2
docker pull kibana:7.16.2
2、创建es实例
2.1、本地创建3个文件夹config/data/plugins,并修改权限,用作映射
mkdir software/elasticsearch/config
mkdir software/elasticsearch/data
mkdir software/elasticsearch/plugins
echo "http.host: 0.0.0.0" >> software/elasticsearch/config/elasticsearch.yml
chmod -R 777 software/elasticsearch/
2.2、启动es
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /Users/benjie/software/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /Users/benjie/software/elasticsearch/data:/usr/share/elasticsearch/data \
-v /Users/benjie/software/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.16.2
解释:
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \ 设置ES的初始内存和最大内存,否则导致过大启动不了ES
2.3、验证访问http://localhost:9200
:
3、创建Kibana
3.1 查询elasticsearch中的内部ip,查询命令:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' elasticsearch
3.2、启动kibana
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://172.17.0.2:9200 -p 5601:5601 -d kibana:7.16.2
-e ELASTICSEARCH_HOSTS= http://172.17.0.2:9200 一定要先查询到内部ip,替换