查看集群状态
curl http://10.0.1.123:9200/_cat/health?v
查看节点状态
curl http://10.0.1.123:9200/_cat/nodes?v
查看索引状态
curl http://10.0.1.123:9200/_cat/indices?v
查看分片状态
curl http://10.0.1.123:9200/_cat/shards?v
删除指定的索引
curl -X DELETE http://10.0.1.123:9200/索引名字
批量删除指定节点索引
for i in `curl -XGET 'http://10.0.1.123:9200/_cat/shards'|grep 10.0.1.123 |grep 221006| awk '{print $1}'` ; do curl -XDELETE "http://10.0.1.123:9200/$i"; done
查看索引当前模板设置
http://10.0.1.123:9200/*/_settings?pretty
关闭索引写保护
curl -XPUT -H "Content-Type: application/json" http://10.0.1.123:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
验证
curl -XPUT -H "Content-Type: application/json" http://10.0.1.123:9200/索引名称/_settings -d '{"index": {"blocks": { "read_only_allow_delete": "false"}}}'
返回
{"acknowledged":true}
热数据分片标记为冷数据分片
curl -XPUT -H "Content-Type: application/json" http://10.12.73.2:9200/*-221101-*/_settings -d '{"index.routing.allocation.require.box_type": "cold"}'
批量删除索引
curl http://10.12.73.2:9200/_cat/indices |grep 221005 |awk '{print $3}' | xargs -n 1 -I {} curl -XDELETE http://10.12.73.2:9200/{}
配置文件
热数据节点
node.attr.box_type: hot
node.name: hot01
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
node.master: true
node.data: true
cluster.name: test_datacenter
discovery.zen.ping.unicast.hosts: ["10.12.73.3:9300","10.12.73.2:9300","10.12.73.2:8300","10.12.73.3:8300","10.12.73.6:9300","10.12.73.6:8300","10.12.158.118:9300","10.12.158.119:9300","10.12.158.120:9300"]
discovery.zen.ping_timeout: 60s
indices.fielddata.cache.size: 30%
bootstrap.memory_lock: true
thread_pool:
write:
size: 16
queue_size: 2000
processors: 16
冷数据节点
node.attr.box_type: cold
node.name: cold01
path.data: /data/elasticsearch/data,/data01/elasticsearch/data,/data02/elasticsearch/data,/data03/elasticsearch/data,/data04/elasticsearch/data,/data05/elasticsearch/data,/data06/elasticsearch/data,/data07/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
node.master: true
node.data: true
cluster.name: test_datacenter
discovery.zen.ping.unicast.hosts: ["10.12.73.3:9300","10.12.73.2:9300","10.12.73.2:8300","10.12.73.3:8300","10.12.73.6:8300","10.12.73.6:9300","10.12.158.118:9300","10.12.158.119:9300","10.12.158.120:9300","10.12.73.5:9300","10.12.73.5:8300"]
discovery.zen.ping_timeout: 60s
indices.fielddata.cache.size: 30%
bootstrap.memory_lock: true
thread_pool:
write:
size: 16
queue_size: 1000
processors: 16