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.ymljava
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.ymlnode
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
若是你用的是elasticsearch6.0版本,又會有新的問題,詳情看docker
https://www.elastic.co/cn/blog/strict-content-type-checking-for-elasticsearch-rest-requestssegmentfault
參考博客
https://blog.csdn.net/u012915455/article/details/78952068
https://blog.csdn.net/wanghao_0206/article/details/79583325
http://www.javashuo.com/article/p-aduealvv-bh.html
https://blog.csdn.net/sinat_31908303/article/details/80496349
https://blog.csdn.net/moliyiran/article/details/53791515
http://www.javashuo.com/article/p-tgvigged-gw.htmlapp