首页 > 其他分享 >ES跨版本升级?——难道升级集群发生shard allocation是因为要分配replica节点???

ES跨版本升级?——难道升级集群发生shard allocation是因为要分配replica节点???

时间:2023-05-31 12:06:09浏览次数:38  
标签:node shards shard cat allocation cluster 版本升级 nodes

Full cluster restart upgrade

Elasticsearch requires a full cluster restart when upgrading across major versions. Rolling upgrades are not supported across major versions. Consult this table to verify that a full cluster restart is required.

The process to perform an upgrade with a full cluster restart is as follows:

  1. Disable shard allocation——防止分片大量复制数据
    When you shut down a node, the allocation process will immediately try to replicate the shards that were on that node to other nodes in the cluster, causing a lot of wasted I/O. This can be avoided by disabling allocation before shutting down a node:
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "none"
  }
}

COPY AS CURLVIEW IN CONSOLE 

  1. Perform a synced flush
    Shard recovery will be much faster if you stop indexing and issue a synced-flush request:
POST _flush/synced

COPY AS CURLVIEW IN CONSOLE 

A synced flush request is a “best effort” operation. It will fail if there are any pending indexing operations, but it is safe to reissue the request multiple times if necessary.

  1. Shutdown and upgrade all nodes
    Stop all Elasticsearch services on all nodes in the cluster. Each node can be upgraded following the same procedure described in [upgrade-node].
  2. Upgrade any plugins
    Elasticsearch plugins must be upgraded when upgrading a node. Use the elasticsearch-plugin script to install the correct version of any plugins that you need.
  3. Start the cluster——先启动主节点,然后再是数据节点
    If you have dedicated master nodes — nodes with node.master set to true(the default) and node.data set to false —  then it is a good idea to start them first. Wait for them to form a cluster and to elect a master before proceeding with the data nodes. You can check progress by looking at the logs.
    As soon as the minimum number of master-eligible nodes have discovered each other, they will form a cluster and elect a master. From that point on, the _cat/health and _cat/nodesAPIs can be used to monitor nodes joining the cluster:
GET _cat/health

GET _cat/nodes

COPY AS CURLVIEW IN CONSOLE 

Use these APIs to check that all nodes have successfully joined the cluster.

  1. Wait for yellow
    As soon as each node has joined the cluster, it will start to recover any primary shards that are stored locally. Initially, the _cat/health request will report a status of red, meaning that not all primary shards have been allocated.
    Once each node has recovered its local shards, the status will become yellow, meaning all primary shards have been recovered, but not all replica shards are allocated. This is to be expected because allocation is still disabled.
  2. Reenable allocation
    Delaying the allocation of replicas until all nodes have joined the cluster allows the master to allocate replicas to nodes which already have local shard copies. At this point, with all the nodes in the cluster, it is safe to reenable shard allocation:
PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.enable": "all"
  }
}

COPY AS CURLVIEW IN CONSOLE 

The cluster will now start allocating replica shards to all data nodes(难道升级集群发生shard allocation是因为要分配replica节点???). At this point it is safe to resume indexing and searching, but your cluster will recover more quickly if you can delay indexing and searching until all shards have recovered.

You can monitor progress with the _cat/health and _cat/recovery APIs:

GET _cat/health

GET _cat/recovery

COPY AS CURLVIEW IN CONSOLE 

Once the status column in the _cat/health output has reached green, all primary and replica shards have been successfully allocated.

标签:node,shards,shard,cat,allocation,cluster,版本升级,nodes
From: https://blog.51cto.com/u_11908275/6385825

相关文章

  • Recovering unassigned shards on elasticsearch 2.x——副本shard可以设置replica为0
    Recoveringunassignedshardsonelasticsearch2.x摘自:https://z0z0.me/recovering-unassigned-shards-on-elasticsearch/Igotaccrosstheproblemwhendecidedtoaddanodetotheelasticsearchclusterandthatnodewasnotabletoreplicatetheindexesofthe......
  • ShardingSphere使用实例
    ShardingSphere是一个开源的分布式数据库中间件,提供了数据库分片、读写分离、分布式事务等功能。下面是一个简单的示例,展示了如何在Java应用程序中使用ShardingSphere:添加依赖项:在您的项目的构建文件(例如pom.xml)中,添加ShardingSphere的依赖项。例如,在Maven项目中,您可以添加以下......
  • 3 - Dynamic Memory Allocation 动态内存分配
    DynamicMemoryAllocation动态内存分配我的博客程序源码本章介绍现代操作系统中编程的关键元素,动态内存分配与内存释放。glibcmalloc(3)API家族在虚拟内存那一章中,我们介绍过在虚拟内存中有段可以用作动态内存分配,这个段是堆段。GNUC库glibc提供强大的API允许开发......
  • springboot~对应sharding-jdbc实现分库分表
    原因当mysql数据库单表大于1千万以后,查询的性能就不能保证了,我们必须考虑分库,分表的方案了,还好,sharding-jdbc可以很优雅的与springboot对接,完成对mysql的分库和分表。依赖整理为了不影响其它小容量的表,所有添加了动态数据源,只对需要分库分表的进行配置即可com.baomidou:dyna......
  • Sharding-Jdbc配置示例
    ​ #应用名称spring:application:name:sharding-jdbc-test#开发环境设置profiles:active:dev#配置为内存模式shardingsphere:mode:type:Memory#配置真实数据源datasource:names:server-order00,server-order0......
  • 记录学习 ShardingSphere 遇到的坑
    ​ 首先来一下官网文档地址:概览::ShardingSphere一、数据库分为2个库,每个库有2张表​编辑 二、配置官方有很多配置方式(ShardingSphere-JDBC::ShardingSphere),这边使用的是YAML配置(YAML配置::ShardingSphere)规则配置:数据分片遇到的坑以下是官方给出的参数配置解......
  • 使用ShardingShpere来实现读写分离跟分库分表
    环境准备两个mysql集群,一主一从我们简单的用docker-compose来快速搭建一个version:'3'services:master1:image:mysql:5.7environment:MYSQL_ROOT_PASSWORD:123456ports:-"3307:3306"volumes:-./master1/data:/var/lib/mysql......
  • Mybatisplus3.5.1+shardingsphere-jdbc5.1.1分表
    注意使用雪花ID的话,查询ID时候必须使用long类型的ID,不要使用MP自带的默认的Serializable类型。否则会提示分片主键id数据类型和分片算法不匹配Inlineshardingalgorithmsexpressionxxxandshardingcolumnxxnotmatch错误。。。导入依赖<!--sharding-jdbc分库分表-->......
  • elasticsearch 启动报错 SearchPhaseExecutionException[Failed to execute phase [qu
    Elasticsearch启动报错:[2023-05-19T22:39:32,161][DEBUG][o.e.a.s.TransportSearchAction][X-111.ecs]Allshardsfailedforphase:[query][2020-05-19T22:39:32,162][WARN][r.suppressed][X-111.ecs]path:/.kibana_task_manager/_search,params:{ign......
  • P1937 [USACO10MAR]Barn Allocation G
    BarnAllocationG题目描述农夫约翰最近开了一个新的牲口棚屋,并且现在接受来自奶牛的分配畜栏请求因为其中的一些畜栏有更好风景。畜栏包括N个畜栏(1≤N≤100,000),方便起见,我们把它们编号为1..N,畜栏i能容纳Ci只牛(1≤Ci≤100,000),第i只牛需要连续编号畜栏(从Ai到Bi)来漫......