es各节点角色配置

环境:
OS:Centos 7
ES:6.8.5

1.节点角色设置
master节点
node.master: true
node.data: false
node.ingest: false

数据节点:
node.master: false
node.data: true
node.ingest: false


协调节点(Coordinating Node)
node.master: false
node.data: false
node.ingest: false

节点输出说明:
[elasticsearch@localhost bin]$ curl -u elastic:elastic http://192.168.1.134:19200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.1.135 24 92 29 3.06 2.29 1.41 di - node-135
192.168.1.114 43 43 10 2.13 1.54 1.07 di - node-114
192.168.1.134 19 90 11 0.33 0.47 0.55 mi * node-134

node.role栏目
m--master节点
d--数据节点
i--ingest节点


说明:
1.集群中最少需要2个主节点,从配置文件中可以看出,避免脑裂
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 1

若想在3个节点的集群中运行起来,需要将如上的参数修改为1


2.master节点不存储数据,可以从数据目录看出,只存储元数据信息
[root@localhost elasticsearch]# du -h ./ --max-depth=1
528K ./data
268K ./logs
796K ./

其他数据节点:
[root@slave1 elasticsearch]# du -h ./ --max-depth=1
940K ./logs
534M ./data
534M ./

[root@host135 elasticsearch]# du -h ./ --max-depth=1
559M ./data
152K ./logs
559M ./


3.master节点也可以接受客户端的请求,写入数据也可以指定master节点,如下:
es = Elasticsearch(hosts=["http://elastic:elastic@192.168.1.134:19200/"])


4.若将master节点修改为可为data节点角色,之前其他data节点的存储数据会重新分布到该节点
原来的mater节点修改为可data节点后
[root@localhost elasticsearch]# du -h ./ --max-depth=1
706M ./data
328K ./logs
707M ./

原来其他data节点的存储会变小了
[root@host135 elasticsearch]# du -h ./ --max-depth=1
321M ./data
164K ./logs
321M ./

[root@slave1 elasticsearch]# du -h ./ --max-depth=1
960K ./logs
321M ./data
322M ./


若将data节点修改为master节点,之前data节点的数据会保留部分
[root@localhost elasticsearch]# du -h ./ --max-depth=1
424M ./data
292K ./logs
425M ./

 

说明:

新版本(7.9以上版本,含7.9版本)的es可以使用如下方式设置节点角色

 

node.roles: [ master ]

 

node.roles: [ data ]

 

posted @ 2025-05-29 18:15  slnngk  阅读(43)  评论(0)    收藏  举报