共计 18463 个字符,预计需要花费 47 分钟才能阅读完成。
背景
测试 OceanBase 比照 MySQL,TiDB 的性能体现,数据存储压缩,摸索多点外部我的项目一个数据库场景落地 Oceanbase(MySQL->OceanBase)。
单机测试
筹备
OBD 形式部署单机
文件筹备
wget https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/7/x86_64/oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz?Expires=1681878350&OSSAccessKeyId=LTAI5tGVLeRRycCRGerZJMNC&Signature=4E8%2FW77U1MAqq1ttNvuljadkTq0%3D
mv oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz?Expires=1681878350 oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz
tar -zxf oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz -C /usr/local
装置相干包
/usr/local/oceanbase-all-in-one/bin/install.sh
.......
#####################################################################
Install Finished
=====================================================================
Setup Environment: source ~/.oceanbase-all-in-one/bin/env.sh
Start Web Service: obd web
Quick Start: obd demo
More Details: obd -h
=====================================================================
批改配置文件
蕴含组件:oceanbase-ce、obproxy-ce、obagent、grafana、Prometheus
cp /usr/local/oceanbase-all-in-one/obd/usr/obd/example/all-components.yaml ./
vi all-components.yaml
- memory_limit 64G observer 总内存(租户内存 + 零碎内存)
- system_memory 30G 零碎内存
- datafile_size 1500G 数据文件大小(启动就会预调配)
- log_disk_size 日志文件大小(启动就会预调配)
# all-components.yaml
oceanbase-ce:
servers:
- name: server1
ip: 127.0.0.1
global:
devname: lo
memory_limit: 64G # The maximum running memory for an observer
system_memory: 30G
datafile_size: 1500G # Size of the data file.
log_disk_size: 800G # The size of disk space used by the clog files.
.......
server1:
........
zone: zone1
obproxy-ce:
depends:
- oceanbase-ce
servers:
- 127.0.0.1
global:
......
obagent:
depends:
- oceanbase-ce
servers:
- name: server1
ip: 127.0.0.1
global:
home_path: /data/obagent1
ocp-express:
depends:
- oceanbase-ce
- obproxy-ce
- obagent
servers:
- 127.0.0.1
global:
.....
部署启动
obd cluster deploy obtest -c all-components.yaml
+--------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+------------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.1.0.0 | 100000192023032010.el7 | 8439ecf8db5e0649bd49671b41ea9e8c85756b63 |
| obproxy-ce | 4.1.0.0 | 7.el7 | 2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe |
| obagent | 1.3.0 | 22.el7 | d57fbb4962b2fbecb6282358c59295fdfba4d6ac |
| ocp-express | 1.0.0 | 100000432023032015.el7 | 42c6fc921063f24f9e1072d75bfa7f21f42146e3 |
+--------------+---------+------------------------+------------------------------------------+
------
obd cluster start obtest
...
+---------------------------------------------+
| observer |
+-----------+---------+------+-------+--------+
| ip | version | port | zone | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.1.0.0 | 4000 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P4000 -uroot -Doceanbase -A
+---------------------------------------------+
| obproxy |
+-----------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884 | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
+------------------------------------------------------------------+
| obagent |
+---------------+--------------------+--------------------+--------+
| ip | mgragent_http_port | monagent_http_port | status |
+---------------+--------------------+--------------------+--------+
| 10.xxxx | 8089 | 8088 | active |
+---------------+--------------------+--------------------+--------+
+------------------------------------------------------------------+
| ocp-express |
+---------------------------+----------+------------------+--------+
| url | username | default_password | status |
+---------------------------+----------+------------------+--------+
| http://10.xxxx:8180 | admin | oceanbase | active |
+---------------------------+----------+------------------+--------+
创立 MySQL 用户
create resource unit ut1 max_cpu 32,memory_size '16G';
create resource pool p1 unit 'ut1',unit_num 1;
create tenant mysql resource_pool_list=('p1') set ob_tcp_invited_nodes='%';
重要配置
OceanBase | TiDB | MySQL | ||
---|---|---|---|---|
社区 版本 |
v4.1.0 | v6.1.5 | v5.7.16 | |
内存 配置 |
租户 memory_size 16G |
block_cache_size 16G | innodb_buffer_pool_size 16G | |
单机器 配置 |
32C RAID10 SSD | 32C RAID10 SSD | 32C RAID10 SSD | |
刷盘 配置 |
默认强制刷盘 (无刷盘相干配置参数) |
sync-log=1 | sync_binlog=1 | innodb_flush_log_at_trx_commit=2 |
并发数 | 5,10,20,30,60,120 | 5,10,20,30,60,120 | 5,10,20,30,60,120 | |
测试 模式 |
read_write,read_only,write_only | read_write,read_only,write_only | read_write,read_only,write_only | |
单次测试 工夫 |
300s 共 18 种测试(并发数 x 测试模式) |
300s 共 18 种测试(并发数 x 测试模式) |
300s 共 18 种测试(并发数 x 测试模式) |
|
每种测试 办法 |
obd test sysbench(OBD 自带) 先 prepare、再 run、再 cleanup |
sysbench prepare sysbench run sysbench cleanup |
sysbench prepare sysbench run sysbench cleanup |
-
架构层级:
- MySQL 一层架构、OceanBase 二层架构(OBProxy + OBServer)、TiDB 三层架构(TiDB+PD+TiKV);
- 每多一层网络层面的提早耗费会减少。
-
QPS:均匀提早 OceanBase 体现绝对于 MySQL 体现均能够
- QPS 延迟时间绝对是 MySQL 的 1/3(最低 QPS 也过万,最低均匀提早 3ms);
- 数据压缩率(表仅 2 数值、2 字符字段)是 MySQL 的 3/5。
- sysbench 表绝对简略和实际生产场景表有肯定差别,本次测试作为参考
- 每种测试(每类数据库共 18 种测试)均会生成测试数据(prepare)、跑测试(run)、清理测试数据(cleanup)
QPS 体现
提早体现
存储压缩
MySQL:数据 test
库物理空间占用 69G
mysql> select count(*) from sbtest10;
+----------+
| count(*) |
+----------+
| 30000000 |
+----------+
1 row in set (4.62 sec)
TiDB:数据 test
库物理空间占用 39G
mysql> select count(*) from sbtest10;
+----------+
count(*) |
+----------+
30000000 |
+----------+
1 row in set (0.00 sec)
OceanBase:数据 test
库物理空间占用 43G。预分配机制,启动就是占用 1.2T 空间(理论具体库物理空间通过 OB 节点资源耗费查问)。
mysql> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
| 30000000 |
+----------+
1 row in set (0.00 sec)
binlog 兼容
- 迁徙服务 OMS 能通过 OMS 同步数据变更至上游 Kafka;
- 能兼容 MySQL binlog 协定同步上游 Kafka 很敌对(咱们这类场景多 MySQL->Kafka->Hive);
- 暂未有相似 MySQL binlog 原始文件性能,据说爱可生近期公布基于 OceanBase 的商业发行版 ActionDB 对于此性能正在布局中,非常期待。
集群测试
集群形式目前暂对数据存储压缩率形式做了测试(生产监控场景 MySQL 迁徙至 OceanBase),后续还会比照监控场景 MySQL 中各类型报表查问 SQL 在 OceanBase 的体现。
机器资源
节点类型 | 集群形式 |
---|---|
中控治理节点 | 10.xxx 16C 64G /data 3.7T |
数据节点 | 10.xxx 32C 50G /data3 15T |
数据节点 | 10.xxx 32C 50G /data3 15T |
数据节点 | 10.xxx 32C 50G /data3 15T |
OCP 治理组件嵌入到了 OBD 集群的部署流程中,机器相干初始化参考官网文档。
部署筹备
在线部署筹备
yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
yum install -y ob-deploy
source /etc/profile.d/obd.sh
离线部署筹备
在 https://www.oceanbase.com/softwarecenter
下载 all-in-one 包。
tar -xzf oceanbase-all-in-one-*.tar.gz
cd oceanbase-all-in-one/bin/
./install.sh
source ~/.oceanbase-all-in-one/bin/env.sh
白屏部署
obd web -p 80
举荐白屏形式部署,可视化直观,有各种查看项。
预查看阶段会做全面 check。
obd cluster display oceanbase41
Get local repositories and plugins ok
Open ssh connection ok
Cluster status check ok
Connect to observer ok
Wait for observer init ok
+-------------------------------------------------+
| observer |
+---------------+---------+------+-------+--------+
| ip | version | port | zone | status |
+---------------+---------+------+-------+--------+
| 10.xxxx.208 | 4.1.0.0 | 5000 | zone2 | ACTIVE |
| 10.xxxx.209 | 4.1.0.0 | 5000 | zone1 | ACTIVE |
| 10.xxxx.210 | 4.1.0.0 | 5000 | zone3 | ACTIVE |
+---------------+---------+------+-------+--------+
obclient -h10.xxxx.208 -P5000 -uroot -p'xxxx' -Doceanbase -A
Connect to obproxy ok
+-------------------------------------------------+
| obproxy |
+---------------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+---------------+------+-----------------+--------+
| 10.xxxx.209 | 2883 | 2884 | active |
| 10.xxxx.208 | 2883 | 2884 | active |
| 10.xxxx.210 | 2883 | 2884 | active |
+---------------+------+-----------------+--------+
obclient -h10.xxxx.209 -P2883 -uroot -p'xxxx' -Doceanbase -A
Connect to Obagent ok
+------------------------------------------------------------------+
| obagent |
+---------------+--------------------+--------------------+--------+
| ip | mgragent_http_port | monagent_http_port | status |
+---------------+--------------------+--------------------+--------+
| 10.xxxx.209 | 8089 | 8088 | active |
| 10.xxxx.208 | 8089 | 8088 | active |
| 10.xxxx.210 | 8089 | 8088 | active |
+---------------+--------------------+--------------------+--------+
Connect to ocp-express ok
+------------------------------------------------------------------+
| ocp-express |
+---------------------------+----------+------------------+--------+
| url | username | default_password | status |
+---------------------------+----------+------------------+--------+
| http://10.xxxx.209:8180 | admin | oceanbase | active |
+---------------------------+----------+------------------+--------+
Trace ID: c3049c64-efa3-11ed-bf3a-525400b51421
创立 OCP 治理平台域名 Nginx 转发
办公环境仅能拜访生产 80 端口,DNS 域名 ->nginx 80->10.xxxx.209:8180(OCP 治理平台)http://ob-ocp-xxxx.db.dmall.com/
cat oceanbase-ocp.conf
server {
listen 80;
server_name ob-ocp-gz01.db.dmall.com;
location / {
proxy_pass http://10.xxxx.209:8180;
index index.html index.htm index.jsp;
}
}
创立 MySQL 租户
命令行中创立租户存在 timeout 谬误,登录时失败(和官网人员沟通后在 OCP 平台创立租户失常胜利,揣测命令行创立租户 memory_size
过大,OCP 中创立限度为 10G)。
# 创立资源单元
create resource unit ut1 max_cpu 30, memory_size '16G';
# 创立资源池
create resource pool p1 unit 'ut1',unit_num 1,ZONE_LIST ('zone1', 'zone2' ,'zone3');
# 创立租户
select now(); create tenant if not exists mysql CHARSET='utf8mb4', ZONE_LIST=('zone1','zone2','zone3'), PRIMARY_ZONE='zone1,zone2,zone3',resource_pool_list=('p1') set ob_tcp_invited_nodes='%';select now();
ERROR 4012 (HY000): Timeout
# MySQL 租户登录
obclient -h127.0.0.1 -P5000 -uroot@mysql -Doceanbase -A
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 4725 (HY000): tablet does not exist
创立分区表示例
OceanBase 分布式分片基于分区表实现,大表必须创立分区。
CREATE TABLE `snapshot_innodb_status_log` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`stat_time` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
......
PRIMARY KEY (`id`,stat_time),
KEY `idx_port` (`port`),
KEY `idx_ip` (`ip`),
KEY `idx_stat_time` (`stat_time`)
) partition by range (year(stat_time)*100+month(stat_time)) (PARTITION p0 VALUES LESS THAN(202201),
PARTITION p1 VALUES LESS THAN(202203),
PARTITION p2 VALUES LESS THAN(202205),
PARTITION p3 VALUES LESS THAN(202207),
PARTITION p4 VALUES LESS THAN(202209),
PARTITION p5 VALUES LESS THAN(202211),
PARTITION p6 VALUES LESS THAN(202301),
PARTITION p7 VALUES LESS THAN(202303),
PARTITION p8 VALUES LESS THAN(202305),
PARTITION p9 VALUES LESS THAN(202307),
PARTITION p10 VALUES LESS THAN(202309),
PARTITION p11 VALUES LESS THAN(202311),
PARTITION p12 VALUES LESS THAN MAXVALUE
);
CREATE TABLE `redis_app_minute_command_statistics` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`app_id` int(11) NOT NULL COMMENT '利用 id',
`collect_time` datetime NOT NULL,
.........
PRIMARY KEY (`id`,collect_time),
UNIQUE KEY `app_id` (`app_id`,`collect_time`,`command_name`),
KEY `idx_create_time` (`create_time`),
KEY `idx_collect_time_app_id_command_name` (`collect_time`,`app_id`,`command_name`)
) ENGINE=InnoDB
partition by range (year(collect_time)*100+month(collect_time)) (PARTITION p0 VALUES LESS THAN(202201),
PARTITION p1 VALUES LESS THAN(202203),
PARTITION p2 VALUES LESS THAN(202205),
PARTITION p3 VALUES LESS THAN(202207),
PARTITION p4 VALUES LESS THAN(202209),
PARTITION p5 VALUES LESS THAN(202211),
PARTITION p6 VALUES LESS THAN(202301),
PARTITION p7 VALUES LESS THAN(202303),
PARTITION p8 VALUES LESS THAN(202305),
PARTITION p9 VALUES LESS THAN(202307),
PARTITION p10 VALUES LESS THAN(202309),
PARTITION p11 VALUES LESS THAN(202311),
PARTITION p12 VALUES LESS THAN MAXVALUE
);
留神:OceanBase 数据库社区版暂不反对
utf8mb4_unicode_ci
和utf16_unicode_ci
,主键(多列)和惟一索引(多列)必须蕴含分区键。否则创立分区表报错:
ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function
ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function
工夫分区键必须是
datetime
,不能是timestamp
,否则报错。
ERROR 1486 (HY000): Constant or random or timezone-dependent expressions in (sub)partitioning function are not allowed
更多分区表 的应用倡议。
DRC 同步 MySQL 至 OceanBase
咱们 DRC 自研同步工具反对 MySQL->OceanBase(DRC 还能反对 MySQL->MySQL,MySQL->TiDB),官网 OMS 迁徙工具装置管理者工具 OAT。外部 MySQL 监控快照库空间 660G(单正本)迁徙至 OceanBase 单正本空间 110G,压缩率约为 1/6。
MySQL 单正本:
OceanBase 单正本:
MySQL->OceanBase 数据简略统一校验:
MySQL 采纳 show table status;
,OceanBase 查问 information_schema.tables
(show table status
中无 rows
信息,也和官网人员确认过)。
实际中因有 2 张上百 G 大表在 DRC 工具全量期间指标 OB 时常有异样报错,2 张上百 G 大表全量采纳 mydumper + myloader
手动备份还原至 OceanBase,DRC 工具增量同步。
DRC 同步期间存在 OceanBase 指标端呈现谬误问题:指标端执行 SQL 呈现谬误。
!io.ReadFull(header) failed. err EOF: connection was bad,Table [redis_monitor_data_min -> redis_monitor_data_min]
因 DRC 同步大表时频繁呈现以上谬误,大表改为 mydumper
多线程逻辑备份还原也偶然出现异常。
# myloader 多线程还原出现异常谬误
CRITICAL **: 10:45:12.333: Error switching to database xxx whilst restoring table xxxx_data_min
** (myloader:118422): CRITICAL **: 10:46:42.195: Error restoring xxx.xxxx_status_log from file xxx.xxxx_status_log.00006.sql.gz: Lost connection to MySQL server during query
增大租户内存和减小转储比例后 myloader
多线程还原没有出现异常谬误。
旧配置 | 新配置 |
---|---|
freeze_trigger_percentage 70% | freeze_trigger_percentage 30% |
租户 memory_size 10G | 租户 memory_size 15G |
要害配置
留神:
datafile_size 不反对放大(反对增大,需 reload 重启集群),配置后就会预调配(datafile_disk_percentage 默认 95%)占用空间
ll -h /data/oceanbases1/sstable/block_file
-rw-r--r-- 1 root root 1.5T May 4 16:35 /data/oceanbases1/sstable/block_file
[oceanbase-ce] server1(127.0.0.1): DO NOT decrease datafile_size after startup
-
memory_limit
OBServer 的最大可应用内存数。因为最低内存配置为 64 GB,预留局部给零碎应用,则倡议 OBServer 独占 58 GB,即零碎租户内存与程序内存共 58 GB
-
system_memory
零碎预留给租户 ID 为 500 的租户的内存容量
obclient> ALTER SYSTEM SET system_memory='xxG';
-
rootservice_memory_limit
Root Service 的最大内存容量限度
obclient> ALTER SYSTEM SET rootservice_memory_limit='2G';
-
ob_query_timeout
SQL 最大执行工夫,单位是微秒。
超时会报错
ERROR 4012 (HY000): Timeout, query has reached the maximum query timeout: 10000000(us), maybe you can adjust the session variable ob_query_timeout or query_timeout hint, and try again.
常用命令
手动收集信息
CALL dbms_stats.gather_table_stats('test', 'sbtest1', granularity=>'GLOBAL', method_opt=>'FOR ALL COLUMNS SIZE 128');
# 应用 Oracle 模式语法
ALTER SYSTEM SET ENABLE_SQL_EXTENSION = TRUE;
ANALYZE TABLE sbtest1 COMPUTE STATISTICS FOR ALL COLUMNS SIZE 128;
更多手动收集统计信息 的应用倡议。
租户资源的创立
创立资源配置
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T' ;
必选配置项
- MAX_CPU
- MEMORY_SIZE
- MIN_CPU 默认等于 MAX_CPU
- MIN_IOPS 默认等于 MAX_IOPS
- LOG_DISK_SIZE 默认等于 3 倍的内存大小,最小为 2G
- MIN_IOPS 和 MAX_IOPS 的值依据 MIN_CPU 规格主动计算,1 个 Core 对应 1 万 IOPS 值,即 MAX_IOPS = MIN_IOPS = MIN_CPU * 10000
创立资源池
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
- UNIT ‘uc1’ 示意为该资源池指定的资源配置为 uc1,该资源池下的每个资源单元应用 uc1 的规格进行配置;
- ZONE_LIST (‘zone1′,’zone2’) 是为资源池指定的应用范畴,示意该资源池要在 zone1 和 zone2 上创立资源单元;
- UNIT_NUM 2 是为资源池指定资源单元的个数,示意在 ZONE_LIST 内的每个 Zone 上都创立 2 个资源单元。
创立租户
obclient> CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('z1', 'z2');
obclient>CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z3');
obclient>CREATE TENANT tt resource_pool_list=('pool1','pool2');
tt 租户下有 2 个资源池。
删除租户
Drop tenant mysql force ;
Drop resource pool p1;
Drop RESOURCE UNIT ut1;
查看租户资源配置
SELECT t1.name resource_pool_name,
t2.`name` unit_config_name,
t2.max_cpu,
t2.min_cpu,
t2.memory_size/1024/1024/1024 memory_size,
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 | unit_id | zone | observer | tenant_id | tenant_name |
+--------------------+------------------+---------+---------+-----------------+---------+-------+----------------+-----------+-------------+
| sys_pool | sys_unit_config | 1 | 1 | 8.500000000000 | 1 | zone1 | 127.0.0.1:2882 | 1 | sys |
| p1 | ut1 | 32 | 32 | 16.000000000000 | 1001 | zone1 | 127.0.0.1:2882 | 1002 | mysql |
+--------------------+------------------+---------+---------+-----------------+---------+-------+----------------+-----------+-------------+
查看单元配置
select
name,
max_cpu,
round(memory_size / 1024 / 1024 / 1024, 2) 'memory_size_GB'
from
__all_unit_config;
+-----------------+---------+----------------+
| name | max_cpu | memory_size_GB |
+-----------------+---------+----------------+
| sys_unit_config | 1 | 8.50 |
| ut1 | 32 | 16.00 |
+-----------------+---------+----------------+
查看各 OBServer 残余资源单元
select
svr_ip,
svr_port,
zone,
round((cpu_capacity_max - cpu_assigned_max), 2) 'cpu_free_num',
cpu_capacity_max 'cpu_total_num',
round((mem_capacity - mem_assigned) / 1024 / 1024 / 1024, 2) 'mem_free_GB',
round(memory_limit / 1024 / 1024 / 1024, 2) 'mem_total_GB',
round(DATA_DISK_IN_USE / 1024 / 1024 / 1024, 2) as data_used_GB,
round(DATA_DISK_CAPACITY / 1024 / 1024 / 1024, 2) as data_total_GB,
round(LOG_DISK_CAPACITY / 1024 / 1024 / 1024, 2) as log_total_GB,
round(LOG_DISK_IN_USE / 1024 / 1024 / 1024, 2) as log_used_GB
from
gv$ob_servers;
+-----------+----------+-------+--------------+---------------+-------------+--------------+--------------+---------------+--------------+-------------+
| svr_ip | svr_port | zone | cpu_free_num | cpu_total_num | mem_free_GB | mem_total_GB | data_used_GB | data_total_GB | log_total_GB | log_used_GB |
+-----------+----------+-------+--------------+---------------+-------------+--------------+--------------+---------------+--------------+-------------+
| 127.0.0.1 | 2882 | zone1 | 7.00 | 40 | 9.50 | 64.00 | 192.00 | 192.00 | 192.00 | 40.69 |
+-----------+----------+-------+--------------+---------------+-------------+--------------+--------------+---------------+--------------+-------------+
查看所有 OBServer 节点
select zone,svr_ip,svr_port,inner_port,with_rootserver,status,gmt_create from __all_server order by zone, svr_ip;
查看以后租户
show Tenant ;
+---------------------+
| Current_tenant_name |
+---------------------+
| mysql |
+---------------------+
1 row in set (0.002 sec)
批改资源池
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '32G', MMAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T';
obclient> CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('z1', 'z2');
obclient> CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z3');
obclient> CREATE TENANT tt resource_pool_list=('pool1','pool2');
obclient> ALTER RESOURCE UNIT uc1 MAX_CPU 6, MEMORY_SIZE '36G';
ALTER RESOURCE UNIT config_mysql_zone1_20C10G_vcq MEMORY_SIZE='12G';
# 反对的在线扩容资源单元
ALTER RESOURCE UNIT unit_name
MEMORY_SIZE [=] 'size_value',
MAX_CPU [=] cpu_num,
[MIN_CPU [=] cpu_num,]
[MAX_IOPS [=] iops_num,]
[MIN_IOPS [=] iops_num,]
[LOG_DISK_SIZE [=] 'size_value'];
# 调大 OceanBase 集群磁盘最大空间百分比(默认预调配 data_size 的 95%)ALTER system SET datafile_disk_percentage = 98;
# 调大 OceanBase 用户租户内存最大内存百分比(默认 mem_size 的 50%)alter system set memstore_limit_percentage =70;
# 进步转储速度
alter system set freeze_trigger_percentage=30;
更多治理资源池的应用倡议。
限度
- OceanBase 社区版暂不反对字符序
utf8mb4_general_ci
。
更多对于 OceanBase 与 MySQL 的兼容性。 - OceanBase 创立 user 只反对明文形式,密文形式(
identified as xxx
)不反对。反对CREATE USER 'dmall_xxxx'@'10.%.%.%' identified by 'xxx'
; -
若超过磁盘限额配置写入会报错(除了机器磁盘空间报警外还需对 OBServer data 空间使用率做报警)。
error, errno = 4184, state = '53100': Server out of disk space
解决形式为扩容资源单元或者
edit-config
批改datafile_size:
后 reload 集群重启失效。 -
若超过内存限额配置写入会报错(高 TPS 场景下 OceanBase 很耗费内存)。
SQL error, errno = 4013, state = 'HY001': No memory or reach tenant memory limit
解决形式为扩容资源单元、开启写入限速以及调整转储阈值(调高转储线程数,放慢转储,让内存尽快开释)。更多参考租户内存写满。
总结
- OceanBase 在 QPS、读写提早、存储压缩方面均不错(生产 MySQL 一监控场景库空间:OceanBase 空间为 6:1 单正本,660G:110G 单正本);
- 高 TPS 场景能够适当调整租户内存应用参数、转储参数;
- OceanBase 不同租户资源隔离(IOPS,内存,CPU)更好适配多业务场景;
- OBD 白屏部署形式更加高效、直观,OCP 治理平台性能全面;
- 业务利用方应用 OceanBase 比 MySQL 有点区别(大表创立分区表,用户名需带租户名等)。
对于 SQLE
爱可生开源社区的 SQLE 是一款面向数据库使用者和管理者,反对多场景审核,反对标准化上线流程,原生反对 MySQL 审核且数据库类型可扩大的 SQL 审核工具。
SQLE 获取
类型 | 地址 |
---|---|
版本库 | https://github.com/actiontech/sqle |
文档 | https://actiontech.github.io/sqle-docs/ |
公布信息 | https://github.com/actiontech/sqle/releases |
数据审核插件开发文档 | https://actiontech.github.io/sqle-docs-cn/3.modules/3.7_audit… |