Elasticsearch 常用命令
- _reindex
1 | curl --location --request POST 'http://10.138.25.214:9200/_reindex' \ |
- 创建index
1 | curl --location --request PUT 'http://10.138.25.214:9200/deploy-log' |
- 创建mapping
1 | curl --location --request POST 'http://10.138.25.214:9200/deploy-log/deploy_log' \ |
- 删除index
1 | curl --location --request DELETE 'http://10.133.0.87:9200/.kibana_1' |
- _termvectors
1 | curl --location --request GET 'http://10.138.25.214:9200/deploy-log/deploy_log/AWfK6rkZ_ashmo4ko1yd/_termvectors?fields=containerName' |
- index插入内容
1 | curl --location --request POST 'http://10.163.204.193:9200/logstash-2020.10.27/deploy_log' \ |
- mapping删除
1 | curl --location --request DELETE 'http://10.138.25.214:9200/deploy-log/deploy_log/_mapping' |
- _template删除
1 | curl --location --request DELETE 'http://10.138.25.214:9200/_template/d*' |
- 查询_template
1 | curl --location --request GET 'http://10.138.25.214:9201/_template?pretty' |
- indices
1 | curl --location --request GET 'http://10.138.16.190:9200/_cat/indices?v' |
- allocate_replica(reroute)
1 | curl --location --request POST 'http://10.163.204.80:9200/_cluster/reroute?retry_failed=true' \ |
- cluster.routing.allocation.enable
1 | curl --location --request PUT 'http://10.138.16.188:9200/_cluster/settings' \ |
- template更新(新增)
6.x
1 | curl --location --request PUT 'http://10.163.204.193:9200/_template/k8s-log-template2222' \ |
7.x
1 | curl --location --request PUT 'http://10.163.204.193:9200/_template/k8s-log-template2222' \ |
- 查询_mapping
1 | curl --location --request GET 'http://10.133.0.87:9200/logstash-2019.12.04/_mapping' |
- 修改indices.breaker.fielddata.limit
1 | curl --location --request PUT 'http://10.133.0.89:9200/_cluster/settings' \ |
- 清理cache
1 | curl --location --request POST 'http://10.133.0.89:9200/logstash-*/_cache/clear?fields=*' |
- 查询_cluster/settings
1 | curl --location --request GET 'http://10.133.0.89:9200/_cluster/settings' |
- 修改indices.breaker.total.limit
1 | curl --location --request PUT 'http://10.133.0.89:9200/_cluster/settings' \ |
- 修改max_shards_per_node
1 | curl --location --request PUT 'http://10.163.204.80:9200/_cluster/settings' \ |
- remote cluster info
1 | curl --location --request GET 'http://10.133.0.86:9201/_remote/info' \ |
- 修改索引number_of_replicas
1 | curl --location --request PUT 'http://10.163.204.80:9200/security-tracelogdev-20200223/_settings' \ |
- allocation.exclude._ip节点下线
1 | curl --location --request PUT 'http://10.163.204.80:9200/_cluster/settings' \ |
- shard移动到某个节点(reroute)
1 | curl --location --request POST 'http://10.163.204.80:9200/_cluster/reroute?retry_failed=true' \ |
- 调整refresh_interval
1 | curl --location --request PUT 'http://10.163.204.193:9200/logstash-2020.09.24/_settings' \ |
- 修改disk.watermark.high
1 | curl --location --request PUT 'http://10.163.204.193:9200/_cluster/settings' \ |
- 修改recovery相关配置
1 | curl --location --request PUT 'http://10.163.204.193:9201/_cluster/settings' \ |
- 查看某个节点的thread_pool状态
1 | curl --location --request GET 'http://10.163.204.193:9200/_nodes/10.163.204.193-node1/stats/thread_pool?human&pretty' |
- es集群thread_pool write状态
1 | curl --location --request GET 'http://10.163.204.193:9200/_cat/thread_pool/write?v&h=node_name,ip,name,type,active,size,queue,queue_size,largest,rejected,completed&pretty' |
- 查看集群indices缓存信息
1 | curl --location --request GET 'http://10.162.166.136:9201/_cluster/settings?include_defaults&flat_settings&local&filter_path=defaults.indices*' |
- 索引关闭
1 | curl --location --request POST 'http://10.162.166.45:9201/hmcenter-*/_close' |
- 索引打开
1 | curl --location --request POST 'http://10.162.166.45:9201/console*/_open' |
- es写入速度调优
1 | curl --location --request PUT 'http://10.163.204.193:9200/logstash-2021.01.11/_settings' \ |
- 查询_ingest/pipeline
1 | curl --location --request GET 'http://10.163.204.193:9200/_ingest/pipeline' |
- 集群read_only_allow_delete
1 | curl --location --request PUT 'http://10.133.0.84:9200/_settings' \ |
- 查看索引_settings
1 | curl --location --request GET 'http://10.163.204.193:9200/.monitoring-es-6-2021.01.27/_settings?pretty' |
- 索引read_only_allow_delete
1 | curl --location --request PUT 'http://10.163.204.193:9200/.monitoring-es-6-2021.01.28/_settings' \ |
- 查询_cluster/stats
1 | curl --location --request GET 'http://10.163.204.193:9200/_cluster/stats' |
- 查看集群_nodes/hot_threads
1 | curl --location --request GET 'http://10.163.204.193:9200/_nodes/hot_threads' |
- 查询某个节点的hot_threads
1 | curl --location --request GET 'http://10.163.204.193:9200/_nodes/10.163.204.193/hot_threads' |
- 某个节点的stats/thread_pool
1 | curl --location --request GET 'http://10.163.204.193:9200/_nodes/10.163.204.193/stats/thread_pool?human&pretty' |
- 查看某个模板
1 | curl --location --request GET 'http://10.163.204.193:9200/_template/.monitoring-es?pretty' |
索引备份
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-reindex.html1
2
3
4
5
6
7
8
9
10curl -XPOST 'localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
"source": {
"index": "twitter"
},
"dest": {
"index": "new_twitter"
}
}
'es重启
先kill 杀死es1
sh bin/elasticsearch -d
elasticsearch 查看集群所有设置(包含默认的)
1
http://10.138.1.1:9200/_cluster/settings?include_defaults=true
elasticsearch设置密码
1
./bin/elasticsearch-setup-passwords interactive
查看es集群恢复情况
1
http://10.138.1.1:9200/_cluster/allocation/explain?pretty