本文记录了命令行登录oceanbase-ce单机容器并进行简单的规格、资源池、租户信息查看和建、删命令测试。
1、登录数据库(以容器映射端口为3306为例 )
[root@localhost dockerfile]# mysql -h127.0.0.1 -uroot -p -P3306 -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3221487652
Server version: 5.7.25 OceanBase_CE 4.3.0.1 (r100000242024032211-0193a343bc60b4699ec47792c3fc4ce166a182f9) (Built Mar 22 2024 13:19:48)Copyright (c) 2000, 2022, Oracle and/or its affiliates.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.mysql>
2、切换到oceanbase库并查看已有的资源规格
mysql> use oceanbase;
Database changedmysql> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS;
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| 1 | sys_unit_config | 2024-03-30 15:43:11.919152 | 2024-03-30 15:43:11.919152 | 3 | 3 | 2147483648 | 2147483648 | 9223372036854775807 | 9223372036854775807 | 3 |
| 1001 | test_unit | 2024-03-30 15:43:19.749714 | 2024-03-30 15:43:19.749714 | 7 | 7 | 3221225472 | 3221225472 | 9223372036854775807 | 9223372036854775807 | 7 |
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
2 rows in set (0.00 sec)mysql>
3、创建一个名为ipam_unit的规格,查询验证
mysql> CREATE RESOURCE UNIT ipam_unit MEMORY_SIZE = '2G', MAX_CPU = 3, MIN_CPU = 1, LOG_DISK_SIZE = '6G' ;
Query OK, 0 rows affected (0.08 sec)mysql> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE NAME = 'ipam_unit';
+----------------+-----------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+----------------+-----------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
| 1003 | ipam_unit | 2024-04-12 17:23:15.686527 | 2024-04-12 17:23:15.686527 | 3 | 1 | 2147483648 | 6442450944 | 9223372036854775807 | 9223372036854775807 | 1 |
+----------------+-----------+----------------------------+----------------------------+---------+---------+-------------+---------------+---------------------+---------------------+-------------+
1 row in set (0.01 sec)
后续如需删除ipam_unit该规格
mysql> drop resource unit ipam_unit;
Query OK, 0 rows affected (0.07 sec)
4、查询已有的资源池
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 | 2024-03-30 15:43:11.922047 | 2024-03-30 15:43:11.926778 | 1 | 1 | zone1 | FULL |
| 1001 | test_pool | 1002 | 2024-03-30 15:43:19.756685 | 2024-03-30 15:43:19.794582 | 1 | 1001 | zone1 | FULL |
+------------------+-----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
2 rows in set (15.55 sec)mysql>
5、查询已有的租户信息
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 | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | MAX_LS_ID |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+-----------+
| 1 | sys | SYS | 2024-03-30 15:43:11.938501 | 2024-03-30 15:43:11.938501 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | NULL | NULL | NULL | NULL | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1 |
| 1001 | META$1002 | META | 2024-03-30 15:43:19.789417 | 2024-03-30 15:43:36.491571 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | NULL | NULL | NULL | NULL | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1 |
| 1002 | test | USER | 2024-03-30 15:43:19.793521 | 2024-03-30 15:43:36.524407 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1712914026043184341 | 1712914026043184341 | 1712914026043184340 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1001 |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+-----------+
3 rows in set (0.09 sec)mysql>
6、将test租户进行改名,改名为ipam,验证信息,然后删除ipam租户
mysql> ALTER TENANT test RENAME GLOBAL_NAME TO ipam;
Query OK, 0 rows affected (0.21 sec)mysql> SELECT * FROM oceanbase.DBA_OB_TENANTS where TENANT_NAME='ipam' ;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+-----------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | MAX_LS_ID |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+-----------+
| 1002 | ipam | USER | 2024-03-30 15:43:19.793521 | 2024-04-12 17:45:24.581302 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1712915167970934382 | 1712915167970934382 | 1712915167970934382 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1001 |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+-----------+
1 row in set (0.06 sec)mysql> drop TENANT ipam;
Query OK, 0 rows affected (1 min 30.71 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 | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | MAX_LS_ID |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
| 1 | sys | SYS | 2024-03-30 15:43:11.938501 | 2024-03-30 15:43:11.938501 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | NULL | NULL | NULL | NULL | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1 |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
1 row in set (0.02 sec)mysql>
7、删除test_pool资源池信息
mysql> DROP RESOURCE POOL test_pool;
Query OK, 0 rows affected (0.03 sec)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 | 2024-03-30 15:43:11.922047 | 2024-03-30 15:43:11.926778 | 1 | 1 | zone1 | FULL |
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
1 row in set (0.00 sec)
8、使用ipam_unit规格创建ipam_pool资源池
mysql> CREATE RESOURCE POOL ipam_pool UNIT='ipam_unit', UNIT_NUM=1, ZONE_LIST=('zone1');
Query OK, 0 rows affected (0.03 sec)
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 | 2024-03-30 15:43:11.922047 | 2024-03-30 15:43:11.926778 | 1 | 1 | zone1 | FULL |
| 1005 | ipam_pool | NULL | 2024-04-13 00:51:20.111474 | 2024-04-13 00:51:20.111474 | 1 | 1003 | zone1 | FULL |
+------------------+-----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+
2 rows in set (16.62 sec)
9、在 ipam_pool资源池上创建ipam租户
mysql> CREATE TENANT IF NOT EXISTS ipam PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('ipam_pool'),
CHARSET='utf8mb4' SET ob_tcp_invited_nodes TO '%';
Query OK, 0 rows affected, 1 warning (0.01 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 | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | MAX_LS_ID |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+----------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
| 1 | sys | SYS | 2024-03-30 15:43:11.938501 | 2024-03-30 15:43:11.938501 | RANDOM | FULL{1}@zone1 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | NULL | NULL | NULL | NULL | NOARCHIVELOG | DISABLED | 1 | 4.3.0.1 | 1 |
| 1003 | META$1004 | META | 2024-04-13 01:02:53.903813 | 2024-04-13 01:02:53.903813 | zone1 | FULL{1}@zone1 | NULL | MYSQL | CREATING | NO | NO | PRIMARY | NORMAL | 0 | NULL | NULL | NULL | NULL | NOARCHIVELOG | DISABLED | 1 | NULL | 1 |
| 1004 | ipam | USER | 2024-04-13 01:02:53.910250 | 2024-04-13 01:02:53.910250 | zone1 | FULL{1}@zone1 | NULL | MYSQL | CREATING | NO | NO | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | DISABLED | 1 | NULL | NULL |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+-------------------+--------------------+----------+---------------+--------+-------------+-------------------+------------------+----------+----------------+--------------+--------------------+--------------+----------------------------+----------+------------+-----------+
3 rows in set (0.04 sec)mysql>