Elasticsearch集群扩容

本文详细介绍了如何在Elasticsearch集群中进行安全、有效的扩容操作,包括关闭自动平衡、逐个启动新增节点、检查集群状态、开启自动平衡、验证shards分布以及业务测试等关键步骤。
摘要由CSDN通过智能技术生成

1. 部署图

在这里插入图片描述

1)原ES集群信息
IP 集群名称 http端口号 tcp端口号
192.168.2.11 es_es11223_cluster 11223 11224
192.168.2.12 es_es11223_cluster 11223 11224
192.168.2.13 es_es11223_cluster 11223 11224
2)新ES集群信息
IP 集群名称 http端口号 tcp端口号
192.168.2.11 es_es11223_cluster 11223 11224
192.168.2.12 es_es11223_cluster 11223 11224
192.168.2.13 es_es11223_cluster 11223 11224
192.168.2.14 es_es11223_cluster 11223 11224
192.168.2.15 es_es11223_cluster 11223 11224
192.168.2.16 es_es11223_cluster 11223 11224

2. 关闭自动平衡

关闭自动平衡:
# curl -H "Content-Type: application/json"  -XPUT  http://192.168.2.11:11223/_cluster/settings?pretty -d '{"transient": {"cluster.routing.allocation.enable": "none"}}'


确认自动平衡已关闭:
# curl -H "Content-Type: application/json" -XGET 'http://192.168.2.11:11223/_cluster/settings?pretty'

3. 启动192.168.2.14:11223节点

3.1. 检查集群状态

查看检查集群状态是否为green:
# curl http://192.168.2.11:11223/_cluster/health?pretty

{
   
  "cluster_name" : "es_es11223_cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 120,
  "active_shards" : 240,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}


3.2. 启动节点

启动实例
# su - es -c 'cd /data/PaaS/es/11223/bin && ./elasticsearch -d'

# ps -ef|grep -v grep|grep 11223

3.3. 检查节点日志

检查节点日志,查看是否有报错:
# tail -1000f /data/PaaS/es/11223/log/es_es11223_cluster.log

3.4. 检查集群状态

确认新增节点未分配分片:
#  curl -XGET '192.168.2.11:11223/_cat/shards?v' |grep 192.168.2.14
null

检查新增节点已添加进集群:
#  curl http://192.168.2.11:11223/_cat/nodes?v

ip             heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.2.14            4         100   1    1.19    0.67     0.40 mdi       -      192.168.2.14-11223
192.168.2.12              29          99   0    0.99    1.07     1.05 mdi       *      192.168.2.12-11223
192.168.2.13             51          98   0    1.36    1.19     1.08 mdi       -      192.168.2.13-11223
192.168.2.11              61          97   2    0.79    0.58     0.72 mdi       -      192.168.2.11-11223


检查集群状态是否恢复为green:
# curl http://192.168.2.11:11223/_cluster/health?pretty

{
   
  "cluster_name" : "es_es11223_cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 4,
  "number_of_data_nodes" : 4,
  "active_primary_shards" : 120,
  "active_shards" : 240,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}


4. 启动192.168.2.15:11223节点

4.1. 检查集群状态

检查集群状态是否为green:
# curl http://192.168.2.11:11223/_cluster/health?pretty

{
   
  "cluster_name" : "es_es11223_cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 4,
  "number_of_data_nodes" : 4,
  "active_primary_shards" : 120,
  "active_shards" : 240,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}


4.2. 启动节点

启动实例
# su - es -c 'cd /data/PaaS/es/11223/bin && ./elasticsearch -d'

# ps -ef|grep -v grep|grep 11223
es       225493      1 96 23:03 ?        00:00:32 /usr/local/jdk/bin/java -Xms30g -Xmx30g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -XX:+HeapDumpOnOutOfMemoryError -Des.allow_insecure_settings=true -Des.path.home=/data/PaaS/es/11223 -Des.path.conf=/data/PaaS/es/11223/config -cp /data/PaaS/es/11223/lib/* org.elasticsearch.bootstrap.Elasticsearch -d

4.3. 检查节点日志

检查节点日志,查看是否有报错:
# tail -1000f /data/PaaS/es/11223/log/es_es11223_cluster.log
...
[2021-05-20T23:04:16,343][INFO ][o.e.m.j.JvmGcMonitorService] [192.168.2.15-11223] [gc][3] overhead, spent [270ms] collecting in the last [1s]
[2021-05-20T23:04:17,468][INFO ][o.e.c.s.ClusterApplierService] [192.168.2.15-11223
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zhi@Li

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值