1.暂停集群的shard自动均衡
curl -XPUT http://127.0.0.1:8200/_cluster/settings -d’{“transient”:{“cluster.routing.allocation.enable”:“none”}}’
2.重启启动集群的shard均衡
curl -XPUT http://127.0.0.1:8200/_cluster/settings -d’{“transient”:{“cluster.routing.allocation.enable”:“all”}}’
3.将节点从集群路由策略中排除:(此节点的数据慢慢移动到别的节点去,此节点数据会被移空)
curl -XPUT ‘http://127.0.0.1:8200/_cluster/settings’ -H ‘Conetent-Type:application/json’ -d ‘{“transient”:{“cluster.routing.allocation.exclude._name”:“data1”}}’
4.此时节点已经完全从集群中删除了,可恢复集群路由策略
curl -XPUT ‘http://127.0.0.1:8200/_cluster/settings’ -H ‘Conetent-Type:application/json’ -d ‘{“transient”:{“cluster.routing.allocation.exclude._name”:“null”}}’
5.查看集群信息
1)集群健康
http://127.0.0.1:8200/_cat/health?v
2)集群节点
http://127.0.0.1:8200/_cat/nodes?v
3)分片总数,磁盘百分比等
http://127.0.0.1:8200/_cat/allocation?v
4)查看配置设置
http://127.0.0.1:8200/_cluster/settings
5)查看某一索引的分片分布信息
http://127.0.0.1:8200/_cat/shards/cs分片名
6.更改mapping
1) 新建索引 (mapping为新的)
```powershell
PUT方式 http://127.0.0.1:8200/1008_new
{
"mappings": {}
}
```
2) 复制原索引数据到新索引上
```powershell
POST方式 http://127.0.0.1:8200/_reindex
{
"source": {
"index": "1008"
},
"dest": {
"index": "1008_new"
}
}
```
3) 删除原索引
```powershell
DELETE方式 http://127.0.0.1:8200/1008
```
4)设置 1008_new索引别名(为原索引的名1008)
```powershell
POST方式 http://127.0.0.1:8200/_aliases
{
"actions": [
{"add": {"index": "1008_new", "alias": "1008"}}
]
}
```