一步一步学习OceanBase系列回顾:
第一篇:OceanBase 1.4 集群手动安装步骤
第二篇:obproxy的安装、配置和使用
本篇是第三篇 ob1.4集群,MySQL租户的创建和使用
由于之前以最小服务器资源4cpu+16g搭建的ob1.4集群,cpu资源不足无法创建租户,因此重新搭建了一个8cpu+16g的ob1.4集群。
在此资源下,进行ob集群租户的实操体验。
oceanbase 1.4集群环境,创建MySQL租户
概念:
租户是OB集群资源的子集,是逻辑概念,等同于实例。
OB集群下,可以创建多个不同的租户,租户与租户之间是隔离的资源,OB 2.x支持MySQL和Oracle两种兼容模式的租户。
租户创建流程:定义资源单元规格 -> 创建资源池->创建租户
以下是实操:
1.通过obproxy连接ob集群,查看OceanBase集群可用资源情况。
$ mysql -h192.168.0.151 -uroot@sys#obdemo -P2883 -padmin123 -c -A oceanbase
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.25 OceanBase 1.4.60 (r1571952-758a58e85846f9efb907b1c14057204cb6353846) (Built Mar 9 2018 14:32:07)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]>
查看OB集群所有节点信息
MySQL [oceanbase]> select zone,svr_ip,svr_port,inner_port,with_rootserver,status,gmt_create from __all_server order by zone, svr_ip;
+-------+---------------+----------+------------+-----------------+--------+----------------------------+
| zone | svr_ip | svr_port | inner_port | with_rootserver | status | gmt_create |
+-------+---------------+----------+------------+-----------------+--------+----------------------------+
| zone1 | 192.168.0.151 | 2882 | 2881 | 1 | active | 2020-08-07 11:30:28.623847 |
| zone2 | 192.168.0.43 | 2882 | 2881 | 0 | active | 2020-08-07 11:30:28.604907 |
| zone3 | 192.168.0.41 | 2882 | 2881 | 0 | active | 2020-08-07 11:30:28.613459 |
+-------+---------------+----------+------------+-----------------+--------+----------------------------+
3 rows in set (0.01 sec)
MySQL [oceanbase]>
查看OceanBase集群可用资源情况。
MySQL [oceanbase]> select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free,
-> round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb,
-> round(disk_total/1024/1024/1024) disk_total_gb,
-> substr(a.build_version,1,6) version,usec_to_time(b.start_service_time) start_service_time
-> from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
-> order by a.zone, a.svr_ip;
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
| zone | observer | cpu_total | cpu_free | mem_total_gb | mem_free_gb | disk_total_gb | version | start_service_time |
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
| zone1 | 192.168.0.151:2882 | 6 | 3.5 | 10 | 7 | 83 | 1.4.60 | 2020-08-07 11:30:35.152342 |
| zone2 | 192.168.0.43:2882 | 6 | 3.5 | 10 | 7 | 83 | 1.4.60 | 2020-08-07 11:30:31.722452 |
| zone3 | 192.168.0.41:2882 | 6 | 3.5 | 10 | 7 | 83 | 1.4.60 | 2020-08-07 11:30:32.381524 |
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
3 rows in set (0.00 sec)
MySQL [oceanbase]> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu,
-> round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb,
-> t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
-> from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
-> join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
-> left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
-> order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
-> ;
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| 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 | 3 | 2 | 1 | zone1 | 192.168.0.151:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 2 | zone2 | 192.168.0.43:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 3 | zone3 | 192.168.0.41:2882 | 1 | sys |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
3 rows in set (0.00 sec)
MySQL [oceanbase]>
由上面可以看出,oceanbase默认sys租户使用了2.5-5个CPU,2-3G内存。大概还可以分配 3.5个CPU,7G内存。
2.创建租户资源池
(1).先创建资源单元规格
这里创建一个my_unit_1c2g的资源unit
MySQL [oceanbase]> create resource unit my_unit_1c2g max_cpu=2, min_cpu=1, max_memory='3g', min_memory='2g', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='10g';
Query OK, 0 rows affected (0.00 sec)
--如果要修改上面规格用下面sql
--alter resource unit my_unit_1c2g max_cpu=5, min_cpu=2, max_memory='5G', min_memory='2G';
查看创建的资源单元
MySQL [oceanbase]> select unit_config_id,name,max_cpu,min_cpu,round(max_memory/1024/1024/1024) max_mem_gb, round(min_memory/1024/1024/1024) min_mem_gb, round(max_disk_size/1024/1024/1024) max_disk_size_gb
-> from __all_unit_config
-> order by unit_config_id;
+----------------+-----------------+---------+---------+------------+------------+------------------+
| 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 | 3 | 2 | 83 |
| 1001 | my_unit_1c2g | 2 | 1 | 3 | 2 | 10 |
+----------------+-----------------+---------+---------+------------+------------+------------------+
2 rows in set (0.01 sec)
MySQL [oceanbase]>
(2).创建资源池(关键)。
这里创建一个my_pool_test的资源池,分配1个my_unit_1c2g资源unit
如果资源定义不合理,这里可能分配不出来,就会报错ERROR 4624 (HY000): machine resource is not enough to hold a new unit。
MySQL [oceanbase]> create resource pool my_pool_test unit = 'my_unit_1c2g', unit_num = 1;
Query OK, 0 rows affected (0.01 sec)
MySQL [oceanbase]>
查看资源池,这里看到新创建的资源池my_pool_test还未归属租户
MySQL [oceanbase]> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu,
-> round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb,
-> t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
-> from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
-> join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
-> left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
-> order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
-> ;
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
| 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 | 3 | 2 | 1 | zone1 | 192.168.0.151:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 2 | zone2 | 192.168.0.43:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 3 | zone3 | 192.168.0.41:2882 | 1 | sys |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1001 | zone1 | 192.168.0.151:2882 | NULL | NULL |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1002 | zone2 | 192.168.0.43:2882 | NULL | NULL |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1003 | zone3 | 192.168.0.41:2882 | NULL | NULL |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+-------------+
6 rows in set (0.00 sec)
MySQL [oceanbase]>
3.创建租户
MySQL [oceanbase]> create tenant my_test_tent resource_pool_list=('my_pool_test');
Query OK, 0 rows affected (0.06 sec)
MySQL [oceanbase]> select tenant_id, tenant_name, zone_list, locality ,gmt_modified from __all_tenant;
+-----------+--------------+-------------------+---------------------------------------------+----------------------------+
| tenant_id | tenant_name | zone_list | locality | gmt_modified |
+-----------+--------------+-------------------+---------------------------------------------+----------------------------+
| 1 | sys | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | 2020-08-07 11:30:29.946393 |
| 1001 | my_test_tent | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | 2020-08-07 14:00:48.039985 |
+-----------+--------------+-------------------+---------------------------------------------+----------------------------+
2 rows in set (0.00 sec)
MySQL [oceanbase]>
OceanBase 2.x 支持oracle租户,创建oracle租户:
create tenant my_ora_tent resource_pool_list=('my_pool_test'), primary_zone='RANDOM',comment 'oracle tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='oracle';
创建租户的时候指定了租户使用的资源池、数据分布策略(primary_zone为RANDOM)、租户字符集(默认utf8,也可以改为gbk)、租户访问白名单(ob_tcp_invited_nodes)、租户兼容级别(ob_compatibility_mode)。
4.再次检查租户资源分配细节
MySQL [oceanbase]> select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free,
-> round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb,
-> round(disk_total/1024/1024/1024) disk_total_gb,
-> substr(a.build_version,1,6) version,usec_to_time(b.start_service_time) start_service_time
-> from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
-> order by a.zone, a.svr_ip;
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
| zone | observer | cpu_total | cpu_free | mem_total_gb | mem_free_gb | disk_total_gb | version | start_service_time |
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
| zone1 | 192.168.0.151:2882 | 6 | 2.5 | 10 | 5 | 83 | 1.4.60 | 2020-08-07 11:30:35.152342 |
| zone2 | 192.168.0.43:2882 | 6 | 2.5 | 10 | 5 | 83 | 1.4.60 | 2020-08-07 11:30:31.722452 |
| zone3 | 192.168.0.41:2882 | 6 | 2.5 | 10 | 5 | 83 | 1.4.60 | 2020-08-07 11:30:32.381524 |
+-------+--------------------+-----------+----------+--------------+-------------+---------------+---------+----------------------------+
3 rows in set (0.00 sec)
MySQL [oceanbase]> select t1.name resource_pool_name, t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu,
-> round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb,
-> t3.unit_id, t3.zone, concat(t3.svr_ip,':',t3.`svr_port`) observer,t4.tenant_id, t4.tenant_name
-> from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
-> join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
-> left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
-> order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
-> ;
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+--------------+
| 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 | 3 | 2 | 1 | zone1 | 192.168.0.151:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 2 | zone2 | 192.168.0.43:2882 | 1 | sys |
| sys_pool | sys_unit_config | 5 | 2.5 | 3 | 2 | 3 | zone3 | 192.168.0.41:2882 | 1 | sys |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1001 | zone1 | 192.168.0.151:2882 | 1001 | my_test_tent |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1002 | zone2 | 192.168.0.43:2882 | 1001 | my_test_tent |
| my_pool_test | my_unit_1c2g | 2 | 1 | 3 | 2 | 1003 | zone3 | 192.168.0.41:2882 | 1001 | my_test_tent |
+--------------------+------------------+---------+---------+------------+------------+---------+-------+--------------------+-----------+--------------+
6 rows in set (0.00 sec)
MySQL [oceanbase]>
可以看到,整个ob集群资源池,还可用2.5cpu, 5g内存。
5.登录新租户,创建业务数据库和用户
登录新租户my_test_tent,修改新租户my_test_tent下root用户密码,默认为空,创建业务数据库,创建业务用户等。
$ mysql -h192.168.0.151 -uroot@my_test_tent#obdemo -P2883 oceanbase -A -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.25 OceanBase 1.4.60 (r1571952-758a58e85846f9efb907b1c14057204cb6353846) (Built Mar 9 2018 14:32:07)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]> show databases;
+--------------------+
| Database |
+--------------------+
| oceanbase |
| information_schema |
| mysql |
| test |
+--------------------+
4 rows in set (0.01 sec)
MySQL [oceanbase]> alter user root identified by 'admin123';
Query OK, 0 rows affected (0.02 sec)
MySQL [oceanbase]>
MySQL [oceanbase]> create database testdb;
Query OK, 1 row affected (0.02 sec)
MySQL [oceanbase]> grant all privileges on testdb.* to aps2@'%' identified by 'aps2#12345';
Query OK, 0 rows affected, 1 warning (0.03 sec)
MySQL [oceanbase]> show grants for aps2;
+----------------------------------------------+
| Grants for aps2 |
+----------------------------------------------+
| GRANT USAGE ON *.* TO 'aps2' |
| GRANT ALL PRIVILEGES ON `testdb`.* TO 'aps2' |
+----------------------------------------------+
2 rows in set (0.01 sec)
MySQL [oceanbase]>
MySQL [oceanbase]> exit
Bye
$
6.登录新租户下,使用新用户,连接新业务数据库,创建表等
$ mysql -h192.168.0.151 -uaps2@my_test_tent#obdemo -P2883 -paps2#12345 -c -A testdb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.6.25 OceanBase 1.4.60 (r1571952-758a58e85846f9efb907b1c14057204cb6353846) (Built Mar 9 2018 14:32:07)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [testdb]>
创建一个非分区表test
MySQL [testdb]> create table test(id int,name varchar(20),age int,dt datetime);
Query OK, 0 rows affected (0.05 sec)
MySQL [testdb]> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| test |
+------------------+
1 row in set (0.01 sec)
MySQL [testdb]> desc test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| dt | datetime | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
MySQL [testdb]> insert into test values(1,'ob1.4.6',20,now());
Query OK, 1 row affected (0.07 sec)
MySQL [testdb]>
MySQL [testdb]> insert into test values(2,'张三',26,'1998-06-17');
Query OK, 1 row affected (0.00 sec)
MySQL [testdb]> insert into test values(3,'李四',32,'1989-10-13');
Query OK, 1 row affected (0.00 sec)
MySQL [testdb]> insert into test values(4,'Tom',30,'1990-02-21');
Query OK, 1 row affected (0.00 sec)
MySQL [testdb]>
MySQL [testdb]> select * from test;
+------+---------+------+---------------------+
| id | name | age | dt |
+------+---------+------+---------------------+
| 1 | ob1.4.6 | 20 | 2020-08-07 14:05:40 |
| 2 | 张三 | 26 | 1998-06-17 00:00:00 |
| 3 | 李四 | 32 | 1989-10-13 00:00:00 |
| 4 | Tom | 30 | 1990-02-21 00:00:00 |
+------+---------+------+---------------------+
4 rows in set (0.01 sec)
MySQL [testdb]>
创建一个hash分区表
MySQL [testdb]> create table test_hash(id int not null,name varchar(20) not null,age int,dt datetime default now())
-> partition by hash(id)
-> partitions 3;
Query OK, 0 rows affected (0.05 sec)
MySQL [testdb]> desc test_hash;
+-------+-------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+-------------------+-------+
| id | int(11) | NO | | NULL | |
| name | varchar(20) | NO | | NULL | |
| age | int(11) | YES | | NULL | |
| dt | datetime | YES | | CURRENT_TIMESTAMP | |
+-------+-------------+------+-----+-------------------+-------+
4 rows in set (0.00 sec)
MySQL [testdb]>
MySQL [testdb]> insert into test_hash values(1,'张三',26,'1998-06-17');
Query OK, 1 row affected (0.01 sec)
MySQL [testdb]> insert into test_hash values(2,'李四',32,'1989-10-13');
Query OK, 1 row affected (0.00 sec)
MySQL [testdb]> insert into test_hash values(3,'Tom',30,'1990-02-21');
Query OK, 1 row affected (0.00 sec)
MySQL [testdb]> select * from test_hash;
+----+--------+------+---------------------+
| id | name | age | dt |
+----+--------+------+---------------------+
| 3 | Tom | 30 | 1990-02-21 00:00:00 |
| 1 | 张三 | 26 | 1998-06-17 00:00:00 |
| 2 | 李四 | 32 | 1989-10-13 00:00:00 |
+----+--------+------+---------------------+
3 rows in set (0.02 sec)
MySQL [testdb]>
MySQL [testdb]> exit
Bye
$
7、查看租户下的表分区主副本和备副本所在的节点。
如下sql: 其中role=1为主副本,role=2为备副本
$ mysql -h192.168.0.151 -uroot@my_test_tent#obdemo -P2883 -padmin123 -c -A oceanbase
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1048584
Server version: 5.6.25 OceanBase 1.4.60 (r1571952-758a58e85846f9efb907b1c14057204cb6353846) (Built Mar 9 2018 14:32:07)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [oceanbase]> SELECT t1.tenant_id,t1.tenant_name,t2.database_name,t3.table_id,t3.table_Name,t3.tablegroup_id,t3.part_num,t4.partition_Id,
-> t4.zone,t4.svr_ip,t4.role, round(t4.data_size/1024/1024) data_size_mb
-> from `gv$tenant` t1
-> join `gv$database` t2 on (t1.tenant_id = t2.tenant_id)
-> join gv$table t3 on (t2.tenant_id = t3.tenant_id and t2.database_id = t3.database_id and t3.index_type = 0)
-> left join `gv$partition` t4 on (t2.tenant_id = t4.tenant_id and ( t3.table_id = t4.table_id or t3.tablegroup_id = t4.table_id ) and t4.role in (1,2))
-> where t1.tenant_id = 1001
-> order by t3.tablegroup_id, t3.table_name,t4.partition_Id ;
+-----------+--------------+---------------+------------------+------------+---------------+----------+--------------+-------+---------------+------+--------------+
| tenant_id | tenant_name | database_name | table_id | table_Name | tablegroup_id | part_num | partition_Id | zone | svr_ip | role | data_size_mb |
+-----------+--------------+---------------+------------------+------------+---------------+----------+--------------+-------+---------------+------+--------------+
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone2 | 192.168.0.43 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone3 | 192.168.0.41 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone1 | 192.168.0.151 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone2 | 192.168.0.43 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone3 | 192.168.0.41 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone1 | 192.168.0.151 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone2 | 192.168.0.43 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone3 | 192.168.0.41 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone1 | 192.168.0.151 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone2 | 192.168.0.43 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone3 | 192.168.0.41 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone1 | 192.168.0.151 | 1 | 0 |
+-----------+--------------+---------------+------------------+------------+---------------+----------+--------------+-------+---------------+------+--------------+
12 rows in set (0.05 sec)
MySQL [oceanbase]>
my_test_tent租户下的testdb库有一张非分区表test,一个hash分区表test_hash。
从以上可以看到,非分区表test,只有一个p0号分区,主副本在zone1下的151节点。test_hash分区表的p0-p2三个分区的主副本也都在zone1下的151节点。
在Oceanbase里,是以分区为最小单元进行数据同步的。
OceanBase里,每个数据有三份,每个具体的分区也有三份,分布在不同的Zone里的不同节点上。每个分区有三份副本,副本内容相同,角色上有区分,是1个leader副本和2个follower副本。
• 非分区表只有一个分区,分区表有多个分区。
• 分区在Unit内部分配,可以在同租户同Zone的不同Unit之间迁移,是数据迁移的最小粒度
• 每个分区有三副本(Replica),分布在不同Zone里的Unit里。
• 三副本:1个Leader副本(默认提供读写),2个Follower副本(默认不提供服务)
8、最后以图形式,展示租户的分配和表分区数据的分布如下图:
(1)、租户的创建,资源的分配:
(2)业务租户下表分区的分布情况:
本次oceanbase租户使用体验,到此结束。 一步一步学习OceanBase系列 下一篇准备进行oceanbase可扩展体验——集群扩容。。 下次实操继续更新~~~~~
最后修改时间:2020-08-09 17:04:30
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。