elasticsearch 5.0需要指定绑定ip,不指定的情况下默认会绑定到127.0.0.1上,导致集群节点不能自动发现所以需要指定ip。
注意 自定义网络节点的时候 有可能子网ip已经被占用了 只要换一个子网ip就可以了
以下是配置
version: "2.1"
services:
elasticsearch_master:
image: elasticsearch:5
command: "elasticsearch -E cluster.name=workagram -E node.master=true -E node.data=false -E network.host=172.23.238.10"
volumes:
- /home/elasticsearch/master:/usr/share/elasticsearch/data:rw
ports:
- "9200:9200"
- "9300:9300"
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
networks:
app_net:
ipv4_address: 172.23.238.10
elasticsearch1:
image: elasticsearch:5
command: "elasticsearch -E cluster.name=workagram -E node.master=false -E node.data=true -E network.host=172.23.238.11 -E discovery.zen.ping.unicast.hosts=elasticsearch_master"
volumes:
- /home/elasticsearch/data1:/usr/share/elasticsearch/data:rw
links:
- elasticsearch_master
networks:
app_net:
ipv4_address: 172.23.238.11
elasticsearch2:
image: elasticsearch:5
command: "elasticsearch -E cluster.name=workagram -E node.master=false -E node.data=true -E network.host=172.23.238.12 -E discovery.zen.ping.unicast.hosts=elasticsearch_master"
volumes:
- /home/elasticsearch/data2:/usr/share/elasticsearch/data:rw
links:
- elasticsearch_master
networks:
app_net:
ipv4_address: 172.23.238.12
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.23.238.0/24
gateway: 172.23.238.1
网友评论