暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

关于oceanbase 回收站和删除租户的问题

2955

本系列总的专栏:一步一步学习OceanBase系列


今天考OBCP的同事问我删除租户能不能闪回,想起了之前遇到过的一个问题,今天网友也遇到了,也在问我怎么处理,这里记录下。

OB官方文档说,目前不支持租户闪回,但是删除租户时,如果不加force参数,删除租户其实是被放入回收站了,而且查看__all_tenant表,原租户名被更改了一个__recycle_$_*开头的别名,并且原租户占用的资源并没有被释放。
此时如果想再重建同名租户,会报租户已存在,或者此时想重新用原租户对应的资源池创建新的租户时,会报资源池已被分配给一个租户。

OB如果不支持租户闪回,干嘛删除租户有放入回收站呢?目前2275版本仍然存在此问题,应该是OB未来对租户删除有其它规划或者未来支持租户闪回。

正确的删除租户方式是 drop tenant 加上 force 参数:drop tenant xxx force;

image.png


以下我们来做个测试。

[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
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
1人已赞赏
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论