docker-compose搭建elasticsearch 8.6.0集群 —— 筑梦之路

docker-compose.yml

version: '3.6'
services:
  es_1:
    # 镜像名称
    image: elasticsearch:8.6.0
    # 容器名称
    container_name: es_1
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    # 文件映射到主机
    volumes:
      - /data/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/es/plugins:/usr/share/elasticsearch/plugins
      - /data/es/data/es1-data:/usr/share/elasticsearch/data
    # 赋予权限
    privileged: true
    #端口映射
    ports:
      - 9200:9200
      - 9300:9300
    # 指定网段
    networks:
      defalut:
        ipv4_address: 173.199.8.2  #设置ip地址
  es_2:
    # 镜像名称
    image: elasticsearch:8.6.0
    # 容器名称
    container_name: es_2
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    # 文件映射到主机
    volumes:
      - /data/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/es/plugins:/usr/share/elasticsearch/plugins
      - /data/es/data/es2-data:/usr/share/elasticsearch/data
    # 赋予权限
    privileged: true
    #端口映射
    ports:
      - 9201:9200
      - 9301:9300
    # 指定网段
    networks:
      defalut:
        ipv4_address: 173.199.8.3  #设置ip地址
  es_3:
    # 镜像名称
    image: elasticsearch:8.6.0
    # 容器名称
    container_name: es_3
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    # 文件映射到主机
    volumes:
      - /data/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/es/plugins:/usr/share/elasticsearch/plugins
      - /data/es/data/es3-data:/usr/share/elasticsearch/data
    # 赋予权限
    privileged: true
    #端口映射
    ports:
      - 9202:9200
      - 9302:9300
    # 指定网段
    networks:
      defalut:
        ipv4_address: 173.199.8.4  #设置ip地址
  kibana:
    # 镜像名称
    image: kibana:8.6.0
    # 容器名称
    container_name: kibana
    ports:
      - 5601:5601
    volumes:
      - /data/es/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    depends_on:
      - elasticsearch-cluster
    networks:
      defalut:
        ipv4_address: 173.199.8.5  #设置ip地址
networks:
  defalut:
    driver: bridge
    ipam:
      config:
        - subnet: "173.199.8.0/24"

es1.yml

cluster.name: elasticsearch-cluster
node.name: es-node1
network.host: 0.0.0.0
network.publish_host: 173.199.8.2
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: es-node1
discovery.seed_hosts: ["173.199.8.2:9300", "173.199.8.3:9300", "173.199.8.4:9300"]
transport.profiles.default.port: 9300
xpack.security.enabled: false

es2.yml

cluster.name: elasticsearch-cluster
node.name: es-node2
network.host: 0.0.0.0
network.publish_host: 173.199.8.3
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: es-node1
discovery.seed_hosts: ["173.199.8.2:9300", "173.199.8.3:9300", "173.199.8.4:9300"]
transport.profiles.default.port: 9300
xpack.security.enabled: false

es3.yml

cluster.name: elasticsearch-cluster
node.name: es-node3
network.host: 0.0.0.0
network.publish_host: 173.199.8.4
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: es-node1
discovery.seed_hosts: ["173.199.8.2:9300", "173.199.8.3:9300", "173.199.8.4:9300"]
transport.profiles.default.port: 9300
xpack.security.enabled: false

kibana.yml

elasticsearch.hosts: ["http://es_1:9200","http://es_2:9200","http://es_3:9200"]
server.host: 0.0.0.0
server.port: 5601
i18n.locale: "zh-CN"

参考资料:

docker-compose 搭建elasticsearch 集群及kibana - 简书

更新_Docker安装ElasticSearch8.6.0

Docker安装ElasticSearch8.6.0

你可能感兴趣的:(数据库技术,linux系统运维,elasticsearch,docker)