新建资源池命令:
CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone1');
1 新建规格和查询系统已经存在规格
CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
select * from __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 |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
| 2021-12-07 15:52:44.061255 | 2021-12-07 15:52:44.061255 | 1 | sys_unit_config | 5 | 2.5 | 1288490188 | 1073741824 | 10000 | 5000 | 53687091200 | 9223372036854775807 |
| 2021-12-07 17:38:07.657104 | 2021-12-07 17:38:07.657104 | 1001 | S4C1G | 4 | 4 | 1073741824 | 1073741824 | 10000 | 1000 | 1099511627776 | 1000000 |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+------------+------------+----------+----------+---------------+---------------------+
2 rows in set (0.007 sec)
2 新建资源池
#系统zone信息:
MySQL [oceanbase]> select * from __all_zone where name in ('region','status','zone_type');
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| gmt_create | gmt_modified | zone | name | value | info |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
| 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | region | 0 | default_region |
| 2021-12-07 15:52:44.165332 | 2021-12-07 15:52:44.165332 | zone1 | status | 2 | ACTIVE |
| 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | zone_type | 0 | ReadWrite |
| 2021-12-07 15:55:42.470481 | 2021-12-07 15:55:42.470481 | zone2 | region | 0 | default_region |
| 2021-12-07 15:55:42.469251 | 2021-12-07 15:55:50.268682 | zone2 | status | 2 | ACTIVE |
| 2021-12-07 15:55:42.471541 | 2021-12-07 15:55:42.471541 | zone2 | zone_type | 0 | LOCAL |
| 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | region | 0 | default_region |
| 2021-12-07 15:55:46.553067 | 2021-12-07 15:55:52.991332 | zone3 | status | 2 | ACTIVE |
| 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | zone_type | 0 | LOCAL |
| 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | region | 0 | default_region |
| 2021-12-08 12:11:09.490896 | 2021-12-08 12:11:16.640717 | zone4 | status | 2 | ACTIVE |
| 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | zone_type | 0 | LOCAL |
| 2021-12-08 12:14:51.462014 | 2021-12-08 12:14:51.462014 | zone5 | region | 0 | default_region |
| 2021-12-08 12:14:51.459875 | 2021-12-08 12:14:58.415404 | zone5 | status | 2 | ACTIVE |
| 2021-12-08 12:14:51.462014 | 2021-12-08 12:14:51.462014 | zone5 | zone_type | 0 | LOCAL |
+----------------------------+----------------------------+-------+-----------+-------+----------------+
15 rows in set (0.001 sec)
#系统已经存在资源池
select * from __all_resource_pool ;
+----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+
| gmt_create | gmt_modified | resource_pool_id | name | unit_count | unit_config_id | zone_list | tenant_id | replica_type | is_tenant_sys_pool |
+----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+
| 2021-12-07 15:52:44.063479 | 2021-12-07 16:11:07.047749 | 1 | sys_pool | 1 | 1 | zone1;zone2;zone3 | 1 | 0 | 0 |
| 2021-12-08 08:37:32.810127 | 2021-12-08 08:37:56.027919 | 1001 | pool1 | 1 | 1001 | zone1;zone2;zone3 | 1001 | 0 | 0 |
+----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+
2 rows in set (0.008 sec)
#UNIT_NUM指定 Zone 下的单元个数,不能大于zone下的observer数量。
#zone_list不指定,默认为所有的zone(__all_zone).
#由于zone5下面没有observer服务,所以新建资源池失败。
#新建资源池失败
MySQL [oceanbase]> CREATE RESOURCE POOL pool3
-> UNIT = 'S4C1G',
-> UNIT_NUM = 1;
ERROR 4656 (HY000): resource pool unit num is bigger than zone server count
MySQL [oceanbase]>
#系统zone信息: MySQL [oceanbase]> select * from __all_zone where name in ('region','status','zone_type'); +----------------------------+----------------------------+-------+-----------+-------+----------------+ | gmt_create | gmt_modified | zone | name | value | info | +----------------------------+----------------------------+-------+-----------+-------+----------------+ | 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | region | 0 | default_region | | 2021-12-07 15:52:44.165332 | 2021-12-07 15:52:44.165332 | zone1 | status | 2 | ACTIVE | | 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | zone_type | 0 | ReadWrite | | 2021-12-07 15:55:42.470481 | 2021-12-07 15:55:42.470481 | zone2 | region | 0 | default_region | | 2021-12-07 15:55:42.469251 | 2021-12-07 15:55:50.268682 | zone2 | status | 2 | ACTIVE | | 2021-12-07 15:55:42.471541 | 2021-12-07 15:55:42.471541 | zone2 | zone_type | 0 | LOCAL | | 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | region | 0 | default_region | | 2021-12-07 15:55:46.553067 | 2021-12-07 15:55:52.991332 | zone3 | status | 2 | ACTIVE | | 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | zone_type | 0 | LOCAL | | 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | region | 0 | default_region | | 2021-12-08 12:11:09.490896 | 2021-12-08 12:11:16.640717 | zone4 | status | 2 | ACTIVE | | 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | zone_type | 0 | LOCAL | | 2021-12-08 12:14:51.462014 | 2021-12-08 12:14:51.462014 | zone5 | region | 0 | default_region | | 2021-12-08 12:14:51.459875 | 2021-12-08 12:14:58.415404 | zone5 | status | 2 | ACTIVE | | 2021-12-08 12:14:51.462014 | 2021-12-08 12:14:51.462014 | zone5 | zone_type | 0 | LOCAL | +----------------------------+----------------------------+-------+-----------+-------+----------------+ 15 rows in set (0.001 sec) #系统已经存在资源池 select * from __all_resource_pool ; +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+ | gmt_create | gmt_modified | resource_pool_id | name | unit_count | unit_config_id | zone_list | tenant_id | replica_type | is_tenant_sys_pool | +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+ | 2021-12-07 15:52:44.063479 | 2021-12-07 16:11:07.047749 | 1 | sys_pool | 1 | 1 | zone1;zone2;zone3 | 1 | 0 | 0 | | 2021-12-08 08:37:32.810127 | 2021-12-08 08:37:56.027919 | 1001 | pool1 | 1 | 1001 | zone1;zone2;zone3 | 1001 | 0 | 0 | +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------+-----------+--------------+--------------------+ 2 rows in set (0.008 sec)
#UNIT_NUM指定 Zone 下的单元个数,不能大于zone下的observer数量。
#zone_list不指定,默认为所有的zone(__all_zone).
#由于zone5下面没有observer服务,所以新建资源池失败。
#新建资源池失败 MySQL [oceanbase]> CREATE RESOURCE POOL pool3 -> UNIT = 'S4C1G', -> UNIT_NUM = 1; ERROR 4656 (HY000): resource pool unit num is bigger than zone server count MySQL [oceanbase]>
删除zone5
MySQL [oceanbase]> alter system stop zone 'zone5'; Query OK, 0 rows affected (0.009 sec) MySQL [oceanbase]> ALTER SYSTEM DELETE ZONE 'zone5'; Query OK, 0 rows affected (0.004 sec) MySQL [oceanbase]> select * from __all_zone where name in ('region','status','zone_type'); +----------------------------+----------------------------+-------+-----------+-------+----------------+ | gmt_create | gmt_modified | zone | name | value | info | +----------------------------+----------------------------+-------+-----------+-------+----------------+ | 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | region | 0 | default_region | | 2021-12-07 15:52:44.165332 | 2021-12-07 15:52:44.165332 | zone1 | status | 2 | ACTIVE | | 2021-12-07 15:52:44.166392 | 2021-12-07 15:52:44.166392 | zone1 | zone_type | 0 | ReadWrite | | 2021-12-07 15:55:42.470481 | 2021-12-07 15:55:42.470481 | zone2 | region | 0 | default_region | | 2021-12-07 15:55:42.469251 | 2021-12-07 15:55:50.268682 | zone2 | status | 2 | ACTIVE | | 2021-12-07 15:55:42.471541 | 2021-12-07 15:55:42.471541 | zone2 | zone_type | 0 | LOCAL | | 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | region | 0 | default_region | | 2021-12-07 15:55:46.553067 | 2021-12-07 15:55:52.991332 | zone3 | status | 2 | ACTIVE | | 2021-12-07 15:55:46.555209 | 2021-12-07 15:55:46.555209 | zone3 | zone_type | 0 | LOCAL | | 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | region | 0 | default_region | | 2021-12-08 12:11:09.490896 | 2021-12-08 12:11:16.640717 | zone4 | status | 2 | ACTIVE | | 2021-12-08 12:11:09.493083 | 2021-12-08 12:11:09.493083 | zone4 | zone_type | 0 | LOCAL | +----------------------------+----------------------------+-------+-----------+-------+----------------+ 12 rows in set (0.001 sec)
新建资源池:
MySQL [oceanbase]> CREATE RESOURCE POOL pool3 -> UNIT = 'S4C1G', -> UNIT_NUM = 1; Query OK, 0 rows affected (0.021 sec) MySQL [oceanbase]> select * from __all_resource_pool ; +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------------+-----------+--------------+--------------------+ | gmt_create | gmt_modified | resource_pool_id | name | unit_count | unit_config_id | zone_list | tenant_id | replica_type | is_tenant_sys_pool | +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------------+-----------+--------------+--------------------+ | 2021-12-07 15:52:44.063479 | 2021-12-07 16:11:07.047749 | 1 | sys_pool | 1 | 1 | zone1;zone2;zone3 | 1 | 0 | 0 | | 2021-12-08 08:37:32.810127 | 2021-12-08 08:37:56.027919 | 1001 | pool1 | 1 | 1001 | zone1;zone2;zone3 | 1001 | 0 | 0 | | 2021-12-08 12:33:01.724857 | 2021-12-08 12:33:01.724857 | 1005 | pool3 | 1 | 1001 | zone1;zone2;zone3;zone4 | -1 | 0 | 0 | +----------------------------+----------------------------+------------------+----------+------------+----------------+-------------------------+-----------+--------------+--------------------+ 3 rows in set (0.004 sec)
3 unit,unit_num未必选参数,否则失败
MySQL [oceanbase]> CREATE RESOURCE POOL pool3;
ERROR 1210 (HY000): Miss argument for unit
MySQL [oceanbase]> CREATE RESOURCE POOL pool3 UNIT = 'S4C1G';
ERROR 1210 (HY000): Miss argument for unit_num
MySQL [oceanbase]> CREATE RESOURCE POOL pool3 UNIT = 'S4C1G',UNIT_NUM = 1;
Query OK, 0 rows affected (0.023 sec)
4 测试结果
1,新建资源池,未指定zone_list参数,默认使用所有已经存在的zone。
2,UNIT_NUM
指定要创建的单个 Zone 下的 Unit 个数。
每个单元会根据当前集群负载,自动在每个 Zone 中选择一个 Server 负载,但同一个资源池的多个 Unit 不能分配到同一个 Server,即一个资源池包含的Unit 个数不能超过单 Zone 内 Server 的个数。
1,新建资源池,未指定zone_list参数,默认使用所有已经存在的zone。
2,UNIT_NUM
指定要创建的单个 Zone 下的 Unit 个数。
每个单元会根据当前集群负载,自动在每个 Zone 中选择一个 Server 负载,但同一个资源池的多个 Unit 不能分配到同一个 Server,即一个资源池包含的Unit 个数不能超过单 Zone 内 Server 的个数。