连接sys租户
使用root用户连接sys租户的oceanbase数据库
[admin]# mysql -h192.168.1.71 -P2883 -D oceanbase -uroot@sys -pOceanbase2881 -A
添加zone
查看zone信息,当前OceanBase集群有2个zone
mysql> select * from oceanbase.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
mysql> alter system add zone zone3;
Query OK, 0 rows affected (0.25 sec)
查看zone信息,看到新增的zone3状态为INACTIVE
mysql> select * from oceanbase.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:03:47.864105 | INACTIVE | | default_region | ReadWrite |
+-------+----------------------------+----------------------------+----------+-----+----------------+-----------+
启动zone3
mysql> alter system start zone zone3;
Query OK, 0 rows affected (0.16 sec)
查看zone信息,看到新增的zone3状态由INACTIVE转为ACTIVE
mysql> select * from oceanbase.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:03:47.864105 | ACTIVE | | default_region | ReadWrite |
+-------+----------------------------+----------------------------+----------+-----+----------------+-----------+
添加节点
查看节点信息,当前OceanBase集群共有2个节点
mysql> select * from oceanbase.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 | NO | ACTIVE | 2023-05-06 15:14:10.951435 | NULL | NULL | 2023-04-24 18:32:52.606554 | 2023-05-08 15:15:29.356373 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov 1 2022 14:57:18) |
| 192.168.1.72 | 2882 | 2 | zone2 | 2881 | YES | ACTIVE | 2023-05-06 15:07:46.780470 | NULL | NULL | 2023-04-24 18:32:52.245134 | 2023-05-08 15:15:29.300873 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov 1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
添加节点192.168.1.73(添加节点前部署observer服务)
mysql> alter system add server '192.168.1.73:2882' zone 'zone3';
Query OK, 0 rows affected (0.42 sec)
查看节点信息,当前OceanBase集群此时有3个节点
mysql> select * from oceanbase.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 | NO | ACTIVE | 2023-05-06 15:14:10.951435 | NULL | NULL | 2023-04-24 18:32:52.606554 | 2023-05-08 15:15:29.356373 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov 1 2022 14:57:18) |
| 192.168.1.72 | 2882 | 2 | zone2 | 2881 | YES | ACTIVE | 2023-05-06 15:07:46.780470 | NULL | NULL | 2023-04-24 18:32:52.245134 | 2023-05-08 15:15:29.300873 | 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-08 18:08:35.230382 | 4.0.0.0_100000272022110114-6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be(Nov 1 2022 14:57:18) |
+--------------+----------+----+-------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+
集群扩容
查看资源池信息
mysql> select * from oceanbase.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 14:33:25.095753 | 1 | 1 | zone1;zone2 | FULL |
| 1007 | my_pool | 1004 | 2023-04-25 15:43:45.381999 | 2023-05-08 14:33:32.524411 | 1 | 1003 | zone1;zone2 | FULL |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------+--------------+
sys、my_tenant资源池ZONE_LIST新增zone3
mysql> alter resource pool sys_pool ZONE_LIST=('zone1','zone2','zone3');
Query OK, 0 rows affected (0.83 sec)
mysql> alter resource pool my_pool ZONE_LIST=('zone1','zone2','zone3');
Query OK, 0 rows affected (8.37 sec)
查看资源池信息
mysql> select * from oceanbase.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 |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-------------------+--------------+
租户增加副本
查看租户信息
mysql> select * from oceanbase.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 14:25:57.800492 | 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-08 14:26:30.706161 | 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-08 14:26:30.706161 | RANDOM | FULL{1}@zone1, FULL{1}@zone2 | NULL | MYSQL | NORMAL | NO | NO |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
sys、my_tenant租户LOCALITY新增zone3
mysql> alter tenant sys LOCALITY='FULL{1}@zone1,FULL{1}@zone2,FULL{1}@zone3';
Query OK, 0 rows affected (2.31 sec)
mysql> alter tenant my_tenant LOCALITY='FULL{1}@zone1,FULL{1}@zone2,FULL{1}@zone3';
Query OK, 0 rows affected (1.52 sec)
查看租户信息
mysql> select * from oceanbase.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:17:13.418669 | RANDOM | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | FULL{1}@zone1, FULL{1}@zone2 | MYSQL | NORMAL | NO | NO |
| 1003 | META$1004 | META | 2023-04-25 16:54:07.990306 | 2023-05-08 18:17:22.787336 | RANDOM | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | FULL{1}@zone1, FULL{1}@zone2 | MYSQL | NORMAL | NO | NO |
| 1004 | my_tenant | USER | 2023-04-25 16:54:07.991849 | 2023-05-08 18:17:22.787336 | RANDOM | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | FULL{1}@zone1, FULL{1}@zone2 | MYSQL | NORMAL | NO | NO |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------------------------------------+------------------------------+--------------------+--------+---------------+--------+
添加zone参考:https://www.oceanbase.com/docs/common-oceanbase-database-cn-10000000001687938
添加节点参考:https://www.oceanbase.com/docs/common-oceanbase-database-cn-10000000001697238