首页
/
每日頭條
/
生活
/
oceanbase怎麼遷移
oceanbase怎麼遷移
更新时间:2024-09-29 00:14:22
租戶基本概念回顧

•OceanBase集群内部的資源細分;每個租 戶有自己專屬的資源池(CPU、内存)和用戶名/密碼等。

•租戶之間的數據嚴格隔離;租戶内可創建專屬的數據庫、表,執行DML等操作。

•邏輯上類似傳統數據庫的實例,但物理形式上租戶并沒有自己的專屬進程。

•使用OceanBase集群資源的第一個步驟。

OCP也可以更方便的創建租戶,為了更詳細的講解創建過程,以命令行方式講解。

•步驟一、創建“資源單元規格”,create resource unit命令,指定資源單元的規格;

•步驟二、創建“資源池”,create resource pool命令,根據資源單元規格的定義創建資源單元,并賦給一個新的資源池;

步驟三、創建租戶,create tenant命令,将資源池賦給一個新的租戶

步驟1:創建unit_config

MySQL [oceanbase]> select * from __all_unit_config\G *************************** 1. row *************************** gmt_create: 2022-01-10 18:01:41.267795 gmt_modified: 2022-01-10 18:01:41.267795 unit_config_id: 1 name: sys_unit_config max_cpu: 5 min_cpu: 2.5 max_memory: 17179869184 min_memory: 12884901888 max_iops: 10000 min_iops: 5000 max_disk_size: 179593805824 max_session_num: 9223372036854775807 1 row in set (0.007 sec) MySQL [oceanbase]> create resource unit mini max_cpu=4, min_cpu=4, max_memory='8G', min_memory='8G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='20G'; Query OK, 0 rows affected (0.081 sec) MySQL [oceanbase]> select * from __all_unit_config\G *************************** 1. row *************************** gmt_create: 2022-01-10 18:01:41.267795 gmt_modified: 2022-01-10 18:01:41.267795 unit_config_id: 1 name: sys_unit_config max_cpu: 5 min_cpu: 2.5 max_memory: 17179869184 min_memory: 12884901888 max_iops: 10000 min_iops: 5000 max_disk_size: 179593805824 max_session_num: 9223372036854775807 *************************** 2. row *************************** gmt_create: 2022-01-11 17:24:12.320207 gmt_modified: 2022-01-11 17:24:12.320207 unit_config_id: 1001 name: mini max_cpu: 4 min_cpu: 4 max_memory: 8589934592 min_memory: 8589934592 max_iops: 10000 min_iops: 1000 max_disk_size: 21474836480 max_session_num: 1000000 2 rows in set (0.001 sec)

創建租戶之前,首先我們需要定義資源規格,也就是每台OB Server到底分配一個多大的資源給租戶使用。以上為例,我們定義的資源規格是4個CPU、8G内存,CPU和内存是最重要的參數,一定要定義準确。資源規格也需要指定其他參數,包括最大及最小的IOPS、最大session數量以及磁盤空間等。

創建資源池

