• 简单Kibana命令


    1 查看健康状态

    GET _cat/health?v
    epoch timestamp cluster status node.total node.data shards
    1531290005 14:20:05 elasticsearch green 1 1 2
    pri relo init unassign pending_tasks
    2 0 0 0 0
    max_task_wait_time active_shards_percent
    - 100.0%
    status:green、yellow、red
    green:每个索引的primary shard和replica shard都是active的
    yellow:每个索引的primary shard都是active的,但部分的replica shard不是active的
    red:不是所有的索引都是primary shard都是active状态的。


    2 检查分片信息
    查看索引的shard信息。
    GET _cat/shards?v
    health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
    yellow open test_index yu5HjAt0RS-qSFtrCj-emQ 5 1 0 0 1.1kb 1.1kb

    3 设置磁盘限制
    ES默认当磁盘空间不足15%时,会禁止分配replica shard。可以动态调整ES对磁盘空间的要求限制,命令如下:
    PUT _cluster/settings
    {
        "transient": {
            "cluster.routing.allocation.disk.watermark.low": "95%",
            "cluster.routing.allocation.disk.watermark.high": "5gb"
        }
    }
    注意:配置磁盘空间限制的时候,要求low必须比high大。可以使用百分比或gb的方式设置。且ES要求low至少满足磁盘95%的容量。
    此处配置的百分比都是磁盘的使用百分比,如85%,代表磁盘使用了85%后如何限制。配置的GB绝对值都是剩余空间多少。
    low - 对磁盘空闲容量的最低限制。默认85%。
    high - 对磁盘空闲容量的最高限制。默认90%。
    如:low为50gb。high为10gb。则当磁盘空闲容量不足50gb时停止分配replica shard。当磁盘空闲容量不足10gb时,停止分配shard,并将应该在当前结点中分配的shard分配到其他结点中。
    强调:red问题。因为ES中primary shard是主分片,要求必须全部活动才能正常使用。

    4 查看索引信息
    GET _cat/indices?v
    health status index uuid pri rep docs.count
    yellow open test_index 2PJFQBtzTwOUhcy-QjfYmQ 5 1 0
    docs.deleted store.size pri.store.size
    0 460b 460b


    5 新增索引
    PUT /test_index
    在ES中,默认的创建索引的时候,会分配5个primary shard,并为每个primary shard分配一个replica shard。在ES中,默认的限制是:如果磁盘空间不足15%的时候,不分配replica shard。如果磁盘空间不足5%的时候,不再分配任何的primary shard。
    创建索引时指定分片。
    PUT /test_index
    {
        "settings":{
            "number_of_shards" : 2,
            "number_of_replicas" : 1
        }
    }


    6 修改索引
    注意:索引一旦创建,primary shard数量不可变化,可以改变replica shard数量。
    PUT /test_index/_settings
    {
        "number_of_replicas" : 2
    }
    ES中对shard的分布是有要求的。有其内置的特殊算法。ES尽可能保证primary shard平均分布在多个节点上。Replica shard会保证不和他备份的那个primary shard分配在同一个节点上。


    7 删除索引
    DELETE /test_index [, other_index]

    8 总结:索引不可变
    索引不可变的原因是倒排索引不可变。


    倒排索引不可变的好处
    不需要锁,提升并发能力,避免锁问题。数据不变,可以缓存在OS cache中(前提是cache足够大)。filter cache始终在内存中,因为数据是不可变的。可以通过压缩技术来节省CPU和IO的开销。


    倒排索引不可变的坏处
    倒排索引不可变,导致了ES中的index不可变。只要index的结构发生任何变化,都必须重建索引。

  • 相关阅读:
    读《人人都是产品经理》
    前端值得看的博客
    git 常用命令 创建查看删除分支,创建查看删除tag等
    看《如何令选择变得更加容易》
    读【失控】——众愚成智
    html5 postMessage
    下拉滚动加载更多数据
    html select用法总结
    分布式系统事务一致性解决方案
    nginx简易教程
  • 原文地址:https://www.cnblogs.com/yucongblog/p/11901465.html
Copyright © 2020-2023  润新知