ES集群检查常用命令( 二 )

3.查看分片未分配详细命令
curl -XGET "http://127.0.0.1:24100/_cluster/allocation/explain?pretty" -H 'Content-Type:application/json' -d '{"index": "indexname","shard": 17,"primary": true}'4.修改索引只读字段属性为null,放开写入
curl -XPUT"http://127.0.0.1:24100/*/_settings" -H 'Content-Type: application/json' -d '{"index.blocks.read_only_allow_delete": null}'四、索引设置常用命令1.关闭索引
curl -XPOST 'http://ip:port/my_index/_close?pretty'2.打开索引
curl -XPOST 'http://ip:port/my_index/_open?pretty'3.修改索引刷新时间:
curl -XPUT 'http://ip:port/my_index/_settings?pretty' -H 'Content-Type: application/json' -d'{"refresh_interval" : "60s"}'4.修改translog文件保留时长,默认为12小时
curl -XPUT 'http://ip:port/my_index/_settings?pretty' -H 'Content-Type: application/json' -d'{"index.translog.retention.age" : "30m"}'5.设置索引副本:
curl -XPUT 'http://ip:port/my_index/_settings?pretty' -H 'Content-Type: application/json' -d'{"number_of_replicas" : 1}'6.执行refresh,将内存数据刷新到磁盘缓存
curl -XPOST 'http://ip:port/myindex/_refresh'7.执行flush,将磁盘缓存刷新到文件系统
curl -XPOST 'https://ip:port/myindex/_flush'8.执行synced flush,生成syncid
curl -XPOST'http://ip:port/_flush/synced'

  1. 强制执行段合并
curl -XPOST 'http://ip:httpport/myindex/_forcemerge?only_expunge_deletes=false&max_num_segments=1&flush=true&pretty'10.设置索引在每个esnode上的分片个数
curl -XPUT 'http://ip:httpport/myindex/_settings?pretty' -H 'Content-Type: application/json' -d'{"index.routing.allocation.total_shards_per_node" : "2"}'
  1. 配置控制段合并的refresh、merge线程数等
curl -XPUT"http://ip:port/my_index/_settings?pretty" -H 'Content-Type: application/json' -d'{"refresh_interval": "60s","merge":{"scheduler":{"max_merge_count" : "100","max_thread_count" : "1"},"policy":{"segments_per_tier" : "100","floor_segment" : "1m","max_merged_segment" : "2g"}}}'12.设置索引的刷新时间和translog配置参数
注意:设置translog参数,必须先关闭索引,设置完成后再打开

经验总结扩展阅读