用于集群在第一次启动时,指定可以参与选举的主节点列表 (node.master: true)
cluster.initial_master_nodes: [“es01”, “es02”, “es03”]
cluster.initial_master_nodes:
-es01
-es02
-es03
- discovery.seed_hosts 如果不配置,会自动监听本地回环地址 将本地多个elasticsearch实例加入到集群中。
jvm配置
- /opt/es/config/jvm.options (一般配置为机器内存大小的一半)
sed -i “s/-Xms1g/-Xms"800m”/g" /opt/es/config/jvm.options
sed -i “s/-Xmx1g/-Xmx"800m”/g" /opt/es/config/jvm.options
es01
cluster.name: es-cluster-test
node.name: es01
path.logs: /opt/log/es
path.data: /opt/data/es
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: [“172.16.1.236:9306”, “172.16.1.236:9307”]
cluster.initial_master_nodes: [“es01”, “es02”, “es03”]
es02
cluster.name: es-cluster-test
node.name: es02
path.logs: /opt/log/es
path.data: /opt/data/es
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: [“172.16.1.236:9305”, “172.16.1.236:9307”]
cluster.initial_master_nodes: [“es01”, “es02”, “es03”]
es03
cluster.name: es-cluster-test
node.name: es03
path.logs: /opt/log/es
path.data: /opt/data/es
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: [“172.16.1.236:9305”, “172.16.1.236:9306”]
cluster.initial_master_nodes: [“es01”, “es02”, “es03”]
启动
-
分别进入不同的容器启动elasticsearch
-
命令如下
/opt/es/bin/elasticsearch -d
查看容器状况(容器内)
- 查看集群是否启动成功
[elasticsearch@813bf8515935 /]$ curl localhost:9200/_cat/nodes
172.17.0.7 28 91 9 0.58 0.66 0.90 dilm - es02
172.17.0.6 15 91 5 0.58 0.66 0.90 dilm - es01
172.17.0.8 35 91 13 0.58 0.66 0.90 dilm * es03
- 查看当前节点
[elasticsearch@813bf8515935 /]$ curl localhost:9200
{
“name” : “es03”,
“cluster_name” :