【es】设置副本分片

1.设置副本分片

1.搜索引擎的模块 
数据采集模块,文本分析模块,索引存储模块,搜索模块。
索引存储模块使用倒排索引存储模块把写入的数据组织成倒排索引的结构,
还管理着数据的存储方式,路由方式,事务日志,索引状态。

2.主节点 
每个集群有且只有一个主节点,主节点是整个集群的管理者,它负责维护整个集群的元数据,并在节点数目
发生变化时及时更新集群的状态然后将状态发布给集群的其他节点。
主节点还负责索引分片的分配。

3.主节点的选举 
如果超过30s主节点的状态没有发布成功,则主节点失败,主候选节点需要选举新的主节点。
如果某个节点的最终确认响应超过90s没有发送到主节点,则主节点认为该节点掉线,
将其从集群列表中删除。

4.分片分配 
节点数变化或副本数变化,就会发送分片的重分配。

创建索引并设置分片
curl -X PUT localhost:9200/iot_004 -u elastic:elastic  -H "Content-Type: application/json" -d '
{
"settings":{
"number_of_shards":"3",
"number_of_replicas":"1"
}
}'
{"acknowledged":true,"shards_acknowledged":true,"index":"iot_004"}


查看索引的分片 
curl -X GET localhost:9200/_cat/shards/iot_004?v -u elastic:elastic  
[root@host-172-21-251-180 config]# curl -X GET localhost:9200/_cat/shards/iot_004?v -u elastic:elastic  
index   shard prirep state   docs store ip             node
iot_004 2     p      STARTED    0  226b localhost node-1
iot_004 2     r      STARTED    0  226b 192.168.1.188 node-2
iot_004 1     r      STARTED    0  226b localhost node-1
iot_004 1     p      STARTED    0  226b 192.168.1.188 node-2
iot_004 0     p      STARTED    0  226b localhost node-1
iot_004 0     r      STARTED    0  226b 192.168.1.188 node-2

--查看索引的分布 

检查 R0 的分配是否可以分配到当前节点。
curl -X GET localhost:9200/_cluster/allocation/explain -u elastic:elastic  -H "Content-Type: application/json" -d '
{
"index":"iot_004",
"shard":0,
"primary":false
}'

{
    "index":"iot_004",
    "shard":0,
    "primary":false,
    "current_state":"started",
    "current_node":{
        "id":"xT-aakS2RficXV5PI2fU9Q",
        "name":"node-2",
        "transport_address":"192.168.1.188:9300",
        "attributes":{
            "ml.machine_memory":"4129558528",
            "ml.max_open_jobs":"512",
            "xpack.installed":"true",
            "ml.max_jvm_size":"2067791872",
            "transform.node":"true"
        },
        "weight_ranking":1
    },
    "can_remain_on_current_node":"yes",
    "can_rebalance_cluster":"yes",
    "can_rebalance_to_other_node":"no",
    "rebalance_explanation":"cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance",
    "node_allocation_decisions":[
        {
            "node_id":"ziwZn3mQQ4-LH-6vLuYMUw",
            "node_name":"node-1",
            "transport_address":"localhost:9300",
            "node_attributes":{
                "xpack.installed":"true",
                "transform.node":"true"
            },
            "node_decision":"no",
            "weight_ranking":1,
            "deciders":[
                {
                    "decider":"same_shard",
                    "decision":"NO",
                    "explanation":"a copy of this shard is already allocated to this node [[iot_004][0], node[ziwZn3mQQ4-LH-6vLuYMUw], [P], s[STARTED], a[id=b18r-ftATWSPX8-7bBUGOw]]"
                }
            ]
        }
    ]
}

对于一个总分片数为N的索引而言,当集群节点的数据达到N以后,继续添加新节点无法
提升该索引的读写性能。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值