首页 > 其他分享 >OceanBase集群缩容

OceanBase集群缩容

时间:2023-05-09 10:33:55浏览次数:52  
标签:缩容 09 04 05 OceanBase 18 TIME 集群 2023

连接sys租户

使用root用户连接sys租户的oceanbase数据库

[admin]# mysql -h192.168.1.71 -P2883 -D oceanbase -uroot@sys -pOceanbase2881 -A

租户减少副本

查看租户信息,sys、my_tenat租户(sys是系统租户,my_tenant是我创建的测试租户)的LOCALITY值包括:zone1、zone2、zone3

mysql> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE | LOCALITY                                    | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+
|         1 | sys         | SYS         | 2023-04-24 18:33:06.821930 | 2023-05-08 18:23:29.612310 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1003 | META$1004   | META        | 2023-04-25 16:54:07.990306 | 2023-05-08 18:25:26.069907 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1004 | my_tenant   | USER        | 2023-04-25 16:54:07.991849 | 2023-05-08 18:25:26.069907 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL              | MYSQL              | NORMAL | NO            | NO     |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+

从租户中删除zone3

mysql> alter tenant sys LOCALITY='FULL{1}@zone1,FULL{1}@zone2';
Query OK, 0 rows affected (3.98 sec)

mysql> alter tenant my_tenant LOCALITY='FULL{1}@zone1,FULL{1}@zone2';
Query OK, 0 rows affected (2.93 sec)

查看租户信息,可以看到sys、my_tenant租户的LOCALITY值只包括:zone1、zone2

mysql> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE | LOCALITY                     | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
|         1 | sys         | SYS         | 2023-04-24 18:33:06.821930 | 2023-05-09 09:28:07.989177 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1003 | META$1004   | META        | 2023-04-25 16:54:07.990306 | 2023-05-09 09:28:31.056441 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1004 | my_tenant   | USER        | 2023-04-25 16:54:07.991849 | 2023-05-09 09:28:31.056441 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+

资源池删除zone3

查看资源池信息,sys_pool、my_pool资源池(sys_pool是系统资源池,my_pool是我创建的测试资源池)的ZONE_LIST包括:zone1、zone2、zone3

mysql> select * from DBA_OB_RESOURCE_POOLS;
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------------+--------------+
| RESOURCE_POOL_ID | NAME     | TENANT_ID | CREATE_TIME                | MODIFY_TIME                | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST         | REPLICA_TYPE |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------------+--------------+
|                1 | sys_pool |         1 | 2023-04-24 18:33:06.599543 | 2023-05-08 18:13:57.287837 |          1 |              1 | zone1;zone2;zone3 | FULL         |
|             1007 | my_pool  |      1004 | 2023-04-25 15:43:45.381999 | 2023-05-08 18:14:21.769913 |          1 |           1003 | zone1;zone2;zone3 | FULL         |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------------+--------------+

从资源池zone_list中删除zone3

mysql> alter resource pool sys_pool ZONE_LIST=('zone1','zone2');
Query OK, 0 rows affected (0.20 sec)

mysql> alter resource pool my_pool ZONE_LIST=('zone1','zone2');
Query OK, 0 rows affected (0.29 sec)

查看资源池信息,sys_pool、my_pool资源池(sys_pool是系统资源池,my_pool是我创建的测试资源池)的ZONE_LIST包括:zone1、zone2

mysql> select * from DBA_OB_RESOURCE_POOLS;
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------+--------------+
| RESOURCE_POOL_ID | NAME     | TENANT_ID | CREATE_TIME                | MODIFY_TIME                | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST   | REPLICA_TYPE |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------+--------------+
|                1 | sys_pool |         1 | 2023-04-24 18:33:06.599543 | 2023-05-09 09:41:36.796368 |          1 |              1 | zone1;zone2 | FULL         |
|             1007 | my_pool  |      1004 | 2023-04-25 15:43:45.381999 | 2023-05-09 09:41:43.783302 |          1 |           1003 | zone1;zone2 | FULL         |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------+--------------+

删除节点

查看节点信息

mysql> select * from DBA_OB_SERVERS;
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| SVR_IP       | SVR_PORT | ID | ZONE  | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME         | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME                | MODIFY_TIME                | BUILD_VERSION                                                                             |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| 192.168.1.71 |     2882 |  1 | zone1 |     2881 | YES             | ACTIVE | 2023-05-06 15:14:10.951435 | NULL      | NULL                  | 2023-04-24 18:32:52.606554 | 2023-05-09 05:01:04.983560 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.72 |     2882 |  2 | zone2 |     2881 | NO              | ACTIVE | 2023-05-06 15:07:46.780470 | NULL      | NULL                  | 2023-04-24 18:32:52.245134 | 2023-05-09 05:01:05.072178 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.73 |     2882 |  4 | zone3 |     2881 | NO              | ACTIVE | 2023-05-08 18:08:33.287859 | NULL      | NULL                  | 2023-05-08 18:08:26.713833 | 2023-05-09 05:01:05.686120 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+

