network.bind_host: 0.0.0.0
cluster.name: es_cluster
node.name: master
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
#network.host: 0.0.0.0
network.publish_host: 172.20.0.2
discovery.zen.minimum_master_nodes: 1
es2.yml
network.bind_host: 0.0.0.0
cluster.name: es_cluster
node.name: node2
node.master: false
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
#network.host: 0.0.0.0
network.publish_host: 172.20.0.3
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: es1
docker-compose.yml
version: '2'
services:
elasticsearch-central:
image: elasticsearch:5.6.4
container_name: es1
volumes:
- /root/mydocker/docker-es/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /root/mydocker/docker-es/data1:/usr/share/elasticsearch/data
restart: always
environment:
- ES_CLUSTERNAME=elasticsearch
- "ES_JAVA_OPTS=-Xmx50m -Xms50m"
command: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
networks:
extnetwork:
ipv4_address: 172.20.0.2
elasticsearch-data:
image: elasticsearch:5.6.4
container_name: es2
volumes:
- /root/mydocker/docker-es/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /root/mydocker/docker-es/data2:/usr/share/elasticsearch/data
restart: always
environment:
- ES_CLUSTERNAME=elasticsearch
- "ES_JAVA_OPTS=-Xmx50m -Xms50m"
command: elasticsearch
ports:
- "9201:9200"
- "9301:9300"
links:
- elasticsearch-central:elasticsearch
networks:
extnetwork:
ipv4_address: 172.20.0.3
elasticsearch-head:
image: mobz/elasticsearch-head:5
container_name: head
volumes:
- /root/mydocker/docker-es/head-conf/Gruntfile.js:/usr/src/app/Gruntfile.js
- /root/mydocker/docker-es/head-conf/app.js:/usr/src/app/_site/app.js
ports:
- "9100:9100"
links:
- elasticsearch-central:elasticsearch
networks:
extnetwork:
ipv4_address: 172.20.0.4
networks:
extnetwork:
ipam:
config:
- subnet: 172.20.0.0/16
gateway: 172.20.0.1
参考博客 https://blog.csdn.net/u012915455/article/details/78952068 https://blog.csdn.net/wanghao_0206/article/details/79583325 https://blog.csdn.net/hechaojie_com/article/details/83625265 https://blog.csdn.net/sinat_31908303/article/details/80496349 https://blog.csdn.net/moliyiran/article/details/53791515 https://segmentfault.com/a/1190000014283157