Elasticsearch+kibana下载安装
- docker pull elasticsearch:7.16.2
- docker run --name es -d -e ES_JAVA_OPTS=“-Xms512m -Xmx512m” -e “discovery.type=single-node” -p 9200:9200 -p 9300:9300 elasticsearch:7.16.2
- docker pull kibana:7.16.2
- docker run --name kibana -e
ELASTICSEARCH_HOSTS=http://host.docker.internal:9200 -p 5601:5601 -d
kibana:7.16.2
挂载目录
将 Docker 中的 Elasticsearch 目录挂载到本地,如下命令依次执行
docker run --name es -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 elasticsearch:7.16.2
docker cp -a es:/usr/share/elasticsearch/config/ /opt/es
docker cp -a es:/usr/share/elasticsearch/data/ /opt/es
docker cp -a es:/usr/share/elasticsearch/logs/ /opt/es
docker cp -a es:/usr/share/elasticsearch/plugins/ /opt/es
docker stop es
docker rm es
运行 Elasticsearch
docker run -p 9200:9200 -p 9300:9300 \
--privileged=true --name es \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /opt/es/plugins:/usr/share/elasticsearch/plugins \
-v /opt/es/data:/usr/share/elasticsearch/data \
-v /opt/es/logs:/usr/share/elasticsearch/logs \
-v /opt/es/config:/usr/share/elasticsearch/config \
-d elasticsearch:7.16.2
发现报错(没权限访问挂载目录)
配置 Docker 允许访问的共享文件夹 /opt/es
安装 Ik 分词器
将下载好的 IK 包解压丢到 /opt/es/plugins 文件夹下面即可。下载地址
再次启动发现又报错了(rf .DS_Store文件错误)
切换到 /opt/es/plugins 目录下
cd /opt/es/plugins
删除 DS_Store 文件
rm .DS_Store
接着执行
docker run -p 9200:9200 -p 9300:9300 \
--privileged=true --name es \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /opt/es/plugins:/usr/share/elasticsearch/plugins \
-v /opt/es/data:/usr/share/elasticsearch/data \
-v /opt/es/logs:/usr/share/elasticsearch/logs \
-v /opt/es/config:/usr/share/elasticsearch/config \
-d elasticsearch:7.16.2