隔离192.168.1.73节点

mysql> alter system stop server '192.168.1.73:2882';
Query OK, 0 rows affected (0.94 sec)

查看节点信息,192.168.1.73节点STOP_TIME值是隔离的时间点

mysql> select * from DBA_OB_SERVERS;
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| SVR_IP       | SVR_PORT | ID | ZONE  | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME         | STOP_TIME                  | BLOCK_MIGRATE_IN_TIME | CREATE_TIME                | MODIFY_TIME                | BUILD_VERSION                                                                             |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| 192.168.1.71 |     2882 |  1 | zone1 |     2881 | YES             | ACTIVE | 2023-05-06 15:14:10.951435 | NULL                       | NULL                  | 2023-04-24 18:32:52.606554 | 2023-05-09 05:01:04.983560 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.72 |     2882 |  2 | zone2 |     2881 | NO              | ACTIVE | 2023-05-06 15:07:46.780470 | NULL                       | NULL                  | 2023-04-24 18:32:52.245134 | 2023-05-09 05:01:05.072178 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.73 |     2882 |  4 | zone3 |     2881 | NO              | ACTIVE | 2023-05-08 18:08:33.287859 | 2023-05-09 09:46:20.363214 | NULL                  | 2023-05-08 18:08:26.713833 | 2023-05-09 09:46:20.391424 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+

到192.168.1.73节点上的observer服务

[root]# kill -9 `pidof observer`

 查看节点信息,192.168.1.73节点状态为INACTIVE

mysql> select * from DBA_OB_SERVERS;
+--------------+----------+----+-------+----------+-----------------+----------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| SVR_IP       | SVR_PORT | ID | ZONE  | SQL_PORT | WITH_ROOTSERVER | STATUS   | START_SERVICE_TIME         | STOP_TIME                  | BLOCK_MIGRATE_IN_TIME | CREATE_TIME                | MODIFY_TIME                | BUILD_VERSION                                                                             |
+--------------+----------+----+-------+----------+-----------------+----------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| 192.168.1.71 |     2882 |  1 | zone1 |     2881 | YES             | ACTIVE   | 2023-05-06 15:14:10.951435 | NULL                       | NULL                  | 2023-04-24 18:32:52.606554 | 2023-05-09 05:01:04.983560 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.72 |     2882 |  2 | zone2 |     2881 | NO              | ACTIVE   | 2023-05-06 15:07:46.780470 | NULL                       | NULL                  | 2023-04-24 18:32:52.245134 | 2023-05-09 05:01:05.072178 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.73 |     2882 |  4 | zone3 |     2881 | NO              | INACTIVE | NULL                       | 2023-05-09 09:46:20.363214 | NULL                  | 2023-05-08 18:08:26.713833 | 2023-05-09 09:47:02.583856 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+----------+----------------------------+----------------------------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+

删除192.168.1.73节点

mysql> alter system delete server '192.168.1.73:2882';
Query OK, 0 rows affected (0.23 sec)

 查看节点信息,此时已经看不到192.168.1.73节点的信息

mysql> select * from DBA_OB_SERVERS;
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| SVR_IP       | SVR_PORT | ID | ZONE  | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME         | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME                | MODIFY_TIME                | BUILD_VERSION                                                                             |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
| 192.168.1.71 |     2882 |  1 | zone1 |     2881 | YES             | ACTIVE | 2023-05-06 15:14:10.951435 | NULL      | NULL                  | 2023-04-24 18:32:52.606554 | 2023-05-09 05:01:04.983560 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
| 192.168.1.72 |     2882 |  2 | zone2 |     2881 | NO              | ACTIVE | 2023-05-06 15:07:46.780470 | NULL      | NULL                  | 2023-04-24 18:32:52.245134 | 2023-05-09 05:01:05.072178 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov  1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+

 删除zone3

 查看ZONE信息

mysql> select * from DBA_OB_ZONES;
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| ZONE  | CREATE_TIME                | MODIFY_TIME                | STATUS | IDC | REGION         | TYPE      |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| zone1 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE |     | default_region | ReadWrite |
| zone2 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE |     | default_region | ReadWrite |
| zone3 | 2023-05-08 18:03:47.864105 | 2023-05-08 18:07:34.943350 | ACTIVE |     | default_region | ReadWrite |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+

关闭zone3

mysql> alter system stop zone zone3;
Query OK, 0 rows affected (0.41 sec)

查看ZONE信息,此时zone3的状态为INACTIVE(待激活)

mysql> select * from DBA_OB_ZONES;
+-------+----------------------------+----------------------------+----------+-----+----------------+-----------+
| ZONE  | CREATE_TIME                | MODIFY_TIME                | STATUS   | IDC | REGION         | TYPE      |
+-------+----------------------------+----------------------------+----------+-----+----------------+-----------+
| zone1 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE   |     | default_region | ReadWrite |
| zone2 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE   |     | default_region | ReadWrite |
| zone3 | 2023-05-08 18:03:47.864105 | 2023-05-09 09:49:24.709821 | INACTIVE |     | default_region | ReadWrite |
+-------+----------------------------+----------------------------+----------+-----+----------------+-----------+

