首页 > 其他分享 >OceanBase创建租户

OceanBase创建租户

时间:2023-05-09 14:56:59浏览次数:54  
标签:OceanBase 创建 sys 租户 pool unit config id tenant

使用root用户连接sysy租户

使用root用户连接sys租户

[admin]# mysql -h 192.168.1.71 -P2881 -D oceanbase -uroot@sys -pOceanbase2881 -A

创建单元规格

查看已创有的资源单元规格

obclient [oceanbase]> select * from __all_unit_config;
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| gmt_create                 | gmt_modified               | unit_config_id | name            | max_cpu | min_cpu | memory_size | log_disk_size | max_iops | min_iops | iops_weight |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| 2023-04-24 18:33:06.566391 | 2023-04-24 18:33:06.566391 |              1 | sys_unit_config |       1 |       1 |  5368709120 |    5368709120 |    10000 |    10000 |           1 |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+

创建单元规格语法

CREATE RESOURCE UNIT unit_name 
MEMORY_SIZE [=] 'size_value',
MAX_CPU [=] cpu_num, 
[MAX_IOPS [=] iops_num,]
[MIN_CPU [=] cpu_num,]
[MIN_IOPS [=] iops_num,] 
[IOPS_WEIGHT [=]iopsweight,]
[LOG_DISK_SIZE [=] 'size_value'];

创建单元规格

create resource unit s1 max_cpu=1,memory_size='5G';

查看已创建的单元规格

obclient [oceanbase]> select * from __all_unit_config;
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| gmt_create                 | gmt_modified               | unit_config_id | name            | max_cpu | min_cpu | memory_size | log_disk_size | max_iops | min_iops | iops_weight |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+
| 2023-04-24 18:33:06.566391 | 2023-04-24 18:33:06.566391 |              1 | sys_unit_config |       1 |       1 |  5368709120 |    5368709120 |    10000 |    10000 |           1 |
| 2023-04-25 15:18:41.373470 | 2023-04-25 15:18:41.373470 |           1003 | s1              |       1 |       1 |  5368709120 |   16106127360 |    10000 |    10000 |           1 |
+----------------------------+----------------------------+----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+

创建资源池

创建资源池的语法

CREATE RESOURCE POOL poolname 
UNIT [=] unitname, 
UNIT_NUM [=] unitnum, 
ZONE_LIST [=] ('zone' [, 'zone' ...]);

创建资源池(需要确保节点资源充裕)

create resource pool my_pool unit='s1',unit_num=1,zone_list=('zone1','zone2','zone3');

 查看资源分配细节

obclient [oceanbase]> select t1.name resource_pool_name,t2.name unit_config_name,t2.max_cpu,t2.min_cpu,truncate(t2.memory_size/1024/1024/1024,2) memory_size_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 | memory_size_gb | unit_id | zone  | observer          | tenant_id | tenant_name |
+--------------------+------------------+---------+---------+----------------+---------+-------+-------------------+-----------+-------------+
| sys_pool           | sys_unit_config  |       1 |       1 |           5.00 |       1 | zone1 | 192.168.1.71:2882 |         1 | sys         |
| sys_pool           | sys_unit_config  |       1 |       1 |           5.00 |       2 | zone2 | 192.168.1.72:2882 |         1 | sys         |
| sys_pool           | sys_unit_config  |       1 |       1 |           5.00 |       3 | zone3 | 192.168.1.73:2882 |         1 | sys         |
| my_pool            | s1               |       1 |       1 |           5.00 |    1001 | zone1 | 192.168.1.71:2882 |      NULL | NULL        |
| my_pool            | s1               |       1 |       1 |           5.00 |    1002 | zone2 | 192.168.1.72:2882 |      NULL | NULL        |
| my_pool            | s1               |       1 |       1 |           5.00 |    1003 | zone3 | 192.168.1.73:2882 |      NULL | NULL        |
+--------------------+------------------+---------+---------+----------------+---------+-------+-------------------+-----------+-------------+

 创建租户

 创建租户的语法

CREATE TENANT [IF NOT EXISTS] tenant_name 
     [tenant_characteristic_list] [opt_set_sys_var];

tenant_characteristic_list: 
  tenant_characteristic [, tenant_characteristic...]

tenant_characteristic: 
      COMMENT 'string'  
    | {CHARACTER SET | CHARSET} [=] charsetname 
    | COLLATE [=]  collationname
    | ZONE_LIST [=] (zone [, zone...]) 
    | PRIMARY_ZONE [=] zone  
    | DEFAULT TABLEGROUP [=] {NULL | tablegroup}
    | RESOURCE_POOL_LIST [=](poolname [, poolname...])
    | LOCALITY [=] 'locality description'

opt_set_sys_var:
  {SET | SET VARIABLES | VARIABLES} system_var_name = expr [,system_var_name = expr] ...

 查看租户信息

mysql> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE | LOCALITY                     | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
|         1 | sys         | SYS         | 2023-04-24 18:33:06.821930 | 2023-05-09 09:28:07.989177 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+

