Elastic Search snapshot curl

 2022-08-21    0 条评论    12380 浏览

es

查看集群状态

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 ,
	 #配置 replica为0,可选条件
	"index_settings": { "index.number_of_replicas": 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/仓库名"

操作会在ES集权node节点日志显示 比如删除快照与删除仓库