现有环境: 采用VM虚拟机模拟不同服务器
两台centos, 一台ubuntu
docker 的es镜像
elasticsearch:6.5.3
运行的镜像参数
docker run -d --restart=always --name es -p 9200:9200 -p 9300:9300 -v /home/chentong/es/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml elasticsearch:6.5.3
-p 端口映射
-v 主要是修改es容器配置文件映射宿主机
主节点配置
cluster.name: test_cluster
node.name: master
node.master: true
node.data: true
network.host: 0.0.0.0
network.publish_host: 192.168.0.214
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.0.214","192.168.0.92", "192.168.0.137"]
discovery.zen.minimum_master_nodes: 1
从节点1配置
cluster.name: test_cluster
node.name: slave1
node.master: false
node.data: true
network.host: 0.0.0.0
network.publish_host: 192.168.0.92
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.0.214","192.168.0.92", "192.168.0.137"]
discovery.zen.minimum_master_nodes: 1
从节点2配置
cluster.name: test_cluster
node.name: slave2
node.master: false
node.data: true
network.host: 0.0.0.0
network.publish_host: 192.168.0.137
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.0.214","192.168.0.92", "192.168.0.137"]
discovery.zen.minimum_master_nodes: 1
踩坑1
ERROR: bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
- 添加下面配置:
vm.max_map_count=655360
- 并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
踩坑2
docker elasticsearch挂载宿主机报 java.nio.file.AccessDeniedException:/usr/share/elasticsearch/data/nodes
解决方式:
原因:宿主机映射的/database/elasticsearch/cluster/data目录权限不足导致的
解决方案: chmod 776 data 加上权限