es集群重启及导数据

ES重启

1.禁用自动分配

curl -XPUT 192.168.14.xxx:9200/_cluster/settings -d'{
  "transient": {
  "cluster.routing.allocation.enable": "none"
       }
   }'

2.干掉以前的进程

循环干掉es进程
for i in {xxx..xxx}; do ssh 192.168.14.$i "ps -ef|grep elasticsearch|grep -v grep|awk '{print $2}'|xargs kill -9"; done

也可以在界面关闭

3.一起启动(不行就单个添加)

/opt/elasticsearch/bin/elasticsearch -d
for i in {148..161}; do ssh 192.168.14.$i "/opt/elasticsearch/bin/elasticsearch -d"; done

4.启用自动分配

可等多个节点上线后启用

curl -XPUT 192.168.14.xxx:9200/_cluster/settings -d'{
     "transient": {
         "cluster.routing.allocation.enable": "all"
     }
 }'

刷新es

加速恢复(节点全部上线后执行,对于节点全部上线但报红有奇效)

curl -XPOST '192.168.14.xxx:9200/_cluster/reroute?retry_failed'

导数据

去存储目录下,导入即可,然后重启集群

cd /opt/elasticsearch/data/nodes/0/indices

要注意的是两点:
1.如果两个集群,从节点少的往多的导,直接导即可
如果是从多的往少的导,则需要把分片缩小到节点较少的集群节点数,可以下几个自动分配,也可以用手动迁移分片的方式
2.要注意别名的问题,尽量避免导入的分片索引之前没有别名,或者导数据之前先把别名去了,再下数据,之后再建别名,因为别名有时候会导致导入分配失败

猜你喜欢

转载自blog.csdn.net/lisong_ghost/article/details/80018101