創建兩個資源池 CREATE RESOURCE POOL pool1 UNIT = 'mini', UNIT_NUM = 1, ZONE_LIST = ('zone1', 'zone2') ; CREATE RESOURCE POOL pool2 UNIT = 'mini', UNIT_NUM = 1, ZONE_LIST = ('zone1', 'zone2') 執行過程: MySQL [oceanbase]> CREATE RESOURCE POOL pool1 -> UNIT = 'mini', -> UNIT_NUM = 1, -> ZONE_LIST = ('zone1', 'zone2') -> ; Query OK, 0 rows affected (0.234 sec) MySQL [oceanbase]> CREATE RESOURCE POOL pool2 -> UNIT = 'mini', -> UNIT_NUM = 1, -> ZONE_LIST = ('zone1', 'zone2'); Query OK, 0 rows affected (0.193 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 | ---------------------------- ---------------------------- ------------------ ---------- ------------ ---------------- ------------- ----------- -------------- -------------------- | 2022-01-10 18:01:41.310975 | 2022-01-10 18:01:41.532239 | 1 | sys_pool | 1 | 1 | zone1;zone2 | 1 | 0 | 0 | | 2022-01-11 17:30:10.951118 | 2022-01-11 17:30:10.951118 | 1001 | pool1 | 1 | 1001 | zone1;zone2 | -1 | 0 | 0 | | 2022-01-11 17:30:53.681061 | 2022-01-11 17:30:53.681061 | 1002 | pool2 | 1 | 1001 | zone1;zone2 | -1 | 0 | 0 | ---------------------------- ---------------------------- ------------------ ---------- ------------ ---------------- ------------- ----------- -------------- -------------------- 3 rows in set (0.004 sec)

每個resource pool在每個OB Server上隻能有一個resource unit;如果unit_num大于1,每個zone内都必須有和unit_num對應數目的機器。Zone List一般與zone個數保持一緻;如果在某個zone内找不到有足夠剩餘資源的機器來創建resource unit,資源池會創建失敗。

Zone List的數量可以少于總的Zone的數量。比如一個5副本的集群,一共有5個Zone,我們也可以指定資源池為裡面的3個Zone。

創建mysql租戶

MySQL [oceanbase]> create tenant mysql_t1 charset='utf8mb4', zone_list=('zone1','zone2'), primary_zone='zone1,zone2', resource_pool_list=('pool1') set ob_tcp_invited_nodes='%'; Query OK, 0 rows affected (11.081 sec)

創建oracle租戶

MySQL [oceanbase]> create tenant oracle_t2 charset='utf8mb4', zone_list=('zone1','zone2'), primary_zone='zone1,zone2', resource_pool_list=('pool2') set ob_tcp_invited_nodes='%',ob_compatibility_mode='oracle'; Query OK, 0 rows affected (11.441 sec)

•Primary Zone:指定主副本分配到Zone内的優先級,逗号兩側優先級相同,分号左側優先級高于右側。比如zone1,zone2;zone3;

•需要指定租戶類型為MySQL還是Oracle,一旦指定無法修改,默認為mysql租戶;設置 字符集與編碼。對于 MySQL 模式,可選字符集有:utf8mb4、binary、gbk、gb18030。缺省為 utf8mb4。對于 Oracle 模式,可選字符集有:utf8mb4、gbk、gb18030。缺省為 utf8mb4。

通過ocp查看租戶信息

oceanbase怎麼遷移(OceanBase學習記錄八OB環境部署-創建租戶)1

連接mysql_t1租戶

[root@ocp obclient]# mysql -h1xxxx1 -P2883 -uroot@mysql_t1#obcluster01 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3857 Server version: 5.6.25 OceanBase 3.1.2 (r20211230114204-432323fdc2f09d06250bef6ea90e4217fd555d3c) (Built Dec 30 2021 12:27:18) 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 [(none)]> MySQL [(none)]> set password=password('rootroot'); #配置root密碼 Query OK, 0 rows affected (0.175 sec) [root@ocp obclient]# mysql -h1xxxxx1 -P2883 -uroot@mysql_t1#obcluster01 -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3921 Server version: 5.6.25 OceanBase 3.1.2 (r20211230114204-432323fdc2f09d06250bef6ea90e4217fd555d3c) (Built Dec 30 2021 12:27:18) 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 [(none)]> show databases; -------------------- | Database | -------------------- | oceanbase | | information_schema | | mysql | | test | -------------------- 4 rows in set (0.005 sec) 直連observer的租戶 [root@ocp obclient]# mysql -h1xxx.11 -uroot@mysql_t1 -P2881 -prootroot -c Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221536583 Server version: 5.7.25 OceanBase 3.1.2 (r20211230114204-432323fdc2f09d06250bef6ea90e4217fd555d3c) (Built Dec 30 2021 12:27:18) 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 [(none)]>

連接oracle租戶

[root@ocp obclient]# obclient -h1xxxx1 -P2883 -usys@oracle_t2#obcluster01 -c --prompt "\u > " Welcome to OceanBase. Commands end with ; or \g. Your OceanBase connection id is 4113 Server version: OceanBase 3.1.2 (r20211230114204-432323fdc2f09d06250bef6ea90e4217fd555d3c) (Built Dec 30 2021 12:27:18) Copyright (c) 2000, 2020, OceanBase and/or its affiliates. All rights reserved. Cannot read termcap database; using dumb terminal settings. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. SYS > alter user sys identified by oracle; #設置sys密碼 Query OK, 0 rows affected (0.19 sec) SYS > 再次連接使用sys密碼 [root@ocp obclient]# obclient -h1xxxx11 -P2883 -usys@oracle_t2#obcluster01 -c --prompt "\u > " -poracle obclient: [Warning] Using a password on the command line interface can be insecure. Welcome to OceanBase. Commands end with ; or \g. Your OceanBase connection id is 4139 Server version: OceanBase 3.1.2 (r20211230114204-432323fdc2f09d06250bef6ea90e4217fd555d3c) (Built Dec 30 2021 12:27:18) Copyright (c) 2000, 2020, OceanBase and/or its affiliates. All rights reserved. Cannot read termcap database; using dumb terminal settings. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. SYS >

密碼初始化完畢後再ocp中執行連接操作

oceanbase怎麼遷移(OceanBase學習記錄八OB環境部署-創建租戶)2

輸入sys的密碼,連接成功後可以看到租戶的密碼等

oceanbase怎麼遷移(OceanBase學習記錄八OB環境部署-創建租戶)3

點擊租戶,點擊用戶可以查看對應的登陸字符串。複制出來可以直接登陸。

oceanbase怎麼遷移(OceanBase學習記錄八OB環境部署-創建租戶)4

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
推荐阅读
荷包蛋的做法
荷包蛋的做法
荷包蛋的做法?配料:雞蛋3個、花生油20g鍋中倒入底油,油熱打入雞蛋,我來為大家科普一下關于荷包蛋的做法?下面希望有你要的答案,我們一起來看看吧!荷包蛋的做法配料:雞蛋3個、花生油20g。鍋中倒入底油,油熱打入雞蛋。将雞蛋煎至兩面金黃,出鍋...
2024-09-29
怎麼關聯qq号
怎麼關聯qq号
怎麼關聯qq号?工具/原料:QQ首先打開QQ,在消息界面點擊左上角的頭像,下面我們就來說一說關于怎麼關聯qq号?我們一起去了解并探讨一下這個問題吧!怎麼關聯qq号工具/原料:QQ首先打開QQ,在消息界面點擊左上角的頭像。然後點擊左下角的設置...
2024-09-29
羊卓雍措海拔多少米
羊卓雍措海拔多少米
羊卓雍措海拔多少米?羊卓雍措(YamdrokTso),又名羊湖雍措有的人簡稱羊湖(并非藏北的羊湖),藏語意為“碧玉湖”,是西藏三大聖湖之一,像珊瑚枝一般,因此它在藏語中又被稱為“上面的珊瑚湖”,我來為大家講解一下關于羊卓雍措海拔多少米?跟着...
2024-09-29
花葉芋的養殖方法
花葉芋的養殖方法
花葉芋的養殖方法?适宜溫度,花葉芋在溫暖的環境中利于生長,生長期需保持适宜的溫度,平時可将溫度保持在25-30度左右花葉芋的耐寒性較差,溫度長期低于15度會導緻凍害,導緻葉子發軟、發蔫冬季時做好保暖措施,移到溫暖室内養護,我來為大家科普一下...
2024-09-29
總有一首詩
總有一首詩
詠史唐高适尚有绨袍贈,應憐範叔寒。不知天下士,猶作布衣看。高适和岑參一樣,是盛唐的邊塞詩人。身為一個大詩人,他和王維一樣,做過的官也很大。曾為淮南(安徽、江蘇地區)節度使,相當于軍區司令員,讨伐過李白所在的永王李璘軍隊,平定過安史之亂餘部,...
2024-09-29
Copyright 2023-2024 - www.tftnews.com All Rights Reserved