单服务器 docker elasticsearch集群

多服务器elasticsearch集群
手动配置 多服务器 elasticsearch集群

将以下文件放在服务器路径中,需要注意各文件相对路径,cd 到docker-compose.yml所在路径

docker-compose up

运行后即可 服务IP:5601 查看kibana页面

docker-compose.yml

version: '2'
services:
  es01:
    image: elasticsearch:6.7.1
    container_name: es01
    environment:
      - "ES_JAVA_OPTS=-Xms1G -Xmx1G"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
      - ./es/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9200:9200
    networks:
      - esnet
  es02:
    image: elasticsearch:6.7.1
    container_name: es02
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1G -Xmx1G"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data
      - ./es/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9201:9200
    links:
      - es01
    networks:
      - esnet
  es03:
    image: elasticsearch:6.7.1
    container_name: es03
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1G -Xmx1G"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata03:/usr/share/elasticsearch/data
      - ./es/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9202:9200
    links:
      - es01
    networks:
      - esnet
  kibana:
    image: kibana:6.7.1
    container_name: kibana
    ports:
      - 5601:5601
    volumes:
      - ./kibana/kibana.yml:/usr/share/kibana/config/kibana.yml:rw
    # environment:
    #   - server.name= kibana
    #   - server.host= 0
    #   - elasticsearch.hosts= http://es01:9200
    #   - xpack.monitoring.ui.container.elasticsearch.enabled= true
    #   - i18n.locale= zh-CN
    networks:
      - esnet
volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local
  esdata03:
    driver: local
networks:
  esnet:
    driver: bridge

es1.yml

cluster.name: wwzb
node.name: es01
node.master: true
node.data: true
http.port: 9200
network.host: 0.0.0.0
#network.publish_host: master-ip
#discovery.zen.ping.unicast.hosts: ["master-ip"]

http.cors.enabled: true
http.cors.allow-origin: "*" 
discovery.zen.minimum_master_nodes: 1

xpack.security.enabled: false

es2.yml

cluster.name: wwzb
node.name: es02
node.master: false
node.data: true
http.port: 9200
network.host: 0.0.0.0
#network.publish_host: data-ip
discovery.zen.ping.unicast.hosts: ["es01"]

http.cors.enabled: true
http.cors.allow-origin: "*" 
discovery.zen.minimum_master_nodes: 1

xpack.security.enabled: false

es3.yml

cluster.name: wwzb
node.name: es01
node.master: true
node.data: true
http.port: 9200
network.host: 0.0.0.0
#network.publish_host: master-ip
#discovery.zen.ping.unicast.hosts: ["master-ip"]

http.cors.enabled: true
http.cors.allow-origin: "*" 
discovery.zen.minimum_master_nodes: 1

xpack.security.enabled: false

kibana.yml

server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://es01:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: zh-CN