==========================================
现供职于某上市互联网公司担任DBA
Oracle & PG ACE称号,
拥有 Oracle OCM、AWS、以及部分国产数据库等产品认证。
喜欢技术分享,热爱交友,也热爱健身。
2019年加入墨天轮,目前已发表了一百多篇原创文章,曾多次获评"月度墨力之星"。
OceanBase、PG中国分会、IvorySQL等南京地区组织者,也是TeckTalk技术交流社区创始人。
个人微信公众号: 尚雷的驿站
可微信公众号搜索 : 尚雷的驿站
==========================================
注: 会根据学到的知识进一步补充该文章内容
obd cluster tenant create obcluster -n obuser --max-cpu=1 --min-cpu=1 --max-memory=512M --min-memory=512M --mode=mysql --charset=GBK
- obcluster oceanbase集群名称
- -n 后跟租户名称
-- 创建数据库下的普通用户
obclient [oceanbase]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LBACSYS |
| mysql |
| oceanbase |
| ORAAUDITOR |
| SYS |
| test |
+--------------------+
7 rows in set (0.277 sec)
obclient [oceanbase]> use test
Database changed
-- 创建用户obuser1 并设置密码
obclient [test]> create user obuser1 identified by 'Ob#password';
Query OK, 0 rows affected (0.796 sec)
-- 通过 alter方式修改密码
obclient [test]> alter user obuser1 identified by 'ob@Password';
Query OK, 0 rows affected (0.347 sec)
-- 通过set password方式修改密码
obclient [test]> set password for obuser1=password('Ob#password');
Query OK, 0 rows affected (0.059 sec)
-- 适合在OceanBase 4.0 版本执行,企业版3下执行会提示GV$OB_SERVERS不存在
obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_SERVERS;
+--------------+----------+-------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
| SVR_IP | SVR_PORT | ZONE | SQL_PORT | CPU_CAPACITY | CPU_CAPACITY_MAX | CPU_ASSIGNED | CPU_ASSIGNED_MAX | MEM_CAPACITY | MEM_ASSIGNED | LOG_DISK_CAPACITY | LOG_DISK_ASSIGNED | LOG_DISK_IN_USE | DATA_DISK_CAPACITY | DATA_DISK_IN_USE | DATA_DISK_HEALTH_STATUS | MEMORY_LIMIT | DATA_DISK_ABNORMAL_TIME | SSL_CERT_EXPIRED_TIME |
+--------------+----------+-------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
| 10.xxx.xxx.152 | 2882 | zone1 | 2881 | 4 | 4 | 2 | 2 | 8589934592 | 8589934592 | 10737418240 | 10737418240 | 4966055936 | 10737418240 | 3380609024 | NORMAL | 10737418240 | NULL | NULL |
| 10.xxx.xxx.153 | 2882 | zone2 | 2881 | 4 | 4 | 2 | 2 | 8589934592 | 8589934592 | 10737418240 | 10737418240 | 4966055936 | 10737418240 | 3395289088 | NORMAL | 10737418240 | NULL | NULL |
| 10.xxx.xxx.154 | 2882 | zone3 | 2881 | 4 | 4 | 2 | 2 | 8589934592 | 8589934592 | 10737418240 | 10737418240 | 4966055936 | 10737418240 | 3395289088 | NORMAL | 10737418240 | NULL | NULL |
+--------------+----------+-------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+---
--适用于OceanBase 4.0社区版
obclient [oceanbase]> select * from oceanbase.DBA_OB_ZONES;
+-------+----------------------------+----------------------------+--------+-----+------------+-----------+
| ZONE | CREATE_TIME | MODIFY_TIME | STATUS | IDC | REGION | TYPE |
+-------+----------------------------+----------------------------+--------+-----+------------+-----------+
| zone1 | 2022-12-13 17:33:09.249260 | 2022-12-13 17:33:09.249260 | ACTIVE | | sys_region | ReadWrite |
| zone2 | 2022-12-13 17:33:09.249260 | 2022-12-13 17:33:09.253307 | ACTIVE | | sys_region | ReadWrite |
| zone3 | 2022-12-13 17:33:09.253307 | 2022-12-13 17:33:09.255304 | ACTIVE | | sys_region | ReadWrite |
+-------+----------------------------+----------------------------+--------+-----+------------+-----------+
3 rows in set (0.303 sec)
obclient [oceanbase]> SELECT t1.tenant_name,concat(svr_ip,":",svr_port) as "unit_server",t3.max_cpu,t3.min_cpu FROM OCEANBASE.DBA_OB_TENANTS t1,OCEANBASE.DBA_OB_UNITS t2,OCEANBASE.DBA_OB_UNIT_CONFIGS t3,OCEANBASE.DBA_OB_RESOURCE_POOLS t4
-> where t1.tenant_id = t4.tenant_id
-> AND t4.resource_pool_id=t2.resource_pool_id
-> AND t4.unit_config_id=t3.unit_config_id
-> ORDER BY t1.tenant_name;
+-------------+-------------------+---------+---------+
| tenant_name | unit_server | max_cpu | min_cpu |
+-------------+-------------------+---------+---------+
| obuser | 10.xxx.xxx.154:2882 | 1 | 1 |
| obuser | 10.xxx.xxx.153:2882 | 1 | 1 |
| obuser | 10.xxx.xxx.152:2882 | 1 | 1 |
| sys | 10.xxx.xxx.154:2882 | 1 | 1 |
| sys | 10.xxx.xxx.153:2882 | 1 | 1 |
| sys | 10.xxx.xxx.152:2882 | 1 | 1 |
+-------------+-------------------+---------+---------+
6 rows in set (0.020 sec)
复制
--适用于OceanBase 4.0社区版
obclient [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 | 10.xxx.xxx.152 | 2882 | 2881 | 1 | ACTIVE | 2022-12-13 17:32:59.396305 |
| zone2 | 10.xxx.xxx.153 | 2882 | 2881 | 0 | ACTIVE | 2022-12-13 17:32:59.192397 |
| zone3 | 10.xxx.xxx.154 | 2882 | 2881 | 0 | ACTIVE | 2022-12-13 17:32:59.920349 |
+-------+--------------+----------+------------+-----------------+--------+----------------------------+
3 rows in set (0.011 sec)
字段 | 字段描述信息 |
---|---|
tenant_name | 租户名 |
unit_server | 租户 unit 所在的 OBServer |
max_cpu | 租户 unit 允许使用的最大 CPU 核数 |
min_cpu | 租户 unit 至少可使用的 CPU 核数 |
MySQL [oceanbase]> 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 |
+----------------------------+----------------------------+----------------+----------------------------+---------+---------+-------------+-------------+----------+----------+---------------+-----------------+
| 2022-12-08 09:31:10.817056 | 2022-12-08 09:31:10.817056 | 1029 | config_sys_zone3_S1_yyi | 1.5 | 1.5 | 6442450944 | 6442450944 | 1250 | 1250 | 536870912000 | 375 |
| 2022-12-08 09:31:21.841872 | 2022-12-08 09:31:21.841872 | 1030 | config_sys_zone2_S1_gqi | 1.5 | 1.5 | 6442450944 | 6442450944 | 1250 | 1250 | 536870912000 | 375 |
| 2022-12-08 09:31:33.904568 | 2022-12-08 09:31:33.904568 | 1031 | config_sys_zone1_S1_gsr | 1.5 | 1.5 | 6442450944 | 6442450944 | 1250 | 1250 | 536870912000 | 375 |
| 2022-12-08 09:34:06.601425 | 2022-12-08 09:34:06.601425 | 1032 | config_xyz_zone2_C7G32_moi | 7 | 7 | 34359738368 | 34359738368 | 5000 | 128 | 536870912000 | 75 |
| 2022-12-08 09:34:06.604595 | 2022-12-08 09:34:06.604595 | 1033 | config_xyz_zone3_C7G32_nxr | 7 | 7 | 34359738368 | 34359738368 | 5000 | 128 | 536870912000 | 75 |
| 2022-12-08 09:34:06.606710 | 2022-12-08 09:34:06.606710 | 1034 | config_xyz_zone1_C7G32_idm | 7 | 7 | 34359738368 | 34359738368 | 5000 | 128 | 536870912000 | 75 |
+----------------------------+----------------------------+----------------+----------------------------+---------+---------+-------------+-------------+----------+----------+---------------+-----------------+
6 rows in set (0.00 sec)
obclient [oceanbase]> SHOW VARIABLES LIKE '%time%';
+---------------------------------+------------------+
| Variable_name | Value |
+---------------------------------+------------------+
| connect_timeout | 10 |
| default_password_lifetime | 0 |
| error_on_overlap_time | OFF |
| explicit_defaults_for_timestamp | ON |
| interactive_timeout | 28800 |--interactive_timeout 服务器关闭非交互连接之前等待活动秒数
| lock_wait_timeout | 31536000 |
| long_query_time | 10 |
| max_execution_time | 0 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| ob_pl_block_timeout | 3216672000000000 |
| ob_query_timeout | 10000000 |
| ob_trx_idle_timeout | 86400000000 |-- ob_trx_idle_timeout 事务超时时间
| ob_trx_lock_timeout | -1 |
| ob_trx_timeout | 86400000000 |
| system_time_zone | +08:00 |
| timestamp | 0 |
| time_format | %H:%i:%s |
| time_zone | +8:00 |
| wait_timeout | 28800 |
+---------------------------------+------------------+
20 rows in set (0.027 sec)
[root@oceanbase-db3 ~]# ntpq -p|grep -E "\*|\=|remote"
remote refid st t when poll reach delay offset jitter
==============================================================================
*obproxy-node 119.xxx.xxx.184 3 u 892 1024 377 0.237 -1.068 0.636