oceanbase 资源查询和分配

资源单元 resource unit

查询单元信息

obclient [(none)]> select * from oceanbase.__all_unit_config;
+----------------------------+----------------------------+----------------+-----------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
| gmt_create                 | gmt_modified               | unit_config_id | name            | max_cpu | min_cpu | max_memory | min_memory | max_iops | min_iops | max_disk_size | max_session_num     |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
| 2022-08-25 15:22:14.522680 | 2022-08-25 15:22:14.522680 |              1 | sys_unit_config |       5 |     2.5 |  644245094 |  536870912 |    10000 |     5000 |    5368709120 | 9223372036854775807 |
| 2022-08-25 15:22:20.432026 | 2022-08-25 15:22:20.432026 |           1001 | test_unit       |      11 |      11 | 1503238554 | 1503238554 |      128 |      128 |    5368709120 |                  64 |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
obclient [(none)]> select * from oceanbase.__all_unit;
+----------------------------+----------------------------+---------+------------------+----------+-------+-----------+----------+---------------------+-----------------------+----------------+--------+--------------+
| gmt_create                 | gmt_modified               | unit_id | resource_pool_id | group_id | zone  | svr_ip    | svr_port | migrate_from_svr_ip | migrate_from_svr_port | manual_migrate | status | replica_type |
+----------------------------+----------------------------+---------+------------------+----------+-------+-----------+----------+---------------------+-----------------------+----------------+--------+--------------+
| 2022-08-25 15:22:14.530681 | 2022-08-25 15:22:14.530681 |       1 |                1 |        0 | zone1 | 127.0.0.1 |     2882 |                     |                     0 |              0 | ACTIVE |            0 |
| 2022-08-25 15:22:20.447571 | 2022-08-25 15:22:20.447571 |    1001 |             1001 |        0 | zone1 | 127.0.0.1 |     2882 |                     |                     0 |              0 | ACTIVE |            0 |
+----------------------------+----------------------------+---------+------------------+----------+-------+-----------+----------+---------------------+-----------------------+----------------+--------+--------------+
obclient [(none)]> select * from oceanbase.v$unit;
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
| unit_id | unit_config_id | unit_config_name | resource_pool_id | resource_pool_name | zone  | tenant_id | tenant_name | svr_ip    | svr_port | migrate_from_svr_ip | migrate_from_svr_port | max_cpu | min_cpu | max_memory | min_memory | max_iops | min_iops | max_disk_size | max_session_num     |
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
|       1 |              1 | sys_unit_config  |                1 | sys_pool           | zone1 |         1 | sys         | 127.0.0.1 |     2882 |                     |                     0 |       5 |     2.5 |  644245094 |  536870912 |    10000 |     5000 |    5368709120 | 9223372036854775807 |
|    1001 |           1001 | test_unit        |             1001 | test_pool          | zone1 |      1001 | test        | 127.0.0.1 |     2882 |                     |                     0 |      11 |      11 | 1503238554 | 1503238554 |      128 |      128 |    5368709120 |                  64 |
+---------+----------------+------------------+------------------+--------------------+-------+-----------+-------------+-----------+----------+---------------------+-----------------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+

创建unit

obclient [(none)]> create resource unit S2C1G max_cpu=2 ,min_cpu=2,max_memory='1G',min_memory='1G',max_iops=10000,min_iops=1000,max_disk_size='128G',max_session_num=2000;

创建资源池

obclient [(none)]> create resource pool test_pool unit='S2C1G',unit_num=1;

租户查询

obclient [(none)]> select * from oceanbase.__all_tenant;
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+---------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+
| gmt_create                 | gmt_modified               | tenant_id | tenant_name | replica_num | zone_list | primary_zone | locked | collation_type | info          | read_only | rewrite_merge_version | locality      | logonly_replica_num | previous_locality | storage_format_version | storage_format_work_version | default_tablegroup_id | compatibility_mode | drop_tenant_time | status               | in_recyclebin |
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+---------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+
| 2022-08-25 15:22:14.544639 | 2022-08-25 15:22:14.544639 |         1 | sys         |          -1 | zone1     | zone1        |      0 |              0 | system tenant |         0 |                     0 | FULL{1}@zone1 |                   0 |                   |                      0 |                           0 |                    -1 |                  0 |               -1 | TENANT_STATUS_NORMAL |             0 |
| 2022-08-25 15:22:22.564947 | 2022-08-25 15:22:22.564947 |      1001 | test        |          -1 | zone1     | RANDOM       |      0 |              0 |               |         0 |                     0 | FULL{1}@zone1 |                   0 |                   |                      0 |                           0 |                    -1 |                  0 |               -1 | TENANT_STATUS_NORMAL |             0 |
+----------------------------+----------------------------+-----------+-------------+-------------+-----------+--------------+--------+----------------+---------------+-----------+-----------------------+---------------+---------------------+-------------------+------------------------+-----------------------------+-----------------------+--------------------+------------------+----------------------+---------------+

创建mysql租户

obclient [(none)]> create tenant imysql resource_pool_list=('test_pool'), primary_zone='RANDOM' ,comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%',ob_compatibility_mode='mysql';

oracle租户

obclient [(none)]> create tenant ioracle resource_pool_list=('test_pool'), primary_zone='RANDOM' ,comment 'oracle tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%',ob_compatibility_mode='oracle';