zoukankan      html  css  js  c++  java
  • ES基本操作命令

    • transient 临时:这些设置在集群重启之前一直会生效。一旦整个集群重启,这些设置就被清除。
    • persistent 永久:这些设置永久保存,除非再次被手动修改。是将修改持久化到文件中,重启之后也不影响。

    1、查看集群配置

    GET _cluster/settings

    2、禁用与启用自平衡

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.rebalance.enable": "none"
    }
    }

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.rebalance.enable": "all"
    }
    }

    3、禁用与启用自分片

    all - (默认值)允许为所有类型的分片分配分片。

    primaries - 仅允许分配主分片的分片。

    new_primaries -仅允许为新索引的主分片分配分片。

    none - 任何索引都不允许任何类型的分配分片。

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.allocation.enable": "none"
    }
    }

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.allocation.enable": "all"
    }
    }

    4、配置分片迁移并发数

    ①节点级别

    PUT _cluster/settings
    {
    "persistent": {
    "cluster.routing.allocation.node_concurrent_recoveries": 2
    }
    }

    ②集群级别

    PUT _cluster/settings

    {

      "persistent": {

      "cluster.routing.allocation.cluster_concurrent_rebalance": 8}

    }

    5、退役节点

    _ip:通过IP

    _name:通过节点名

    _host:通过主机名

    ①指定退役节点IP

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.allocation.exclude._ip" : "1.1.1.1,2.2.2.2"
    }
    }

    ②指定保留节点IP,至少符合一项

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.allocation.include._ip" : "1.1.1.1,2.2.2.2"
    }
    }

    ③指定保留节点IP,指定项全部符合

    PUT _cluster/settings
    {
    "persistent" : {
    "cluster.routing.allocation.require._ip" : "1.1.1.1,2.2.2.2"
    }
    }

    6、清空配置为默认值

    PUT _cluster/settings

    {

      "persistent": {

      "indices.recovery.max_bytes_per_sec": null}

    }

    7、开启慢查询

    PUT /_settings
    {
    "index.search.slowlog.level": "debug",
    "index.search.slowlog.threshold.query.warn": "5s",
    "index.search.slowlog.threshold.query.info": "3s",
    "index.search.slowlog.threshold.query.debug": "1s",
    "index.search.slowlog.threshold.query.trace": "500ms",
    "index.search.slowlog.threshold.fetch.warn": "1s",
    "index.search.slowlog.threshold.fetch.info": "800ms",
    "index.search.slowlog.threshold.fetch.debug": "500ms",
    "index.search.slowlog.threshold.fetch.trace": "200ms"
    }

    8、强制重新分配集群中的UNASSIGEMED Shards

    POST _cluster/reroute?retry_failed=true

     

    9、设置index恢复时每秒最大字节数限制,默认40mb

    PUT _cluster/settings

    {

      "persistent": {

      "indices.recovery.max_bytes_per_sec": "100mb"}

    }

    10、同步刷新

    POST _flush/synced

    11、设置ES集群允许使用_all或*通配符的方式删除索引,默认不允许,会报“Wildcard expressions or all indices are not allowed”错误。

    PUT /_cluster/settings

    {

        "persistent" : {

            "action.destructive_requires_name" : false

        }

    }

    12、 磁盘的三个默认警戒水位线

    cluster.routing.allocation.disk.watermark.low 低警戒水位线——默认为磁盘容量的85%。

    Elasticsearch不会将分片分配给使用磁盘超过85%的节点。它也可以设置为绝对字节值(如500mb),以防止Elasticsearch在小于指定的可用空间量时分配分片。此设置不会影响新创建的索引的主分片,或者特别是之前任何从未分配过的分片。

    cluster.routing.allocation.disk.watermark.high 高警戒水位线——默认为磁盘容量的90%。

    Elasticsearch将尝试从磁盘使用率超过90%的节点重新分配分片。它也可以设置为绝对字节值,以便在节点小于指定的可用空间量时将其从节点重新分配。此设置会影响所有分片的分配,无论先前是否分配。

    cluster.routing.allocation.disk.watermark.flood_stage 洪水警戒水位线——默认为磁盘容量的95%。

    Elasticsearch对每个索引强制执行只读索引块(index.blocks.read_only_allow_delete)。这是防止节点耗尽磁盘空间的最后手段。一旦有足够的可用磁盘空间允许索引操作继续,就必须手动释放索引块。

    cluster.info.update.interval Elasticsearch应该多久检查一次群集中每个节点的磁盘使用情况。 默认为30秒。

    磁盘的分片分配综合样例配置如下:

    PUT _cluster/settings
    {
     "transient": {
    "cluster.routing.allocation.disk.watermark.low": "100gb",
     "cluster.routing.allocation.disk.watermark.high": "50gb",
     "cluster.routing.allocation.disk.watermark.flood_stage": "10gb",
     "cluster.info.update.interval": "1m"
     }
    }

    13、ES迁移数据

    ①先扩容,集群退役节点

    ②logstash等工具迁移

    ③reindex

    从远程ES进行reindex
    需要在配置文件中设置白名单:
    reindex.remote.whitelist: ["192.168.1.2:9200"]

  • 相关阅读:
    hdu 2196(树上点分治)
    hdu 4807(网络流 + 贪心)
    hdu4101
    hdu4216
    hdu 4219, 树形概率DP
    hdu 4127 A*搜索
    hdu 4126
    hdu 5296,15年多校1-7
    poj3436 ACM Computer Factory
    Fence
  • 原文地址:https://www.cnblogs.com/tudachui/p/14275526.html
Copyright © 2011-2022 走看看