创建租户

create tenant my_tenant resource_pool_list=('my_pool'),primary_zone='RANDOM',comment 'my tenant',charset='utf8' set ob_tcp_invited_nodes='%',lower_case_table_names=0;

 查看租户信息

mysql> select * from DBA_OB_TENANTS;
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
| TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME                | MODIFY_TIME                | PRIMARY_ZONE | LOCALITY                     | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+
|         1 | sys         | SYS         | 2023-04-24 18:33:06.821930 | 2023-05-09 09:28:07.989177 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1003 | META$1004   | META        | 2023-04-25 16:54:07.990306 | 2023-05-09 09:28:31.056441 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
|      1004 | my_tenant   | USER        | 2023-04-25 16:54:07.991849 | 2023-05-09 09:28:31.056441 | RANDOM       | FULL{1}@zone1, FULL{1}@zone2 | NULL              | MYSQL              | NORMAL | NO            | NO     |
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+-------------------+--------------------+--------+---------------+--------+

连接租户 

 新创建的租户(root@my_tenant)默认无密码

[admin]# mysql -h192.168.1.71 -P2883 -D oceanbase -uroot@my_tenant#ob_cluster -p -A
mysql> alter user root identified by 'OceanBase010';

 

创建租户参考:https://www.oceanbase.com/docs/common-oceanbase-database-cn-10000000001692881

 

标签:OceanBase,创建,sys,租户,pool,unit,config,id,tenant
From: https://www.cnblogs.com/haha029/p/17385007.html

相关文章

  • FreeCodeCamp-通过创建一架钢琴来学习响应式网页设计
    index.html<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"/><title>Piano</title><metaname="viewport"content="width=device-width,initial-scale=1.0&q......
  • 如何创建可引导的 ESXi USB 安装介质 (macOS, Linux, Windows)
    如何制作ESXiUSB启动盘请访问原文链接:https://sysin.org/blog/create-bootable-esxi-usb-installer/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org以下USB存储设备可以是U盘/SD卡,当然USBSSD更佳。macOSmacOS使用终端自带命令即可完成操作。查看US......
  • OceanBase集群缩容
    连接sys租户使用root用户连接sys租户的oceanbase数据库[admin]#mysql-h192.168.1.71-P2883-Doceanbase-uroot@sys-pOceanbase2881-A租户减少副本查看租户信息,sys、my_tenat租户(sys是系统租户,my_tenant是我创建的测试租户)的LOCALITY值包括:zone1、zone2、zone3mysql>s......
  • uniclound创建新项目全流程
    1、创建xxxx-node(项目服务端+H5端),此过程中需要创建云空间。2、创建xxxx-min(小程序端)3、创建xxxx-admin(后台管理端)4、更新xxxx-node中的公共依赖与函数5、修改xxxx-node common/uni-config-center/uni-id/config.json"passwordSecret":"passwordSecret-demo","token......
  • OceanBase集群扩容
    连接sys租户使用root用户连接sys租户的oceanbase数据库[admin]#mysql-h192.168.1.71-P2883-Doceanbase-uroot@sys-pOceanbase2881-A添加zone查看zone信息,当前OceanBase集群有2个zonemysql>select*fromoceanbase.dba_ob_zones;+-------+------------------------......
  • 使用IDEA创建第一个SpringBoot项目并进行一些基础配置的详细教程
    1.打开IDEA,新建newproject,填写项目信息。 2.如上图所示,设置serverURL为阿里云服务器为:https://start.aliyun.com/下面的Java版本选择必须和ProjectSDK版本相对应,不然不能进行下一步。3.选择springboot版本和开发会使用到的组件,最后点finish即可。 4.等待IDEA创建并......
  • FreeCodeCamp-创建一副毕加索绘画来学习中级 CSS
    index.html<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"><title>PicassoPainting</title><linkrel="stylesheet"href="./styles.css"/><......
  • VA21 创建报价单
    1、前台报价是提供给客户交付货物或服务的一份文件,客户想要知道产品价格以及装运时间。事务代码VA21输入报价单类型和销售组织、分销渠道、产品组输入售达方和行项目的物料信息,订购数量等信息输入条件,金额2、源代码"--------------------@斌将军--------------------D......
  • 数据库的创建、数据表的创建
     创建数据库usemaster--表示下面的操作是真的master数据库完成的go--判断当前数据库是否在master数据库中已经存在ifexists(select*fromsysdatabaseswherename='MISDB')dropdatabaseMISDBgo--创建数据库createdatabaseMISDBonprimary(name='MISDB_m......
  • BAPI_PR_CREATE-BAPI程序创建采购申请单
    FUNCTIONZPR2.DATAGS_HEADERTYPEBAPIMEREQHEADER."ME51N采购申请凭证抬头DATAGS_HEADERXTYPEBAPIMEREQHEADERX.GS_HEADER-PR_TYPE='NB'.GS_HEADERX-PR_TYPE='X'."采购凭证类型DATAGT_ITEMTYPETABLEOFBAPIMER......