elasticsearch 常用命令
#查看集群状态
curl -XGET "http://localhost:9200/_cluster/health?pretty"
#查看所有的快照
curl -XGET "http://localhost:9200/_snapshot/仓库名/_all"
#查看快照信息
curl -XGET "http://localhost:9200/_snapshot/仓库名/snapshot_name/_status"
#删除快照
curl -XDELETE "localhost:9200/_snapshot/仓库名/snapshot_name"
#生成快照
curl -XPUT -uelastic:xxxx "http://127.0.0.1:9200/_snapshot/仓库名/snapshot_name?wait_for_completion=true" -d '
{
"indices": "index_name",
"ignore_unavailable": "true", #在创建快照的过程中会忽略不存在的索引
"include_global_state": false #防止集群的全局状态被作为快照的一部分存储起来
}'
#恢复快照
curl -XPOST "http://127.0.0.1:9200/_snapshot/仓库名/snapshot_name/_restore?wait_for_completion=true" -d '
{
"ignore_unavailable": "true",
"include_global_state": false ,
"index_settings": { "index.number_of_replicas": 0 } #配置 replica为0,可选条件
}'
#查看快照恢复状态
curl "http://localhost:9200/_cluster/state" | jq '.restore'
#关闭索引
curl -XPOST "http://localhost:9200/index_name/_close"
#开启索引
curl -XPOST "http://localhost:9200/index_name/_open"
#删除索引
curl -XDELETE "http://127.0.0.1:9200/index_name"
#查看索引数据
curl -XGET "http://localhost:9200/index_name/_search"
#合并段
curl -XPOST "http://localhost:9200/index_name/_forcemerge?max_num_segments=1"
#配置replica个数
curl -XPUT "http://localhost:9200/index_name/_settings" -d '{
"index" : {
"number_of_replicas" : 0 }
}'
#创建仓库
curl -XPUT "http://127.0.0.1:9200/_snapshot/仓库名" -d '
{
"type": "fs",
"settings": {
"location": "/S3/elasticsearch/仓库目录路径" }
}'
#查询仓库信息
curl -XGET "http://127.0.0.1:9200/_snapshot/仓库名"
赠人玫瑰,手有余香,如果我的文章有幸能够帮到你,麻烦帮忙点下右下角的推荐,谢谢!
作者: imcati
出处: https://www.cnblogs.com/imcati/>
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接