删除zone3

mysql> alter system delete zone zone3;
Query OK, 0 rows affected (0.13 sec)

查看ZONE信息,此时已经看不到zone3的信息

mysql> select * from DBA_OB_ZONES;
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| ZONE  | CREATE_TIME                | MODIFY_TIME                | STATUS | IDC | REGION         | TYPE      |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| zone1 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE |     | default_region | ReadWrite |
| zone2 | 2023-04-24 18:33:07.113435 | 2023-04-24 18:33:07.113435 | ACTIVE |     | default_region | ReadWrite |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+

 

删除ZONE参考:https://www.oceanbase.com/docs/common-oceanbase-database-cn-10000000001687939
删除节点参考:https://www.oceanbase.com/docs/common-oceanbase-database-cn-10000000001692877

标签:缩容,09,04,05,OceanBase,18,TIME,集群,2023
From: https://www.cnblogs.com/haha029/p/17384123.html

相关文章

  • OceanBase集群扩容
    连接sys租户使用root用户连接sys租户的oceanbase数据库[admin]#mysql-h192.168.1.71-P2883-Doceanbase-uroot@sys-pOceanbase2881-A添加zone查看zone信息,当前OceanBase集群有2个zonemysql>select*fromoceanbase.dba_ob_zones;+-------+------------------------......
  • Nacos 使用 CentOS7 进行集群部署
    有了上篇博客的Nacos单机部署经验,对于集群搭建就容易多了。要想搭建Nacos集群,至少需要3个节点。为了统一访问地址,因此需要使用nginx进行转发。本篇博客仍然采用Nacos当前最新的版本2.2.2进行集群搭建。Nacos官网上也有集群搭建的说明,不过有点简略。Nacos的集群搭......
  • skywalking 集群部署
    1、安装包:apache-skywalking-apm-es7-8.7.0.tar.gz下载地址:https://archive.apache.org/dist/skywalking/8.7.0/apache-skywalking-apm-es7-8.7.0.tar.gz2、安装包解压tar -xf  apache-skywalking-apm-es7-8.7.0.tar.gzyuminstalljava-1.8.0-openjdk-devel-y  ......
  • 搭建 Kubernetes 集群
    简介Kubernetes是一个开源系统,用于容器化应用的自动部署、扩缩和管理。它将构成应用的容器按逻辑单位进行分组以便于管理和发现。搭建环境:CentOSv7.6.1810docker-ce-versionv23.0.5kubernetes-versionv1.23.6本次使用2台服务器进行搭建,运行下面命令写入/etc/hosts文件(......
  • Hbase跨集群迁移以及常用命令
    场景:由于Hbase版本升级以及集群切换,现需要将Hbase从A集群(源)迁移至B集群(目的)迁移过程:将源A集群的Hbase需要迁移的表(注意namespace)通过snapshot方式打成快照,然后再通过ExportSnapshot方式迁移至目的B集群,此时目的集群的HDFS目录下的hbase目录会生成.hbase_snapshot和archive目录......
  • k8s集群组件
    k8s集群有以下组件:Master:Kubernetes集群的控制中心,包括:APIServer:在Kubernetes集群中,APIserver扮演一个接口,使用户和管理员可以通过kubectl或其他工具与集群进行交互,而不必直接与底层组件打交道。同时,所有其他Kubernetes组件,包括kubelet、kube-proxy、controllerman......
  • StatefulSet扩缩容源码分析
    k8sv1.15.0Informer监听cmd/kube-controller-manager/app/apps.go作为StatefulSet资源控制器,StatefulSetController通过PodInformer、StatefulSetInformer、PersistentVolumeClaimInformer、ControllerRevisionInformer来监听事件。扩缩容StatefulSetpodManagementPolicyPa......
  • 有关本地集群的linux操作tips
    免密登录认证-1.使用rsa加密技术,生成公钥和私钥。一路回车即可[root@username01~]#cd~[root@username01~]#ssh-keygen-trsa -2.进入~/.ssh目录下,使用ssh-copy-id命令[root@username01~]#cd~/.ssh [[email protected]]#ssh-copy-idroot@username01-3.......
  • Deploy扩缩容源码分析
    k8sv1.15.0Informer监听作为Deployment资源控制器,DeploymentController通过DeploymentInformer、ReplicaSetInformer、PodInformer来监听事件。cmd/kube-controller-manager/app/apps.gostartDeploymentController函数pkg/controller/deployment/deployment_controller.goN......
  • openGauss 5.0 主从集群 日常运维
    在之前的博客我们看了openGauss主从集群的搭建,如下:openGauss5.0一主两从复制环境搭建手册https://www.cndba.cn/dave/article/116528本篇我们看下主从集群的维护。 1查看集群状态查看集群所有节点:[[email protected]~]$gs_om-tstatus--detail[CMServerSta......