首页
/
每日頭條
/
生活
/
oceanbase怎麼遷移
oceanbase怎麼遷移
更新时间:2026-03-18 10:30:15
租戶基本概念回顧

•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
推荐阅读
實木家具怎麼挑選最好的
實木家具怎麼挑選最好的
木作:一個家具選購路上,讓人又愛又恨的東西。本來是追求一種純粹,溫暖,自然的木頭質感。卻被無數的無良商家利用。實木家具裡面,到底有多少坑?我們先從實木家具的分類說起。凡是木頭,都能叫實木家具。1.指接闆箭頭指向的就是指接木的兩塊木頭相結合的...
2026-03-18
應收賬款周轉次數計算公式
應收賬款周轉次數計算公式
應收賬款周轉次數計算公式?應收賬款周轉天數的算法,可以有好幾種:,接下來我們就來聊聊關于應收賬款周轉次數計算公式?以下内容大家不妨參考一二希望能幫到您!應收賬款周轉次數計算公式應收賬款周轉天數的算法,可以有好幾種:一是将應收賬款的期末餘額除...
2026-03-18
夢幻西遊什麼葫蘆必開
夢幻西遊什麼葫蘆必開
遊戲的意義就在于它能夠給人帶來快樂,如果過多的摻雜其他的東西就失去了其本身的意義,大家好,我是小三,每天給大家分享遊戲中的八卦趣事。以前的時候,物理系門派的玩家都感覺不公平,因為怪物一般都會擁有着高級反震,但是高級反正隻會反擊物理傷害,并不...
2026-03-18
淺淺的時光遙遙的遠方
淺淺的時光遙遙的遠方
時光匆匆的腳步,四季更叠的美景,我們,一直在路上。立德樹人不曾停歇,追夢前行不知疲倦。躬耕教壇,情牽學生,通濟實驗人不忘教書育人初心,牢記立德樹人使命。通濟實驗校園,每一天都在悄然生長;通濟實驗師生,每一天都有精彩呈現。在學校一年又一年的發...
2026-03-18
可以從面相判斷一個人的性格
可以從面相判斷一個人的性格
1.孩子學習什麼都會收到環境的影響,作為家長,我們要言傳身教。所以我決定在孩子暑假的這兩個月,我們每人各帶一個月,分别将自己拿手的東西交給兒子。兩個月過去了。兒子跟着媽媽學會了打麻将,跟着爸爸學會了吐煙圈。虎父無犬子啊!2.老夫妻正在為兒子...
2026-03-18
Copyright 2023-2026 - www.tftnews.com All Rights Reserved