温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

elasticsearch restful日常维护操作

发布时间:2020-07-21 10:47:44 来源:网络 阅读:971 作者:typuc 栏目:建站服务器

一,索引操作
curl -XPUT http://127.0.0.1:9200/xrf_test_index001  -d '{"setting":{"index":{"number_of_shards":5,"number_of_replication":1}}}'    #创建手动指定分片副本    
curl -XPOST http://127.0.0.1:9200/xrf_test_index001/_close        #关闭索引    
curl -XPOST http://127.0.0.1:9200/xrf_test_index001/_open        #开启索引    
curl -XDELETE http://127.0.0.1:9200/xrf_test_index001            #删除索引
curl -XPUT http://127.0.0.1:9200/xrf_test_index001/_settings -d '{"index":{"number_of_replicas":1}}'    #调整副本数量
curl -XPOST http://127.0.0.1:9200/_aliases -d '{"actions":[{"add":{"index":"xrf_test_index001","alias":"xrf_test"}}]}'    #增加索引别名
curl -XPOST http://127.0.0.1:9200/_aliases -d '{"actions":[{"remove":{"index":"xrf_test_index001","alias":"xrf_test"}}]}' #删除别名
二,分片操作
curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable":"none"}}'    #关闭自动分片  persistent 表示永久
curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable":"all"}}'    #开起自动分片
curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.cluster_concurrent_rebalance":5}}' #设置分片均衡线程数
curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.exclude._ip":"1.1.1.1"}}' #排除机器或者节点,改节点上的分片将调整到其他节点,支持_name,_hostname,_ip
三,节点操作
curl -XPOST http://127.0.0.1:9200/_cluster/nodes/_local/_shutdown?delay=10s        #延迟10s关闭本机节点,2.x以后无效kill $pid
curl -XPOST http://127.0.0.1:9200/_cluster/nodes/nodeId1,nodeId2/_shutdown        #关闭节点nodeId1,nodeId2
curl -XPOST http://127.0.0.1:9200/_cluster/nodes/_master/_shutdown     #关闭主节点
四,状态查看
curl -XGET http://127.0.0.1:9200/_cluster/nodes     #获得集群中的节点列表和信息
curl -XGET http://127.0.0.1:9200/_cluster/health #获得集群信息
curl -XGET http://127.0.0.1:9200/_cluster/state    #获得集群里的所有信息(集群信息、节点信息、mapping信息等)
curl -XGET http://127.0.0.1:9200/_cat/nodes        #查看集群节点列表
curl -XGET http://127.0.0.1:9200/_cat/indices    #查看集群索引列表
curl -XGET http://127.0.0.1:9200/_cat/shards    #查看集群分片列表

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI