集群规划
- # 1.准备3个ES节点和一个kibana 节点 ES 9200 9300
- - web: 9201 tcp:9301 node-1 elasticsearch.yml
- - web: 9202 tcp:9302 node-2 elasticsearch.yml
- - web: 9203 tcp:9303 node-3 elasticsearch.yml
- - kibana: 5602
注意
所有节点集群名称必须一致 cluster.name
每个节点必须有一个唯一名字 node.name
开启每个节点远程连接 network.host: 0.0.0.0
指定使用 IP地址进行集群节点通信 network.publish_host:
修改 web 端口 tcp 端口 http.port: transport.tcp.port
指定集群中所有节点通信列表 discovery.seed_hosts: node-1 node-2 node-3 相同
允许集群初始化 master 节点节点数: cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
集群最少几个节点可用 gateway.recover_after_nodes: 2
开启每个节点跨域访问http.cors.enabled: true http.cors.allow-origin: "*"
配置文件
# node-1 配置文件
- # 指定集群名称 3个节点必须一致
- cluster.name: es-cluster
- # 指定节点名称 每个节点名字唯一
- node.name: node-1
- # 开放远程链接
- network.host: 0.0.0.0
- # 指定使用发布地址进行集群间通信
- network.publish_host: 192.168.124.3
- # 指定 web 端口
- http.port: 9201
- # 指定 tcp 端口
- transport.tcp.port: 9301
- # 指定所有节点的 tcp 通信
- discovery.seed_hosts: ["192.168.124.3:9301", "192.168.124.3:9302","192.168.124.3:9303"]
- # 指定可以初始化集群的节点名称
- cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
- # 集群最少几个几点可用
- gateway.recover_after_nodes: 2
- # 解决跨域问题
- http.cors.enabled: true
- http.cors.allow-origin: "*"
# node-2 配置文件
- # 指定集群名称 3个节点必须一致
- cluster.name: es-cluster
- # 指定节点名称 每个节点名字唯一
- node.name: node-2
- # 开放远程链接
- network.host: 0.0.0.0
- # 指定使用发布地址进行集群间通信
- network.publish_host: 192.168.124.3
- # 指定 web 端口
- http.port: 9202
- # 指定 tcp 端口
- transport.tcp.port: 9302
- # 指定所有节点的 tcp 通信
- discovery.seed_hosts: ["192.168.124.3:9301", "192.168.124.3:9302","192.168.124.3:9303"]
- # 指定可以初始化集群的节点名称
- cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
- # 集群最少几个几点可用
- gateway.recover_after_nodes: 2
- # 解决跨域问题
- http.cors.enabled: true
- http.cors.allow-origin: "*"
# node-3 配置文件
- # 指定集群名称 3个节点必须一致
- cluster.name: es-cluster
- # 指定节点名称 每个节点名字唯一
- node.name: node-2
- # 开放远程链接
- network.host: 0.0.0.0
- # 指定使用发布地址进行集群间通信
- network.publish_host: 192.168.124.3
- # 指定 web 端口
- http.port: 9202
- # 指定 tcp 端口
- transport.tcp.port: 9302
- # 指定所有节点的 tcp 通信
- discovery.seed_hosts: ["192.168.124.3:9301", "192.168.124.3:9302","192.168.124.3:9303"]
- # 指定可以初始化集群的节点名称
- cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
- # 集群最少几个几点可用
- gateway.recover_after_nodes: 2
- # 解决跨域问题
- http.cors.enabled: true
- http.cors.allow-origin: "*"
编写 compose 文件
- version: "3.8"
- networks:
- escluster:
- services:
- es01:
- image: elasticsearch:7.14.0
- ports:
- - "9201:9201"
- - "9301:9301"
- networks:
- - "escluster"
- volumes:
- - ./node-1/data:/usr/share/elasticsearch/data
- - ./node-1/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- - ./node-1/plugins/ik:/usr/share/elasticsearch/plugins/ik
- environment:
- - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
-
- es02:
- image: elasticsearch:7.14.0
- ports:
- - "9202:9202"
- - "9302:9302"
- networks:
- - "escluster"
- volumes:
- - ./node-2/data:/usr/share/elasticsearch/data
- - ./node-2/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- - ./node-2/plugins/ik:/usr/share/elasticsearch/plugins/ik
- environment:
- - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
-
- es03:
- image: elasticsearch:7.14.0
- ports:
- - "9203:9203"
- - "9303:9303"
- networks:
- - "escluster"
- volumes:
- - ./node-3/data:/usr/share/elasticsearch/data
- - ./node-3/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- - ./node-3/plugins/ik:/usr/share/elasticsearch/plugins/ik
- environment:
- - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
-
- kibana:
- image: kibana:7.14.0
- ports:
- - "5602:5601"
- networks:
- - "escluster"
- volumes:
- - ./kibana.yml:/usr/share/kibana/config/kibana.yml
kibana 配置文件
- # kibana配置文件 连接到ES
- server.host: "0"
- server.shutdownTimeout: "5s"
- elasticsearch.hosts: [ "http://192.168.124.3:9201" ] #链接任意节点即可
- monitoring.ui.container.elasticsearch.enabled: true
查看集群状态
http://10.102.115.3:9200/_cat/health?v