本系列总的专栏:一步一步学习OceanBase系列
今天考OBCP的同事问我删除租户能不能闪回,想起了之前遇到过的一个问题,今天网友也遇到了,也在问我怎么处理,这里记录下。
OB官方文档说,目前不支持租户闪回,但是删除租户时,如果不加force参数,删除租户其实是被放入回收站了,而且查看__all_tenant表,原租户名被更改了一个__recycle_$_*开头的别名,并且原租户占用的资源并没有被释放。
此时如果想再重建同名租户,会报租户已存在,或者此时想重新用原租户对应的资源池创建新的租户时,会报资源池已被分配给一个租户。
OB如果不支持租户闪回,干嘛删除租户有放入回收站呢?目前2275版本仍然存在此问题,应该是OB未来对租户删除有其它规划或者未来支持租户闪回。
正确的删除租户方式是 drop tenant 加上 force 参数:drop tenant xxx force;
以下我们来做个测试。
[admin@ocp101 my]$ obclient -h127.1 -P2883 -uroot@sys#obdemo -pYH_admin123.com -c oceanbase
obclient: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the OceanBase monitor. Commands end with ; or \g.
Your OceanBase connection id is 3293928
Server version: 5.6.25 OceanBase 2.2.75 (r20210107182621-81357ec10e1342ef9f9e993ea38ef1cdd8778cf6) (Built Jan 7 2021 18:54:53)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient> source servers.sql
+-------+--------------+----------+------------+-----------------+--------+----------------------------+----------------------------+-----------------------+
| zone | svr_ip | svr_port | inner_port | with_rootserver | status | gmt_create | start_service_time | build_version |
+-------+--------------+----------+------------+-----------------+--------+----------------------------+----------------------------+-----------------------+
| zone1 | 10.10.10.185 | 2882 | 2881 | 1 | active | 2020-12-21 15:54:03.200702 | 2021-01-15 12:09:53.789667 | 2.2.75_20210107182621 |
| zone2 | 10.10.10.196 | 2882 | 2881 | 0 | active | 2020-12-21 15:54:03.620223 | 2021-01-15 12:18:24.780653 | 2.2.75_20210107182621 |
| zone3 | 10.10.10.65 | 2882 | 2881 | 0 | active | 2020-12-21 15:54:03.231911 | 2021-01-15 12:14:31.224392 | 2.2.75_20210107182621 |
+-------+--------------+----------+------------+-----------------+--------+----------------------------+----------------------------+-----------------------+
3 rows in set (0.00 sec)
obclient> source server_stat.sql
+-------+-------------------+-----------+----------+--------------+-------------+---------------+--------------+----------+----------------------------+-----------------------+--------+
| zone | observer | cpu_total | cpu_free | mem_total_gb | mem_free_gb | disk_total_gb | disk_free_gb | unit_num | start_service_time | version | status |
+-------+-------------------+-----------+----------+--------------+-------------+---------------+--------------+----------+----------------------------+-----------------------+--------+
| zone1 | 10.10.10.185:2882 | 30 | 6.5 | 184 | 91 | 380 | -1200 | 5 | 2021-01-15 12:09:53.789667 | 2.2.75_20210107182621 | active |
| zone2 | 10.10.10.196:2882 | 30 | 6.5 | 184 | 91 | 380 | -1200 | 5 | 2021-01-15 12:18:24.780653 | 2.2.75_20210107182621 | active |
| zone3 | 10.10.10.65:2882 | 30 | 6.5 | 184 | 91 | 380 | -1200 | 5 | 2021-01-15 12:14:31.224392 | 2.2.75_20210107182621 | active |
+-------+-------------------+-----------+----------+--------------+-------------+---------------+--------------+----------+----------------------------+-----------------------+--------+
3 rows in set (0.01 sec)
obclient> source unit_config.sql
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
| unit_config_id | name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | max_disk_size_gb |
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
| 1 | sys_unit_config | 5 | 2.5 | 16 | 12 | 380 |
| 1007 | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 500 |
| 1008 | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 500 |
| 1009 | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 500 |
| 1010 | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 500 |
| 1011 | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 500 |
| 1012 | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 500 |
| 1014 | my_unit_2c16g | 2 | 2 | 16 | 16 | 100 |
| 1015 | my_unit_1c5g | 1 | 1 | 5 | 5 | 100 |
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
9 rows in set (0.00 sec)
obclient> source unit_config.sql
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
| unit_config_id | name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | max_disk_size_gb |
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
| 1 | sys_unit_config | 5 | 2.5 | 16 | 12 | 380 |
| 1007 | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 500 |
| 1008 | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 500 |
| 1009 | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 500 |
| 1010 | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 500 |
| 1011 | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 500 |
| 1012 | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 500 |
| 1014 | my_unit_2c16g | 2 | 2 | 16 | 16 | 100 |
| 1015 | my_unit_1c5g | 1 | 1 | 5 | 5 | 100 |
+----------------+------------------------------------+---------+---------+------------+------------+------------------+
9 rows in set (0.00 sec)
obclient> source tent.sql
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
5 rows in set (0.00 sec)
--创建一个测试用的资源池test_pool
obclient> create resource pool test_pool unit = 'my_unit_1c5g', unit_num = 1;
Query OK, 0 rows affected (0.27 sec)
--创建一个mysql租户,使用已创建的测试资源池test_pool
obclient> create tenant test_tent01 resource_pool_list=('test_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (4.52 sec)
--此时查看__all_tenant表
obclient> source tent.sql
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
| 1007 | test_tent01 | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | RANDOM | 2021-03-26 16:42:02.359033 |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
6 rows in set (0.00 sec)
--查看是否开启了回收站(已开启)
obclient> show variables like 'recyclebin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| recyclebin | ON |
+---------------+-------+
1 row in set (0.00 sec)
--此时回收站里没有对象
obclient> show recyclebin;
Empty set (0.09 sec)
--开始删除租户,不加force
obclient> drop tenant test_tent01;
Query OK, 0 rows affected (0.02 sec)
--此时查看__all_tenant表,发现删除的租户test_tent其实是重命名成了一个__all_recycle_$_*开头的租户
obclient> source tent.sql
+-----------+--------------------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+--------------------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
| 1007 | __recycle_$_2_1616748122358784 | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | RANDOM | 2021-03-26 16:43:12.408773 |
+-----------+--------------------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
6 rows in set (0.01 sec)
--此时查看回收站,发现删除的租户被放进了回收站
obclient> show recyclebin;
+--------------------------------+---------------+--------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+---------------+--------+----------------------------+
| __recycle_$_2_1616748122358784 | test_tent01 | TENANT | 2021-03-26 16:43:12.407740 |
+--------------------------------+---------------+--------+----------------------------+
1 row in set (0.01 sec)
--此时查看资源池,测试资源池test_pool被__recycle_$_*开头的租户占用
obclient> source pool.sql
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+--------------------------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone | observer | tenant_id | tenant_name |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+--------------------------------+
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 1 | zone1 | 10.10.10.185:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 2 | zone2 | 10.10.10.196:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 3 | zone3 | 10.10.10.65:2882 | 1 | sys |
| pool_gjj_mysql_tent_zone1_sjr | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 1001 | zone1 | 10.10.10.185:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone2_nhm | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 1002 | zone2 | 10.10.10.196:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone3_gjc | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 1003 | zone3 | 10.10.10.65:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_ora_tent_zone2_kza | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 1004 | zone2 | 10.10.10.196:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone3_avt | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 1005 | zone3 | 10.10.10.65:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone1_neh | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 1006 | zone1 | 10.10.10.185:2882 | 1002 | gjj_ora_tent |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1010 | zone1 | 10.10.10.185:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1011 | zone2 | 10.10.10.196:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1012 | zone3 | 10.10.10.65:2882 | 1004 | gjj_ora_tent_restore |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1013 | zone1 | 10.10.10.185:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1014 | zone2 | 10.10.10.196:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1015 | zone3 | 10.10.10.65:2882 | 1005 | ora_test_tent |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1016 | zone1 | 10.10.10.185:2882 | 1007 | __recycle_$_2_1616748122358784 |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1017 | zone2 | 10.10.10.196:2882 | 1007 | __recycle_$_2_1616748122358784 |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1018 | zone3 | 10.10.10.65:2882 | 1007 | __recycle_$_2_1616748122358784 |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+--------------------------------+
18 rows in set (0.00 sec)
--此时如果想再创建一个同名的租户时,会报错
obclient> create tenant test_tent01 resource_pool_list=('test_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
ERROR 4626 (HY000): resource pool 'test_pool' has already been granted to a tenant
obclient>
--此时闪回租户,OB也不支持闪回租户
obclient> flashback tenant test_tent01 before to drop;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'before to drop' at line 1
obclient>
obclient> flashback tenant __recycle_$_2_1616748122358784 before to drop;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'before to drop' at line 1
obclient>
--此时如果想重新用原租户对应的资源池创建新的租户时,会报资源池已被分配给一个租户。
obclient> create tenant test_tent02 resource_pool_list=('test_pool'), primary_zone='RANDOM',comment 'oracle tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='oracle';
ERROR 4626 (HY000): resource pool 'test_pool' has already been granted to a tenant
obclient>
--到此,如果出现这种情况该怎么做呢?再删除__recycle_$_*开头的租户,加上force参数
obclient> drop tenant __recycle_$_2_1616748122358784 force;
Query OK, 0 rows affected (0.17 sec)
obclient>
obclient> source tent.sql
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
5 rows in set (0.01 sec)
obclient> source pool.sql
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone | observer | tenant_id | tenant_name |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 1 | zone1 | 10.10.10.185:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 2 | zone2 | 10.10.10.196:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 3 | zone3 | 10.10.10.65:2882 | 1 | sys |
| pool_gjj_mysql_tent_zone1_sjr | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 1001 | zone1 | 10.10.10.185:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone2_nhm | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 1002 | zone2 | 10.10.10.196:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone3_gjc | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 1003 | zone3 | 10.10.10.65:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_ora_tent_zone2_kza | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 1004 | zone2 | 10.10.10.196:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone3_avt | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 1005 | zone3 | 10.10.10.65:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone1_neh | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 1006 | zone1 | 10.10.10.185:2882 | 1002 | gjj_ora_tent |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1010 | zone1 | 10.10.10.185:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1011 | zone2 | 10.10.10.196:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1012 | zone3 | 10.10.10.65:2882 | 1004 | gjj_ora_tent_restore |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1013 | zone1 | 10.10.10.185:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1014 | zone2 | 10.10.10.196:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1015 | zone3 | 10.10.10.65:2882 | 1005 | ora_test_tent |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1016 | zone1 | 10.10.10.185:2882 | NULL | NULL |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1017 | zone2 | 10.10.10.196:2882 | NULL | NULL |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1018 | zone3 | 10.10.10.65:2882 | NULL | NULL |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
18 rows in set (0.00 sec)
obclient> show recyclebin;
+--------------------------------+---------------+--------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+---------------+--------+----------------------------+
| __recycle_$_2_1616748122358784 | test_tent01 | TENANT | 2021-03-26 16:43:12.407740 |
+--------------------------------+---------------+--------+----------------------------+
1 row in set (0.00 sec)
obclient>
--清空回收站其实也没用,会报回收站没有对象,但show recyclebin确能看到删除的回收站
obclient> purge recyclebin;
ERROR 5270 (HY000): object not in RECYCLE BIN
obclient>
obclient> show recyclebin;
+--------------------------------+---------------+--------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+---------------+--------+----------------------------+
| __recycle_$_2_1616748122358784 | test_tent01 | TENANT | 2021-03-26 16:43:12.407740 |
+--------------------------------+---------------+--------+----------------------------+
1 row in set (0.01 sec)
obclient>
最后,正确的删除租户的方式时,drop tenant时加上force参数。
obclient>
obclient> create tenant test_tent01 resource_pool_list=('test_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (1.79 sec)
obclient> source tent.sql
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
| 1010 | test_tent01 | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | RANDOM | 2021-03-26 16:51:24.473536 |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
6 rows in set (0.00 sec)
obclient> source pool.sql
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone | observer | tenant_id | tenant_name |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 1 | zone1 | 10.10.10.185:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 2 | zone2 | 10.10.10.196:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 3 | zone3 | 10.10.10.65:2882 | 1 | sys |
| pool_gjj_mysql_tent_zone1_sjr | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 1001 | zone1 | 10.10.10.185:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone2_nhm | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 1002 | zone2 | 10.10.10.196:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone3_gjc | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 1003 | zone3 | 10.10.10.65:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_ora_tent_zone2_kza | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 1004 | zone2 | 10.10.10.196:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone3_avt | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 1005 | zone3 | 10.10.10.65:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone1_neh | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 1006 | zone1 | 10.10.10.185:2882 | 1002 | gjj_ora_tent |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1010 | zone1 | 10.10.10.185:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1011 | zone2 | 10.10.10.196:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1012 | zone3 | 10.10.10.65:2882 | 1004 | gjj_ora_tent_restore |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1013 | zone1 | 10.10.10.185:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1014 | zone2 | 10.10.10.196:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1015 | zone3 | 10.10.10.65:2882 | 1005 | ora_test_tent |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1016 | zone1 | 10.10.10.185:2882 | 1010 | test_tent01 |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1017 | zone2 | 10.10.10.196:2882 | 1010 | test_tent01 |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1018 | zone3 | 10.10.10.65:2882 | 1010 | test_tent01 |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
18 rows in set (0.00 sec)
obclient> show recyclebin;
+--------------------------------+---------------+--------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+---------------+--------+----------------------------+
| __recycle_$_2_1616748122358784 | test_tent01 | TENANT | 2021-03-26 16:43:12.407740 |
+--------------------------------+---------------+--------+----------------------------+
1 row in set (0.01 sec)
obclient>
obclient>
obclient> drop tenant test_tent01 force;
Query OK, 0 rows affected (0.13 sec)
obclient> source tent.sql
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| tenant_id | tenant_name | compatibility_mode | zone_list | locality | primary_zone | gmt_modified |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
| 1 | sys | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2,zone3 | 2020-12-21 15:57:13.995853 |
| 1001 | gjj_mysql_tent | 0 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 10:39:29.044498 |
| 1002 | gjj_ora_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2020-12-23 14:52:09.341057 |
| 1004 | gjj_ora_tent_restore | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1,zone2,zone3 | 2021-01-26 18:47:23.217573 |
| 1005 | ora_test_tent | 1 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | zone1;zone2;zone3 | 2021-02-01 11:16:11.895747 |
+-----------+----------------------+--------------------+-------------------+---------------------------------------------+-------------------+----------------------------+
5 rows in set (0.00 sec)
obclient> source pool.sql
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | unit_id | zone | observer | tenant_id | tenant_name |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 1 | zone1 | 10.10.10.185:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 2 | zone2 | 10.10.10.196:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 16 | 12 | 3 | zone3 | 10.10.10.65:2882 | 1 | sys |
| pool_gjj_mysql_tent_zone1_sjr | config_gjj_mysql_tent_zone1_S3_bsx | 6 | 6 | 20 | 20 | 1001 | zone1 | 10.10.10.185:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone2_nhm | config_gjj_mysql_tent_zone2_S3_gde | 6 | 6 | 20 | 20 | 1002 | zone2 | 10.10.10.196:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_mysql_tent_zone3_gjc | config_gjj_mysql_tent_zone3_S3_oje | 6 | 6 | 20 | 20 | 1003 | zone3 | 10.10.10.65:2882 | 1001 | gjj_mysql_tent |
| pool_gjj_ora_tent_zone2_kza | config_gjj_ora_tent_zone2_S4_kza | 12 | 12 | 40 | 40 | 1004 | zone2 | 10.10.10.196:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone3_avt | config_gjj_ora_tent_zone3_S4_avt | 12 | 12 | 40 | 40 | 1005 | zone3 | 10.10.10.65:2882 | 1002 | gjj_ora_tent |
| pool_gjj_ora_tent_zone1_neh | config_gjj_ora_tent_zone1_S4_neh | 12 | 12 | 40 | 40 | 1006 | zone1 | 10.10.10.185:2882 | 1002 | gjj_ora_tent |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1010 | zone1 | 10.10.10.185:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1011 | zone2 | 10.10.10.196:2882 | 1004 | gjj_ora_tent_restore |
| gjj_pool_restore | my_unit_2c16g | 2 | 2 | 16 | 16 | 1012 | zone3 | 10.10.10.65:2882 | 1004 | gjj_ora_tent_restore |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1013 | zone1 | 10.10.10.185:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1014 | zone2 | 10.10.10.196:2882 | 1005 | ora_test_tent |
| test_pool_restore | my_unit_1c5g | 1 | 1 | 5 | 5 | 1015 | zone3 | 10.10.10.65:2882 | 1005 | ora_test_tent |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1016 | zone1 | 10.10.10.185:2882 | NULL | NULL |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1017 | zone2 | 10.10.10.196:2882 | NULL | NULL |
| test_pool | my_unit_1c5g | 1 | 1 | 5 | 5 | 1018 | zone3 | 10.10.10.65:2882 | NULL | NULL |
+-------------------------------+------------------------------------+---------+---------+------------+------------+---------+-------+-------------------+-----------+----------------------+
18 rows in set (0.01 sec)
obclient> drop resource pool test_pool;
Query OK, 0 rows affected (0.01 sec)
obclient>
obclient> show recyclebin;
+--------------------------------+---------------+--------+----------------------------+
| OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME |
+--------------------------------+---------------+--------+----------------------------+
| __recycle_$_2_1616748122358784 | test_tent01 | TENANT | 2021-03-26 16:43:12.407740 |
+--------------------------------+---------------+--------+----------------------------+
1 row in set (0.00 sec)
obclient>
一步一步学习oceanbase系列
复制
最后修改时间:2021-03-29 18:01:41
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
2025年4月中国数据库流行度排行榜:OB高分复登顶,崖山稳驭撼十强
墨天轮编辑部
1893次阅读
2025-04-09 15:33:27
2025年3月国产数据库大事记
墨天轮编辑部
872次阅读
2025-04-03 15:21:16
OceanBase 接入 MCP 架构:贯通数据孤岛,释放 AI 创新潜能
OceanBase数据库
399次阅读
2025-03-28 15:32:52
OceanBase 单机版发布,针对中小规模业务场景
通讯员
261次阅读
2025-03-28 12:01:19
AI关键场景得到全面支持!OceanBase入选Forrester报告三大领域代表厂商
OceanBase数据库
231次阅读
2025-04-19 22:27:54
数据库管理-第313期 分布式挑战单机,OceanBase单机版试玩(20250411)
胖头鱼的鱼缸
211次阅读
2025-04-10 22:41:56
OceanBase CEO杨冰:2025年分布式数据库将迎来本地部署和国产升级的全面爆发
通讯员
202次阅读
2025-04-03 09:35:26
OceanBase亮相「党政信息化产品技术选型供需对接会」,助力党政关键业务系统升级
OceanBase
191次阅读
2025-03-27 09:55:58
OceanBase单机版产品解读
多明戈教你玩狼人杀
181次阅读
2025-04-11 15:28:33
2024年中国联通软研院OceanBase扩容单一来源采购公示
通讯员
157次阅读
2025-04-21 15:55:59