前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >安全的移除Es数据节点步骤

安全的移除Es数据节点步骤

原创
作者头像
HLee
修改2021-08-13 10:48:53
5.3K0
修改2021-08-13 10:48:53
举报
文章被收录于专栏:房东的猫房东的猫

说明:想要安全的移除一个es节点,不改变分片的数量,100%不会引起数据丢失,即保证这个节点的所有数据被其他节点接收。然后停止这个节点的实例。

两个节点禁用策略:

代码语言:javascript
复制
curl -XPUT http://0.0.0.0:9200/_cluster/settings?pretty -d '{"transient":{"cluster.routing.allocation.exclude._ip":"10.10.10.11,10.10.10.12"}}'

Data-node节点下线过程:

  • 步骤1:将节点从集群路由策略中排除
代码语言:javascript
复制
curl -XPUT http://0.0.0.0:9200/_cluster/settings?pretty -d '{"transient":{"cluster.routing.allocation.exclude._ip":"10.10.10.11"}}'

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.exclude._ip": "10.1.22.129"
  }
}

执行结果:
{
  "acknowledged" : true,
  "persistent" : { },
  "transient" : {
    "cluster" : {
      "routing" : {
        "allocation" : {
          "exclude" : {
            "_ip" : "10.1.22.129"
          }
        }
      }
    }
  }
}
  • 步骤2:等待节点上分片全部被迁移
代码语言:javascript
复制
curl http://0.0.0.0:9200/_cluster/health?pretty
curl http://0.0.0.0:9200/_cluster/pending_tasks?pretty
curl http://0.0.0.0:9200/_cluster/allocation/explain?pretty

1.检查集群状态
http://10.1.34.146:9200/_cluster/health?pretty
{
   cluster_name: "my-es6-test",
   status: "green",
   timed_out: false,
   number_of_nodes: 4,
   number_of_data_nodes: 4,
   active_primary_shards: 150,
   active_shards: 272,
   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
}

2.若出现pening_tasks,当pending_tasks的等级>=HIGH时,存在集群无法新建索引的风险
http://10.1.34.146:9200/_cluster/pending_tasks?pretty
{
  "tasks": []
}

3.若集群中出现UNASSIGNED shards,检查原因,查看是否是分配策略导致无法迁移分片
http://10.1.22.129:9200/_cluster/allocation/explain?pretty

4.查看节点数据是否已迁移,都是 0 表示数据也已经迁移
http://10.1.34.146:9200/_nodes/%7Bnode-6%7D/stats/indices?pretty
{
   _nodes: {
       total: 0,
       successful: 0,
       failed: 0
   },
   cluster_name: "my-es6-test",
   nodes: { }
}
  • 步骤3:下线节点
代码语言:javascript
复制
[localhost~]$ ps aux | grep Elasticsearch
[localhost~]$ ps -ef | grep Elasticsearch

kill -9 {pid}
  • 步骤4:取消节点禁用策略
代码语言:javascript
复制
curl -XPUT http://0.0.0.0:9200/_cluster/settings?pretty -d '{"transient":{"cluster.routing.allocation.exclude._ip": null}}'

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.exclude._ip": null
  }
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com