部署准备
官方参考文档https://www.oceanbase.com/docs/community-obd-cn-1000000003146500
1.创建部署用户
useradd oceanbase
passwd oceanbase设置密码database@123
2.创建部署目录
mkdir -p /data/Oceanbase
chown -R oceanbase:oceanbase /data/Oceanbase
3.配置sudo
sed -i '$aoceanbase ALL=(ALL) NOPASSWD: NOPASSWD: ALL' /etc/sudoers
安装obd
su oceanbase
下载依赖包
bash -c "$(curl -s https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/oceanbase-all-in-one/installer.sh)"
更新环境
source ~/.oceanbase-all-in-one/bin/env.sh
禁用远程镜像
obd mirror disable remote
obd mirror clone *.rpm
查看本地镜像列表
obd mirror list local
部署oceanbase-ce
1.配置
vi /home/oceanbase/oceanbase-ce.yaml
内容如下
user:
username: oceanbase
password: database@123
oceanbase-ce:
servers:
- name: server1
ip: 192.168.0.101
global:
devname: ens33
cluster_id: 1
memory_limit: 6G
system_memory: 1G
datafile_size: 2G
datafile_next: 2G
datafile_maxsize: 20G
log_disk_size: 14G
cpu_count: 16
scenario: htap
mysql_port: 2881
rpc_port: 2882
obshell_port: 2886
production_mode: false
home_path: /data/Oceanbase/observer
data_dir: /data/Oceanbase/date
redo_dir: /data/Oceanbase/redo
自定义数据库root用户的密码
root_password: root.123
zone: zone1
2.发布
obd cluster deploy obtest -c oceanbase-ce.yaml
3.启动集群
obd cluster start obtest
查看 OceanBase 集群状态
obd cluster display obtest
4.登录
obclient -h192.168.0.101 -P2881 -uroot@sys -Doceanbase -A
修改root密码
ALTER USER root IDENTIFIED BY 'root.123';
创建租户
obclient -h192.168.0.101 -P2881 -uroot@sys#obtest -A
USE oceanbase;
1.创建资源规格
查看
SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS;
#创建
CREATE RESOURCE UNIT S1_unit_config MEMORY_SIZE = '3G', MAX_CPU = 3, MIN_CPU = 1, LOG_DISK_SIZE = '6G', MAX_IOPS = 10000, MIN_IOPS = 10000, IOPS_WEIGHT=1;
2.创建资源池
查看
SELECT * FROM oceanbase.DBA_OB_RESOURCE_POOLS;
创建
CREATE RESOURCE POOL mq_pool_01 UNIT='S1_unit_config', UNIT_NUM=1, ZONE_LIST=('zone1');
报错记录
obclient(root@sys)[oceanbase]> CREATE RESOURCE POOL mq_pool_01 UNIT='S1_unit_config', UNIT_NUM=1, ZONE_LIST=('zone1');
ERROR 1235 (0A000): unit MEMORY_SIZE less than __min_full_resource_pool_memory not supported
原因是设置资源规格的MEMORY_SIZE小于默认的5G,需要修改以下参数(107374182B=1G)
obclient(root@sys)[oceanbase]> alter system __min_full_resource_pool_memory=1073741824;
Query OK, 0 rows affected (0.048 sec)
修改后再执行创建资源池的命令即可。
3.创建租户
创建mq_t1租户
CREATE TENANT IF NOT EXISTS mq_t1 PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('mq_pool_01') set OB_TCP_INVITED_NODES='%';
查看结果
SELECT * FROM DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';
登录 mq_t1 租户的 root 用户,默认密码是空
因为默认部署的是MySQL 兼容模式,以下方式登录:
obclient -h192.168.0.101 -P2881 -uroot@sys -A
修改 root 用户的密码
ALTER USER root IDENTIFIED BY 'root.123';
运维
1.查看集群列表
obd cluster list
2.查看集群状态,以部署名为 obtest 为例
obd cluster display obtest
3.修改集群参数
执行如下命令打开配置文件,修改集群配置
obd cluster edit-config obtest
修改配置并保存退出后,obd 会告知如何使得此次修改生效,复制 obd 输出的命令即可。保存修改后输出如下:
Search param plugin and load ok
Search param plugin and load ok
Parameter check ok
Save deploy "obtest" configuration
Use obd cluster reload obtest to make changes take effect.
复制执行输出中的 obd cluster reload obtest 命令即可使修改生效。
4.停止运行中的集群
obd cluster stop obtest
5.销毁已部署的集群
obd cluster destroy obtest
安装obproxy
1.配置
vi /home/oceanbase/add_odp.yaml
内容如下
obproxy-ce:
#version: 4.3.0.0
servers:
- 192.168.0.101
global:
listen_port: 2883 # External port. The default value is 2883.
prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
rpc_listen_port: 2885
enable_obproxy_rpc_service: true
home_path: /data/Oceanbase/obproxy
enable_cluster_checkout: false
skip_proxy_sys_private_check: true
enable_strict_kernel_release: false
client_session_id_version: 2 #This parameter is used to specify whether to use the new logic to generate the client session ID. The parameter type is integer. The value range is [1, 2] and the default value is 2 (use the new logic).
proxy_id: 5 #This parameter is used to set the ID for an ODP. The parameter type is integer. The default value is 0 and the value range is [0, 8191].
obproxy_sys_password: root.123
2.添加到已有集群
obd cluster component add obtest -c add_odp.yaml
检查
obd cluster display obtest
可根据打印出的命令,通过2883端口登录
obclient -h192.168.0.101 -P2883 -uroot@proxysys -p'root.123' -Doceanbase -A
安装ob-configserver
su oceanbase
1.配置
vi /home/oceanbase/obconfigserver.yaml
内容如下
ob-configserver:
servers:
- 192.168.0.101
global:
listen_port: 8071 # The port of ob-configserver web
server_ip: 0.0.0.0 # Listen to the ob-configserver server IP。When you want to listen to the specified IP address,use it.
home_path: /data/Oceanbase/ob-configserver
2.发布
obd cluster component add obtest -c obconfigserver.yaml
注册 OceanBase 集群
obd cluster edit-config obtest
将 obconfig_url 配置到 oceanbase-ce 组件的 global 模块下
重新加载集群
obd cluster reload obtest
查看是否注册
obd cluster display obtest
http://192.168.0.101:8071/services?Action=GetObProxyConfig
返回结果的ObRootServiceInfoUrlList 中包含集群名为 test 的 OceanBase 集群的信息,表示该集群已被注册到 obconfigserver 中。
启动 ODP
可执行 obd cluster edit-config obtest命令打开配置文件,直接在配置文件中 obproxy-ce 组件的 global 模块下添加如下内容即可:
obproxy_config_server_url: http://192.168.0.101:8071/services?Action=GetObProxyConfig
重启集群
obd cluster restart obtest --wp
安装obbinlog
用于收集 OceanBase 社区版的事务日志并转换为 MySQL Binlog 的服务。
已知系统安装的数据库版本为4.3.5.4,查到对应的obbinlog支持版本为4.2.10
obbinlog文档https://www.oceanbase.com/docs/common-oblogproxy-doc-1000000003867565
安装
1.下载
2.安装
sudo rpm -ivh --prefix=/data/Oceanbase/obbinlog /home/oceanbase/obbinlog-ce-4.2.10-100000032025082811.el7.x86_64.rpm
3.配置环境
cd /data/Oceanbase/obbinlog
sudo cp ./deps/lib/libstdc++.so.6.0.28 /usr/lib64/
cd /usr/lib64
sudo ln -sf libstdc++.so.6.0.28 libstdc++.so.6
4.安装依赖
sudo yum install -y jq mysql diffutils
5.配置并启动 Binlog Server
修改 env/deploy.conf.json
{
"host": "192.168.0.101",
"port": 3306,
"user": "test",
"password": "test@123",
"database": "oceanbase_log",
"sys_user": "root",
"sys_password": "root.123",
"supervise_start": "false",
"init_schema": "true",
"node_ip": "192.168.0.101"
}
6.启动Binlog Server 节点
sudo sh env/deploy.sh -m deploy -f env/deploy.conf.json
若报错
Given 'node_ip': '192.168.0.101' is different with output of 'hostname -i': 'fe80::935e:6a1:8f24:8631%ens33 fe80::42:d8ff:feca:d471%docker0 192.168.0.101 172.17.0.1 172.20.0.1'
Will you continue to use '192.168.0.101' ? [Y/n]y
{
"res": "FAILED",
"msg": "start binlog failed",
"log": "/data/Oceanbase/obbinlog/log/deploy.log"
}
直接查看库里是否生成表,若生成表,则直接执行
sudo ./run.sh start
若报错
2025-10-10 13:32:00.901568\] \[warning\] mysql_connecton_wrapper.cpp(40): Failed to obtain connection, try to reconnect \[2025-10-10 13:32:00.902828\] \[error\] mysql_connecton_wrapper.cpp(179): Failed to connect to mariadb platform: Could not connect to address=(host=192.168.0.101)(port=3306)(type=master) : Plugin caching_sha2_password could not be loaded: /home/jenkins/agent/workspace/ob_artifacte_local_artifact/ob_source_code_dir/packenv/third-party/install/mariadb-connector-cpp/lib64/mariadb/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory,url:jdbc:mariadb://192.168.0.101:3306/oceanbase_log 去元数据执行SELECT User, Host, plugin FROM mysql.user; 发现root是caching_sha2_password,换成test用户(支持mysql_native_password),将oceanbase_log库授权给test 7.验证进程是否启动 netstat -ntulp \|grep 2983 连接查询 mysql -h127.0.0.1 -uroot -P2983 创建Binlog 任务 1.确认租户、集群、obconfig_url信息 obclient -h192.168.0.101 -P2883 -uroot@mq_t1 -A -p Enter password:root.123 查询以下信息 SHOW PARAMETERS LIKE 'cluster'; SHOW TENANT; SHOW PARAMETERS LIKE 'obconfig_url'; 2.连接Binlog Server mysql -h127.0.0.1 -P2983 3.创建任务 CREATE BINLOG FOR TENANT `obtest`.`mq_t1` TO USER `root` PASSWORD `root.123` WITH CLUSTER URL `http://192.168.0.101:8071/services?Action=ObRootServiceInfo&ObCluster=obtest`, REPLICATE NUM 1; 4.查询任务实例 MySQL \[(none)\]\> SHOW BINLOG INSTANCES; 5.配置 ODP obclient -h192.168.0.101 -P2883 -uroot@proxysys -p'root.123' -Doceanbase -A ALTER proxyconfig SET binlog_service_ip='192.168.0.101:2983'; ALTER proxyconfig SET enable_binlog_service='True'; ## ODP_CE V4.2.3 及之后版本已经移除 enable_binlog_service 配置项,因此如果报错显示该配置项不存在可以忽略。 6.(可选)如果希望 Binlog 服务执行 SHOW CREATE TABLE 时的返回结果完全兼容 MySQL 语法(即去除 OceanBase 数据库的扩展语法),可执行以下命令。 ALTER proxyconfig SET init_sql='set _show_ddl_in_compat_mode = 1;'; 7.验证配置是否正确,如查看 binlog_service_ip 配置: SHOW PROXYCONFIG LIKE 'binlog_service_ip'; 8.验证结果 使用 ODP 连接到 Binlog 任务对应的租户 obclient -h192.168.0.101 -P2883 -uroot@mq_t1 -p'root.123' -Doceanbase -A 查看 Binlog 文件 SHOW MASTER STATUS; 9.查看所有 Binlog 事件 SHOW BINLOG EVENTS; 验证 建库建表 create database wwdl_test; CREATE TABLE wwdl_test.`ftp01_test_csv` ( `id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT 'id', `desc1` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'desc1', `desc2` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'desc2', `batch_job_dt` varchar(50) COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务数据日期', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='csv换行测试'; INSERT INTO `wwdl_test`.`ftp01_test_csv`(`id`, `desc1`, `desc2`, `batch_job_dt`) VALUES ('1', '又换行\\n黄河', '和', '20250811'); INSERT INTO `wwdl_test`.`ftp01_test_csv`(`id`, `desc1`, `desc2`, `batch_job_dt`) VALUES ('2', '无换行', '丰,富', '20250811'); INSERT INTO `wwdl_test`.`ftp01_test_csv`(`id`, `desc1`, `desc2`, `batch_job_dt`) VALUES ('3', '右换行\\n哈哈\\n嘎嘎', '调度\\n打的', '20250811'); 再次查看Binlog 文件,发现有变化即代表服务正常。 卸载 Linux完全卸载OceanBase单机版 1. 查看OB集群信息 obd cluster list 2. 停止demo库 obd cluster stop demo 3. 删除demo obd cluster destroy demo 若集群为configured状态,直接删文件即可。 rm -rf /home/oceanbase/.obd/cluster/obbinlog 若提示集群中有服务在运行不能销毁 netstat -ntulp \|grep 2881 tcp 0 0 0.0.0.0:2881 0.0.0.0:\* LISTEN 24243/observer \[root@101db oceanbase\]# kill -9 24243 再次检查,看是否销毁所有集群 obd cluster list 4. 删除OB部署介质及环境变量 \[root@tidb01 oceanbase-all-in-one\]# ./bin/uninstall.sh \~/.bash_profile\[root@tidb01 oceanbase-all-in-one\]# vi \~/.bash_profile #删除下面这一行 source /root/.oceanbase-all-in-one/bin/env.sh cdc问题记录 1.Flink CDC 读取 Oceanbase binlog, 报错: Timeout to receive log messages in LogProxyClient.RecordListener 解决:从binlog 模式切换为cdc 模式后可以正常进行数据同步了, 没有出现binlog 模式中遇到的问题; 具体操作是, 修改 oblogproxy 目录下的 conf/conf.json 配置文件, 将 binlog_mode改为 false 重启obbinlog。