作者:爱可生数据库高级工程师,擅长故障分析和性能优化。
引言
OceanBase 单机集中式集群(即单机版,后文不再称“单机集中式集群”)是OB推出的极简数据库架构,区别于分布式集群架构,单机版无多副本和扩缩容能力,适用于开发测试环境及数据安全性要求不高的业务系统。
OceanBase社区版和企业版都支持单机版部署,相关区别如下。
单机企业版 | 单机社区版 | |
---|---|---|
单机部署(v4.0以下) | 不支持 | 不支持 |
主备集群(v4.1及以上) | 不支持 | 不支持 |
主备租户 | 支持 | 支持(OBD 目前仅支持基于网络的主备租户部署) |
主备租户是否支持Failover | 仅支持手动Failover | 仅支持手动Failover |
主备租户是否为异步同步 | 是 | 是 |
主备租户是否支持最大可用/最大保护模式 | 不支持 | 不支持 |
是否支持扩缩容 | 不支持 | 不支持 |
是否支持在线转分布式架构部署 | 支持 | 支持 |
是否支持OCP部署 | 支持 | 仅OCP社区版支持 |
是否支持Oracle模式 | 支持 | 不支持 名词解释 |
- 主备集群:OceanBase v4.1.0 之前,物理备库的产品形态为集群级主备。集群有两种角色:主集群和备集群,主集群下面所有用户租户都是主租户,备集群下面所有用户租户都是备租户,备集群会自动同步主集群的租户变更操作。
- 主备租户:OceanBase v4.1.0 之后,物理备库的产品形态变更为租户级主备,即主或备的角色信息属于租户,分为主租户和备租户,集群不再有主备角色的概念,而只是承载租户的容器。
一、安装部署
1.1 OceanBase 单机版部署方式
OceanBase 单机社区版部署方式有3种,分别是:
- 通过 OBD ALL-IN-ONE 包部署
- 推荐,轻量级部署,所需资源少(OBD和OceanBase单机版数据库可复用1台服务器),方便快速
- 通过命令行方式部署
- 需纯手工命令行操作
- 通过 OCP 社区版平台部署
- 适合规模化部署,需要额外资源部署 OCP 云平台,运维方便
- 生产环境推荐
1.2 OceanBase 单机版最简部署
需要提前在OceanBase官网上下载 OBD all-in-one 安装包,下载地址 https://www.oceanbase.com/softwarecenter
1.通过all-in-one安装包部署OBD环境
su - admin
tar -xzf oceanbase-all-in-one-*.tar.gz
cd oceanbase-all-in-one/bin/
./install.sh
source ~/.oceanbase-all-in-one/bin/env.sh
2.禁用远程仓库
obd mirror disable remote
obd mirror list
- 查看 Type=remote 对应的 Enabled 变成了 False,说明已关闭远程镜像源
3.查看本地镜像中安装包列表
obd mirror list local
4.准备配置文件
cd ~/.oceanbase-all-in-one/obd/usr/obd/example/
cp mini-single-example.yaml mini-single-20240221.yaml
vim mini-single-20240221.yaml
添加如下参数到配置文件。
user:
username: admin
password: OceanBase_123#
port: 22
oceanbase-ce:
servers:
- 10.186.58.87
global:
home_path: /home/admin/observer
data_dir: /data/1
redo_dir: /data/log1
devname: eth0
mysql_port: 2881
rpc_port: 2882
zone: zone1
cluster_id: 1
memory_limit: 12G
system_memory: 1G
datafile_size: 10G
datafile_next: 2G
datafile_maxsize: 20G
log_disk_size: 20G
cpu_count: 12
production_mode: false
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
root_password: OceanBase_123#
5.部署OceanBase数据库
下述命令创建一个名字为obtest的单节点集群
obd cluster deploy obtest -c mini-single-20240221.yaml
- 输出obtest deployed表示该集群创建完成
6.配置lib环境变量
通过 OCP 社区版或 OBD 启动时不会有环境变量问题(启动时带了相关库),手工启动或执行observer命令将报错,解决方式如下。
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/observer/lib' >> ~/.bash_profile
source ~/.bash_profile
7.检查和启动数据库
确认observer程序在目标机器安装成功。
/home/admin/observer/bin/observer --version
- 结果为observer (OceanBase_CE 4.2.2.0)
启动OceanBase数据库。
obd cluster start obtest
启动完成后,使用root登录数据库(默认登录sys租户)进行创建业务租户等操作。
mysql -h10.186.58.87 -P2881 -uroot -p'OceanBase_123#' -Doceanbase -A
show full processlist;
二、主备架构
2.1 单机版主备租户简述
OceanBase 单机版支持主备租户架构,并采用异步方式做数据同步。由于OceanBase集群支持部署多个业务租户,所以主备租户架构有三种部署方式:
- 集群中仅有主租户或备租户
- 典型场景,适用于两地容灾等多种业务场景
- 集群中既有主租户又有备租户
- 适用于两地多写(容灾)场景
- 主租户和备租户在同一个集群中
- 适用于业务升级(保留数据镜像)场景
2.2 单机版主备租户部署
本章以最常用架构“集群中仅有主租户或备租户”为例进行部署,部署方式使用相对简便的 OCP 社区版云平台进行部署。
1.部署OCP社区版
使用OBD白屏工具部署OCP社区版,具体步骤略。
- 安装包下载
- https://www.oceanbase.com/softwarecenter
- 安装包:ocp-all-in-one-4.2.1-20231208144448.el7.x86_64.tar.gz
- 安装步骤
- 参考:https://www.oceanbase.com/docs/common-ocp-1000000000584989
2.添加主备主机
OCP社区版部署完成后,登录到OCP Web控制台,添加2台主备服务器。
3.安装两个集群
上传需要部署的OceanBase数据库安装包到OCP中,需要上传的包如下(具体版本以实际为准):
- oceanbase-ce-utils-4.2.2.0-100000192024011915.el7.x86_64.rpm
- oceanbase-ce-libs-4.2.2.0-100000192024011915.el7.x86_64.rpm
- oceanbase-ce-4.2.2.0-100000192024011915.el7.x86_64.rpm
安装包上传完成后,分别创建2个单机集中式集群。
4.创建主备租户
第一步,集群1中创建示例主租户 tmysql。
第二步,集群2中创建实例备租户 tmysql。
5.数据同步验证
安装完成后可通过 OCP - 租户- 拓扑图 界面验证主备关系,查看同步延时。
业务数据写入验证如下
- 主库写入数据
- 备库查看数据
- 备库同步延时查看(需要使用备租户所在集群的sys租户)
MySQL [oceanbase]> SELECT TENANT_NAME, TENANT_ID, TENANT_ROLE, SCN_TO_TIMESTAMP(SYNC_SCN),NOW() FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'tmysql';
+-------------+-----------+-------------+----------------------------+---------------------+
| TENANT_NAME | TENANT_ID | TENANT_ROLE | SCN_TO_TIMESTAMP(SYNC_SCN) | NOW() |
+-------------+-----------+-------------+----------------------------+---------------------+
| tmysql | 1004 | STANDBY | 2024-02-23 17:07:06.028739 | 2024-02-23 17:07:06 |
+-------------+-----------+-------------+----------------------------+---------------------+
1 row in set (0.02 sec)
5.故障切换验证
测试OceanBase单机版主备租户模式的高可用能力,检查是否支持故障转移。
- 主库kill前状态,tmysql 租户主角色在集群 singlecluster 上。
- 主库kill后状态,异步同步链路中断
- 通过手工进行容灾切换的方式进行故障转移
- 手工容灾切换后,tmysql 租户主角色切换到集群 singleClusterSlave 。
三、对比MySQL单机版【校正性能基准】
3.1 测试命令
本章测试目的是在获取测试服务器CPU、磁盘基准性能的情况下,对 OceanBase 4.2.2 单机(社区)版和 MySQL 8.0.35 单机(社区)版数据库性能对比测试环境和命令如下。
注意:为减少不同服务器之间误差,本次测试 MySQL 和 OB 数据库都在同一台服务器上进行测试,测试交替进行,MySQL测试完毕后就关闭mysqld服务,启动OB数据库进行测试。
MySQL 8.0.35单机版 | OceanBase 4.2.2单机版 | |
---|---|---|
测试机环境 | CPU x86_64/AMD EPYC 9554 64-Core Processor/虚拟机同一台服务器上进行测试 | |
测试机规格 | 4核8G内存SSD磁盘 | |
测试工具 | sysbench 1.0.20 | |
关键数据库参数 | innodb_buffer_pool_size = 4Gsync_binlog = 1innodb_flush_log_at_trx_commit = 1innodb_io_capacity = 2000innodb_io_capacity_max = 10000 | memory_limit = 7Gsystem_memory = 1Gmemstore_limit_percentage = 90cpu_count = 4系统租户规格:1C2G业务租户规格:3C4G |
测试数据准备 | sysbench /root/sysbench-1.0.20/src/lua/oltp_write_only.lua --tables=8 --table_size=1000000 --mysql-host=10.186.58.85 --mysql-port=8001 --mysql-user=root --mysql-password=root --mysql-db=sbtest --report-interval=2 --time=60 --threads=2 run | sysbench /root/sysbench-1.0.20/src/lua/oltp_read_write.lua --tables=8 --table_size=1000000 --mysql-host=10.186.58.85 --mysql-port=2881 --mysql-user='root@trenzy' --mysql-password='OceanBase_123#' --mysql-db=sbtest --report-interval=2 --time=60 --threads=2 prepare |
Point Select | sysbench /root/sysbench-1.0.20/src/lua/oltp_point_select.lua --tables=8 --table_size=1000000 --mysql-host=10.186.58.85 --mysql-port=8001 --mysql-user=root --mysql-password=root --mysql-db=sbtest --report-interval=2 --time=60 --threads=1 run | sysbench /root/sysbench-1.0.20/src/lua/oltp_point_select.lua --tables=8 --table_size=1000000 --mysql-host=10.186.58.85 --mysql-port=2881 --mysql-user='root@trenzy' --mysql-password='OceanBase_123#' --mysql-db=sbtest --report-interval=2 --time=60 --threads=1 run |
3.2 测试机基准测试
1.磁盘FIO测试
使用 Fio 工具测试服务器的磁盘性能指标如下。
- 4K seq read
- IOPS: 4975
- 4K seq write
- IOPS: 3919
- 4K rand read
- IOPS: 4768
- 4k rand write
- IOPS: 3074
# 4k seq read
[root@10-186-58-85 disktest]# fio -filename=/data/disktest/file -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -size=10G -numjobs=30 -runtime=60 -group_reporting -name=iotest4kW -rw=read
fio-3.7
...
iops : min= 3822, max= 5786, avg=4975.06, stdev=262.95, samples=3591
...
# 4K seq write
[root@10-186-58-85 disktest]# fio -filename=/data/disktest/file -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -size=10G -numjobs=30 -runtime=60 -group_reporting -name=iotest4kW -rw=write
...
iops : min= 2370, max= 5004, avg=3919.07, stdev=481.46, samples=3577
...
# 4K rand read
[root@10-186-58-85 data]# fio -filename=/data/disktest/file -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -size=10G -numjobs=30 -runtime=60 -group_reporting -name=iotest4kW -rw=randread
...
iops : min= 3746, max= 5390, avg=4768.96, stdev=259.29, samples=3583
...
# 4K rand write
[root@10-186-58-85 data]# fio -filename=/data/disktest/file -direct=1 -iodepth 1 -thread -ioengine=psync -bs=4k -size=10G -numjobs=30 -runtime=60 -group_reporting -name=iotest4kW -rw=randwrite
...
iops : min= 784, max= 4416, avg=3074.03, stdev=636.20, samples=3574
...
2.CPU 测试
使用 Sysbench 工具测试 服务器的CPU性能指标如下。
[root@10-186-58-85 ~]# /root/sysbench-1.0.20/src/sysbench cpu --time=60 --threads=4 --report-interval=2 run
...
CPU speed:
events per second: 16316.69
General statistics:
total time: 60.0011s
total number of events: 979033
Latency (ms):
min: 0.23
avg: 0.24
max: 40.26
95th percentile: 0.25
sum: 239493.26
Threads fairness:
events (avg/stddev): 244758.2500/1500.12
execution time (avg/stddev): 59.8733/0.01
3.3 4c8g下OB和MySQL对比测试结果
同一服务器(配置为 4c8g)下测试OB和MySQL单机版的对比结果。
- | MySQL 8.0.35 | OceanBase 4.2.2 | |||
---|---|---|---|---|---|
测试项 | 并发 | QPS | 延迟 | QPS | 延迟(ms) |
Point Select | 1 | 2224.14 | 0.45 | 1216.05 | 0.82 |
2 | 6743.76 | 0.30 | 2921.77 | 0.68 | |
4 | 15224.38 | 0.26 | 6747.46 | 0.59 | |
6 | 23131.86 | 0.26 | 12549.36 | 0.48 | |
8 | 30286.95 | 0.26 | 17033.40 | 0.47 |
通过上述测试,在校准测试服务器性能偏差的情况下,对比 OceanBase单机版和 MySQL 单机版的测试结果结论如下
- 低并发场景,OB单机版性能比MySQL单机版低 50% 左右
3.4 12c16g下OB和MySQL对比测试结果
同一服务器(扩容虚机配置为 12c16g)下测试OB和MySQL单机版的对比结果。
- | MySQL 8.0.35 | OceanBase 4.2.2 | |||
---|---|---|---|---|---|
测试命令 | sysbench /root/sysbench-1.0.20/src/lua/oltp_read_write.lua --tables=30 --table_size=1000000 --mysql-host=10.186.56.112 --mysql-port=8001 --mysql-user=root --mysql-password=root --mysql-db=sbtest --rand-type=uniform --db-ps-mode=disable --report-interval=2 --time=60 --threads=32 run | sysbench /root/sysbench-1.0.20/src/lua/oltp_read_write.lua --tables=30 --table_size=1000000 --mysql-host=10.186.56.112 --mysql-port=2881 --mysql-user='root@trenzy' --mysql-password='OceanBase_123#' --mysql-db=sbtest --rand-type=uniform --db-ps-mode=disable --report-interval=2 --time=60 --threads=32 run | |||
关键参数 | innodb_buffer_pool_size = 8Gsync_binlog = 1innodb_flush_log_at_trx_commit = 1innodb_io_capacity = 2000innodb_io_capacity_max = 10000 | memory_limit = 14Gsystem_memory = 1Gmemstore_limit_percentage = 80cpu_count = 12系统租户规格:1C2G业务租户规格:11C10G | |||
测试项 | 并发 | QPS | 延迟 | QPS | 延迟(ms) |
Read Write | 32 | 22153.58 | 28.85 | 31220.35 | 20.12 |
64 | 41293.90 | 30.96 | 42313.75 | 30.22 | |
128 | 33064.01 | 77.28 | 47213.76 | 54.13 | |
256 | 30631.88 | 166.37 | 51843.56 | 98.46 | |
512 | 52371.69 | 194.41 | 57267.87 | 177.52 | |
1024 | 51408.96 | 391.79 | 50286.83 | 400.67 | |
Write Only | 32 | 14125.67 | 13.58 | 33533.56 | 5.72 |
64 | 29036.95 | 13.21 | 43861.17 | 8.74 | |
128 | 46054.28 | 16.65 | 58032.69 | 13.21 | |
256 | 57964.22 | 26.42 | 69601.43 | 21.98 | |
512 | 56689.01 | 51.90 | 63358.69 | 47.88 | |
1024 | 52504.84 | 106.11 | 56298.68 | 107.87 |
通过上述测试,在校准测试服务器性能偏差的情况下,对比 OceanBase单机版和 MySQL 单机版的测试结果结论如下
- 混合读写场景,OB单机版性能与MySQL单机版持平(虚拟机多次测试结果上下差±2000左右,所以该场景OB与MySQL的性能结果相差不大)
- 纯写场景,OB单机版性能与MySQL单机版略高15%左右
四、对比OBD自带测试工具
OBD test 命令可以一键进行 sysbench 测试,原理上还是需要调用 sysbench 测试工具的 bin 文件和 LUA Scripts,仅在最外层包装了一层 python 脚本进行调用,调用文件存储在:
- ~/oceanbase-all-in-one/obd/usr/obd/plugins/sysbench/4.0.0.0/run_test.py
4.1 测试命令
obd test sysbench | Sysbench | |
---|---|---|
测试命令 | obd test sysbench obtest --tenant=trenzy --sysbench-script-dir=/root/sysbench-1.0.20/src/lua --script-name=oltp_point_select.lua --table-size=1000000 --user=root --password=OceanBase_123# --database=sbtest --table-size=1000000 --tables=5 --interval=2 --time=60 --rand-type=uniform --threads=50 | sysbench /root/sysbench-1.0.20/src/lua/oltp_point_select.lua --tables=5 --table_size=1000000 --mysql-host=10.186.58.85 --mysql-port=2881 --mysql-user='root@trenzy' --mysql-password='OceanBase_123#' --mysql-db=sbtest --report-interval=2 --time=60 --threads=50 run |
4.2 测试结果
使用 OBD test sysbench 与 直接使用 sysbench 测试 OceanBase单机版结果差不多,部分测试结果如下。
- | ob test sysbench | sysbench | |||
---|---|---|---|---|---|
测试项 | 并发 | QPS | 延迟 | QPS | 延迟(ms) |
Point Select | 50 | 63111.42 | 0.79 | 65851.76 | 0.76 |
100 | 72083.36 | 1.38 | 69770.70 | 1.42 | |
200 | 76941.33 | 2.57 | 77500.59 | 2.55 | |
500 | 70481.27 | 6.97 | 72661.22 | 6.68 | |
1000 | 65271.07 | 14.78 | 70344.68 | 13.51 |
五、OB单机版资源配置
5.1 单机版集群配置巡检
本节适用于集群做 Sysbench 测试前,对单机版集群的资源规格和集群配置等做一轮巡检,已提供更好的性能表现。
本节适用于集群做 Sysbench 测试前,对单机版集群的资源规格和集群配置等做一轮巡检,已提供更好的性能表现。
在部署OceanBase单机版集群之后,可以使用 obdiag (OceanBase Diagnose )工具对部署好的集群巡检,步骤如下。
1.安装 obdiag 工具
Obdiag 工具在 OBD ALL-IN-ONE 包中已提供,可直接使用 obd 进行安装。
cd ~/oceanbase-all-in-one/rpms/
obd mirror clone oceanbase-diagnostic-tool-1.6.0-22024020410.el7.x86_64.rpm
obd obdiag deploy
2.配置 obdiag 巡检集群
安装好的 obdiag 工具存放在 $HOME/ 目录下。
cd ~/oceanbase-diagnostic-tool/
# 配置需要巡检的集群信息
./obdiag config -h 10.186.58.86 -u root@sys -P2881 -pOceanBase_123#
3.巡检集群输出报告
cd ~/oceanbase-diagnostic-tool/
./obdiag check --cases=sysbench_free
# 巡检正常完成,会有如下提示:Check observer finished. For more details, please run cmd' cat ./check_report//check_report_observer_2024-02-27-14-16-19.table '
- 直接复制命令,粘贴执行即可查看配置建议。
[root@10-186-58-75 oceanbase-diagnostic-tool]# cat ./check_report//check_report_observer_2024-02-27-14-16-19.table
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| fail-tasks-report |
+-------------------------------------------+--------------------------------------------------------------------------------------------------------------+
| task | task_report |
+-------------------------------------------+--------------------------------------------------------------------------------------------------------------+
| sysbench.sysbench_free_test_network_speed | [fail] [remote:10.186.58.86] network_speed is and the type is <class 'str'>, not int or float ordecimal ! |
+-------------------------------------------+--------------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------------------------------------------------+
| critical-tasks-report |
+-------------------------------------------+--------------------------------------------------------------------------------------------+
| task | task_report |
+-------------------------------------------+--------------------------------------------------------------------------------------------+
| sysbench.sysbench_free_test_cpu_count | [critical] [remote:10.186.58.86] cpu_count/os_cpu_count is 8%,is not between 80 and 100 |
| sysbench.sysbench_free_test_memory_limit | [critical] [remote:10.186.58.86] memory_limit/os_memory is 26%,is not between 80 and 100 |
| sysbench.sysbench_test_cluster_parameters | [critical] [cluster:obcluster] cluster's enable_perf_event is true , need to change False |
+-------------------------------------------+--------------------------------------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| warning-tasks-report |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| task | task_report |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sysbench.sysbench_free_test_cpu_count | [warning] [cluster:obcluster] cpu_count is 2 , need to calculate the relationship between cpu_count and the number of system CPUs |
| sysbench.sysbench_test_cluster_datafile_size | [warning] [remote:10.186.58.86] When the data disk and log disk are on the same disk, the log disk needs to occupy more than 30% of the disk space. now it is 11% |
| | [warning] [remote:10.186.58.86] When the data disk and log disk are on the same disk, the data disk needs to occupy more than 60% of the disk space. now it is 5% |
| sysbench.sysbench_test_cluster_log_disk_size | [warning] [cluster:obcluster] log_disk_size <20G tenant: trenzy . log_disk_size need >20G |
| sysbench.sysbench_test_tenant_cpu_parameters | [warning] [cluster:obcluster] cpu_count is 2. the min_cpu of tenant should cpu_count/2 ~ cpu_count. tenant: sys,trenzy need check |
| | [warning] [cluster:obcluster] the MAX_IOPS of tenant should max_cpu * 10000 ~ max_cpu * 1000000 . tenant: trenzy need check |
| | [warning] [cluster:obcluster] the MIN_IOPS of tenant should max_cpu * 10000 ~ max_cpu * 1000000 . tenant: trenzy need check |
| | [warning] [cluster:obcluster] cpu_count is 2. the max_cpu of tenant should cpu_count/2 ~ cpu_count. tenant: sys,trenzy need check |
| sysbench.sysbench_test_tenant_log_disk_size | [warning] [cluster:obcluster] log_disk_size <20G tenant: trenzy . log_disk_size need >20G |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| all-tasks-report |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| task | task_report |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| sysbench.sysbench_free_test_cpu_count | [critical] [remote:10.186.58.86] cpu_count/os_cpu_count is 8%,is not between 80 and 100 |
| | [warning] [cluster:obcluster] cpu_count is 2 , need to calculate the relationship between cpu_count and the number of system CPUs |
| sysbench.sysbench_free_test_memory_limit | [critical] [remote:10.186.58.86] memory_limit/os_memory is 26%,is not between 80 and 100 |
| sysbench.sysbench_free_test_network_speed | [fail] [remote:10.186.58.86] network_speed is and the type is <class 'str'>, not int or float ordecimal ! |
| sysbench.sysbench_test_cluster_datafile_size | [warning] [remote:10.186.58.86] When the data disk and log disk are on the same disk, the log disk needs to occupy more than 30% of the disk space. now it is 11% |
| | [warning] [remote:10.186.58.86] When the data disk and log disk are on the same disk, the data disk needs to occupy more than 60% of the disk space. now it is 5% |
| sysbench.sysbench_test_cluster_log_disk_size | [warning] [cluster:obcluster] log_disk_size <20G tenant: trenzy . log_disk_size need >20G |
| sysbench.sysbench_test_cluster_parameters | [critical] [cluster:obcluster] cluster's enable_perf_event is true , need to change False |
| sysbench.sysbench_test_cpu_quota_concurrency | all pass |
| sysbench.sysbench_test_log_level | all pass |
| sysbench.sysbench_test_sql_net_thread_count | all pass |
| sysbench.sysbench_test_tenant_cpu_parameters | [warning] [cluster:obcluster] cpu_count is 2. the min_cpu of tenant should cpu_count/2 ~ cpu_count. tenant: sys,trenzy need check |
| | [warning] [cluster:obcluster] the MAX_IOPS of tenant should max_cpu * 10000 ~ max_cpu * 1000000 . tenant: trenzy need check |
| | [warning] [cluster:obcluster] the MIN_IOPS of tenant should max_cpu * 10000 ~ max_cpu * 1000000 . tenant: trenzy need check |
| | [warning] [cluster:obcluster] cpu_count is 2. the max_cpu of tenant should cpu_count/2 ~ cpu_count. tenant: sys,trenzy need check |
| sysbench.sysbench_test_tenant_log_disk_size | [warning] [cluster:obcluster] log_disk_size <20G tenant: trenzy . log_disk_size need >20G |
| sysbench.sysbench_test_tenant_primary_zone | all pass |
+----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@10-186-58-75 oceanbase-diagnostic-tool]#
5.2 最低稳定运行环境
经过测试,OceanBase单机版最少资源规格稳定运行所需的环境如下。
- 服务器规格
- CPU 2C,内存 5G【确保可用内存大于 4G】,磁盘 100G
- 系统租户规格
- CPU 1G,内存 2G
- 业务租户规格
- CPU 1G,内存 1G
- 集群配置文件
# cat min-2c4g.yaml
user:
username: admin
password: OceanBase_123#
port: 22
oceanbase-ce:
servers:
- 10.186.56.101
global:
home_path: /home/admin/observer
data_dir: /data/1
redo_dir: /data/log1
devname: eth0
mysql_port: 2881
rpc_port: 2882
zone: zone1
cluster_id: 1
memory_limit: 4G
system_memory: 1G
datafile_size: 10G
datafile_next: 2G
datafile_maxsize: 20G
log_disk_size: 20G
cpu_count: 2
production_mode: false
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
__min_full_resource_pool_memory: 1073741824
root_password: OceanBase_123#
1.最低运行环境下启动OB
部署的Linux服务器规格如下
[root@10-186-56-101 admin]# grep process /proc/cpuinfo
processor : 0
processor : 1
[root@10-186-56-101 admin]# free -m
total used free shared buff/cache available
Mem: 4797 2624 979 16 1194 1917
Swap: 0 0 0
[root@10-186-56-101 admin]# ps -ef | grep obs
admin 2636 1 29 07:25 ? 00:08:29 /home/admin/observer/bin/observer -r 10.186.56.101:2882:2881 -p 2881 -P 2882 -z zone1 -c 1 -d /data/1 -i eth0 -o __min_full_resource_pool_memory=1073741824,memory_limit=4G,system_memory=1G,datafile_size=10G,datafile_next=2G,datafile_maxsize=20G,log_disk_size=20G,cpu_count=2,enable_syslog_wf=False,enable_syslog_recycle=True,max_syslog_file_count=4
2.最低运行环境下Sysbench持续测试
[root@10-186-58-75 example]# sysbench /root/sysbench-1.0.20/src/lua/oltp_read_write.lua --tables=5 --table_size=1000 --mysql-host=10.186.56.101 --mysql-port=2881 --mysql-user='root@trenzy' --mysql-password='OceanBase_123#' --mysql-db=sbtest --report-interval=2 --time=3600 --threads=1 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Report intermediate results every 2 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
[ 2s ] thds: 1 tps: 37.42 qps: 749.45 (r/w/o: 524.42/149.69/75.34) lat (ms,95%): 42.61 err/s: 0.00 reconn/s: 0.00
...
[ 342s ] thds: 1 tps: 60.50 qps: 1215.48 (r/w/o: 851.48/243.00/121.00) lat (ms,95%): 24.38 err/s: 0.00 reconn/s: 0.00
[ 344s ] thds: 1 tps: 58.01 qps: 1159.20 (r/w/o: 812.14/231.04/116.02) lat (ms,95%): 23.95 err/s: 0.00 reconn/s: 0.00
- 注意
- 业务规格为1C1G情况下,持续写入很容易打满内存,报如下错误,但不影响 observer 运行。
- 可以调整 alter system set memstore_limit_percentage = 80; 将内存适度调大
FATAL: mysql_stmt_execute() returned error 4013 (No memory or reach tenant memory limit) for query 'SELECT c FROM sbtest4 WHERE id BETWEEN ? AND ? ORDER BY c'
FATAL: `thread_run' function failed: /usr/local/share/sysbench/oltp_common.lua:432: SQL error, errno = 4013, state = 'HY001': No memory or reach tenant memory limit
FATAL: mysql_stmt_execute() returned error 4013 (No memory or reach tenant memory limit) for query 'SELECT c FROM sbtest2 WHERE id BETWEEN ? AND ? ORDER BY c'
5.3 单机版推荐参数配置
结合 Sysbench 性能压测,推荐的集群、租户的参数或变量设置如下【适应于性能要求较高的测试环境】。
- 集群参数配置
# 默认 2G,可创建unit的最小内存阈值,若不设置创建1G内存规格的unit将失败
alter system set __min_full_resource_pool_memory=1073741824;
# 默认 5s,设置查询执行时间的阈值。超过时间的请求可能被暂停,暂停后自动被判断为大查询,执行大查询调度策略
alter system set large_query_threshold='600s';
# 默认 true,是否开启审计日志;开发或性能要求高的场景可关闭,生产环境需开启
alter system set enable_sql_audit=false;
# 默认 true,是否开启信息采集;开发或性能要求高的场景可关闭,生产环境需开启
alter system set enable_perf_event=false;
# 默认 true,是否开启 Trace Log 功能
alter system set enable_record_trace_log=false;
# 默认 WDIAG,系统日志的日志级别
alter system set syslog_level='INFO';
- 业务租户参数配置
# 默认 false,是否启用批处理功能的成组执行优化
alter system set ob_enable_batched_multi_statement=true;
# 默认 false,用于对日志传输是否使用压缩,建议开启减少网卡压力
alter system set log_transport_compress_all=true;
- 业务租户变量配置
# 默认 MANUAL,用于设置并行度选择策略。
set global parallel_degree_policy=AUTO;
# 默认 5,SQL 执行的租户内存百分比限制
set global ob_sql_work_area_percentage=20;
# 默认 10000000,设置 SQL 最大执行时间,单位是微秒
set global ob_query_timeout=13888000000;
# 默认 16777216,设置最大网络包大小,单位是 Byte
set global max_allowed_packet=41943040;
附件
MySQL 配置文件
章节三对比测试中,用到的 MySQL 8.0.35 配置文件如下。
[mysql]
default-character-set = utf8mb4
user = root
password =
[mysqld]
# Basic Settings
server-id = 1019938001
port = 8001
pid-file = mysqld.pid
socket = mysqld.sock
mysqlx_socket = mysqldx.sock
character_set_server = utf8mb4
default_storage_engine = InnoDB
lower_case_table_names = 1
skip_name_resolve = 1
skip_external_locking = 1
skip_slave_start = 1
basedir = /data/mysql/8001/base
datadir = /data/mysql/8001/data
tmpdir = /data/mysql/8001/tmp
# P_S Settings
performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
# Session Memory Settins
join_buffer_size = 2M
sort_buffer_size = 2M
tmp_table_size = 8M
max_heap_table_size = 8M
max_allowed_packet = 128M
# Global Memory and Cache Settings
temptable_max_ram = 1G
open_files_limit = 65535
max_connections = 1024
table_open_cache = 2048
# InnoDB Settings
innodb_buffer_pool_size = 8G
innodb_data_file_path = ibdata1:12M:autoextend
innodb_buffer_pool_instances = 1
innodb_file_per_table = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_flush_log_at_trx_commit = 1
innodb_io_capacity = 2000
innodb_io_capacity_max = 10000
innodb_flush_method = O_DIRECT
innodb_strict_mode = 1
innodb_flush_neighbors = 1
innodb_page_cleaners = 8
innodb_purge_threads = 8
innodb_log_file_size = 1024M
innodb_log_buffer_size = 16777216
innodb_print_all_deadlocks = 1
innodb_sort_buffer_size = 67108864
# Log Settings
log_error = mysql-error.log
log_bin = mysql-bin.log
slow_query_log_file = mysql-slow.log
relay_log = mysql-relay.log
log_slave_updates = 1
sync_binlog = 1
relay_log_recovery = 1
binlog_format = row
binlog_expire_logs_seconds = 2592000
slow_query_log = 1
long_query_time = 3
log_slow_admin_statements = 1
log_slow_slave_statements = 1
# Replication Settings
slave_skip_errors = ddl_exist_errors
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
binlog_gtid_simple_recovery = 1
binlog_rows_query_log_events = 1
slave-parallel-type = LOGICAL_CLOCK
slave-parallel-workers = 8
slave_preserve_commit_order = 1
binlog_group_commit_sync_delay=10000
binlog_group_commit_sync_no_delay_count=32