Docker安装es7.8及基本操作
一、首先运行一个容器
# 基本启动命令 # -e "discovery.type=single-node" \ 单节点集群 # -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" \ 制定运行参数,不然如果机器内存太小,启动后会非常卡顿 # --name 起个别名 docker run -p 9200:9200 -p 9300:9300 --name es7.8 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" \ -d elasticsearch:7.8.0
二、在容器里copy出配置文件
docker cp es7.8:/usr/share/elasticsearch/config /home/app/elasticsearch
三、删除容器,然后重新运行容器并挂载本地目录
docker run -p 9200:9200 -p 9300:9300 --name es7.8 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" \ -v /home/app/elasticsearch/plugins:/usr/share/elasticsearch/plugins \ -v /home/app/elasticsearch/data:/usr/share/elasticsearch/data \ -v /home/app/elasticsearch/logs:/usr/share/elasticsearch/logs \ -v /home/app/elasticsearch/config:/usr/share/elasticsearch/config \ -d elasticsearch:7.8.0
⚠️ 注意:以下三个目录需要配置下775权限,否则容器跑不起来
chmod -R 775 /home/app/elasticsearch/data; chmod -R 775 /home/app/elasticsearch/logs; chmod -R 775 /home/app/elasticsearch/config;
四、运行好以后查看状态
[root@iZbp12ifz6ke6o7n5vk599Z logs]# curl http://localhost:9200 { "name" : "7726e86f18d8", "cluster_name" : "docker-cluster", "cluster_uuid" : "xc5O24kcSceZsI46AOZuQQ", "version" : { "number" : "7.8.0", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65", "build_date" : "2020-06-14T19:35:50.234439Z", "build_snapshot" : false, "lucene_version" : "8.5.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
参考:https://baijiahao.baidu.com/s?id=1758451332960611733&wfr=spider&for=pc