docker安装elasticsearch记录

下载

docker pull elasticsearch:7.3.0

配置

mkdir -p /data/docker/elasticsearch

vim elasticsearch.yml

配置文件

cluster.name: elasticsearch-cluster
node.name: master
network.bind_host: 0.0.0.0
network.publish_host: "ip"
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true 
node.data: true  
discovery.zen.ping.unicast.hosts: ["ip:9300","ip:9301"]

运行

docker run  -d -p 9200:9200 -p 9300:9300 -v /data/docker/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /data/docker/elasticsearch/data:/usr/share/elasticsearch/data -v /data/docker/elasticsearch/logs:/usr/share/elasticsearch/logs --name es-master elasticsearch:7.3.0

-d 后台运行
-p 映射端口
-v 挂载本地目录,挂载配置文件
--name 容器名字

问题解决

启动时遇到两个问题,没有启动成功,下面是解决方法

docker logs 容器id  //查看启动日志

Error opening log file 'logs/gc.log': Permission denied

因为挂载本地目录,本地目录又是root创建的,elasticsearch 不能用root权限运行,所以修改文件夹权限即可

sudo chmod -R 775 /data/docker/elasticsearch/
sudo chown -R 1000:1000  /data/docker/elasticsearch/

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

jvm 内存不够需要修改系统jvm内存

vim /etc/sysctl.conf
追加配置
vm.max_map_count=655300

修改完后执行: sudo sysctl -p可以执行:more /proc/sys/vm/max_map_count验证下是否修改成功

修改完成后docker start container id重新启动容器,启动成功


参考链接:https://www.jianshu.com/p/ba7caa5bed53

你可能感兴趣的:(docker安装elasticsearch记录)