📣读完这篇文章里你能收获到
- 在Docker中快速部署单机版的ElasticSearch
- 感谢点赞+收藏,避免下次找不到~
一、拉取镜像
- 版本号根据需要自己选择,这里以
7.7.0
为例
docker pull elasticsearch:7.7.0
二、创建挂载目录
1 宿主机与容器挂载映射
宿主机位置 | 容器位置 |
---|---|
/opt/elasticsearch/config | /usr/share/elasticsearch/config |
/opt/elasticsearch/data | /usr/share/elasticsearch/data |
/opt/elasticsearch/plugins | /usr/share/elasticsearch/plugins |
2 挂载命令执行
sudo mkdir -p /opt/elasticsearch/config
sudo mkdir -p /opt/elasticsearch/data
sudo mkdir -p /opt/elasticsearch/plugins
# 赋予权限
sudo chmod -R 777 /opt/elasticsearch/
# ES配置文件
echo "http.host: 0.0.0.0" >> /opt/elasticsearch/config/elasticsearch.yml
三、创建容器—运行ES
sudo docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /opt/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /opt/elasticsearch/data:/usr/share/elasticsearch/data \
-v /opt/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.7.0
说明:
- -p 端口映射
- -e discovery.type=single-node 单点模式启动
- -e ES_JAVA_OPTS="-Xms84m -Xmx512m":设置启动占用的内存范围
- -v 目录挂载
- -d 后台运行
四、查看ES是否启动成功
- 打开
http://ip:9200