elasticsearch运维常用api

延迟 5 分钟后调整分片

curl -XPUT http://192.168.0.0:9200/_all/_settings -d '{"settings": {"index.unassigned.node_left.delayed_timeout": "5m"}}'

禁止分片分配

curl -XPUT http://192.168.0.0:9200/_cluster/settings -d '{"transient" : {"cluster.routing.allocation.enable" : "none"}}'

开启分片分配

curl -XPUT http://192.168.0.0:9200/_cluster/settings -d '{"transient" : {"cluster.routing.allocation.enable" : "all"}}'

设置分片副本为 0 个

curl -XPUT http://192.168.0.0:9200/bills_v1/_settings -d '{"number_of_replicas": 0}'

为es5.x 版本的 xpack 插件添加 license (6.x以上版本的es,x-pack插件自带,不需要做此操作)

curl -XPUT 'http://192.168.0.0:9200/_xpack/license' -H "Content-Type: application/json" -d @xpack_license.json

或者

curl -XPUT -u elastic:changeme 'http://192.168.50.118:9200/_xpack/license?acknowledge=true' -H 'Content-Type: application/json' -d @license.json

创建索引,并设置分片和副本

curl -XPUT http://192.168.0.0:9200/bills_v1 -d '{"settings":{"number_of_shards":15,"number_of_replicas":1}}'

修改单个节点磁盘使用量限制

cluster.routing.allocation.disk.watermark.low:  控制磁盘最小使用率。默认85%.说明es在磁盘使用率达到85%的时候将会停止分配新的shard。也可以设置为一个绝对数值,比如500M.
cluster.routing.allocation.disk.watermark.high:控制磁盘的最大使用率。默认90%.说明在磁盘使用率达到90%的时候es将会relocate shard去其他的节点。同样也可以设置为一个绝对值。
默认es每隔30s会收集各个节点磁盘的使用情况,可以cluster.info.update.interval来设置时间间隔。

curl -XPUT http://192.168.0.0:9200/_cluster/settings -d '{"transient" : {""cluster.routing.allocation.disk.watermark.low": "90%","cluster.routing.allocation.disk.watermark.high": "95%","cluster.info.update.interval": "1m"}}'

导出mapping

curl http://192.168.4.99:9200/sys_v1/_mapping

导入mapping(用格式化工具格式成 josn 格式,将mapping前的字典删除) 

curl -XPUT http://192.168.0.0:9200/bills_v1/billinfo/_mapping -d@bill_mapping.json

为索引创建别名

curl -XPUT 'http://192.168.0.0:9200/bills_v1/_alias/bills'

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值