首批通过分布式安全可靠测评,为关键业务系统打造
部署 obbinlog
更新时间:2026-04-14 17:55:42
部署 obbinlog 时,您可以选择单独部署,也可以和将 OceanBase 数据库作为 MetaDB 一起部署,本文分别介绍如何操作。
前提条件
您的机器中已安装 V3.1.0 或之后版本的 obd,建议安装最新版本,安装操作可参见 安装 obd。
当依赖 OceanBase 数据库部署 obbinlog 时,OceanBase 数据库需为 V4.2.1.0 或以上版本。
您的机器可以联网,或者 obd 本地镜像库中有部署所需安装包。
可执行
obd mirror list local命令查看本地镜像库中的安装包。离线场景下上传安装包到本地镜像库的操作可参见 安装 obd 中 使用 RPM 安装 部分。
操作步骤
说明
本文默认所使用的机器可以连接公网,或者已配置好所需软件(OceanBase 数据库、obbinlog 等)。
启动 obbinlog 依赖元数据库,本节分为 部署 obbinlog 及 MetaDB(OceanBase 数据库) 和 已有 MetaDB 部署 obbinlog 两种方法介绍如何部署 Binlog 服务:
部署 obbinlog 及 MetaDB(OceanBase 数据库):可在配置文件中同时配置 OceanBase 数据库和 obbinlog 信息,启动 obbinlog 时,会根据配置启动 OceanBase 数据库作为 Binlog 服务的元数据库。
已有 MetaDB 部署 obbinlog:您需确保已存在可用作 Binlog 服务元数据库的 OceanBase 数据库或 MySQL 数据库。
创建配置文件
执行如下命令创建配置文件,此处以
distributed-binlog.yaml为例,您可自定义配置文件名。完整配置文件内容可参见下文 配置文件示例。vim distributed-binlog.yaml修改用户信息
您可复制如下内容,根据自身实际场景进行修改。
## Only need to configure when remote login is required user: username: admin # password: your password if need key_file: /home/admin/.ssh/id_rsa # port: your ssh port, default 22 # timeout: ssh connection timeout (second), default 30username为登录到目标机器的用户名,确保您的用户名有家目录的写权限。password和key_file均用于验证用户,通常情况下只需要填写一个。注意
在配置秘钥路径后,如果您的秘钥不需要口令,请注释或者删除
password,以免password被视为秘钥口令用于登录,导致校验失败。修改 OceanBase 数据库配置
您可复制如下内容,根据自身实际场景进行修改。OceanBase 数据库的配置项详细介绍可参见 配置文件说明 中 配置项说明。
oceanbase-ce: version: 4.3.3.0 # release: 100000242024032211.el7 # package_hash: c4a03c83614f50c99ddb1c37dda858fa5d9b14b7 servers: - name: server1 ip: 10.10.10.1 global: mysql_port: 2881 rpc_port: 2882 home_path: /home/admin/oceanbase obshell_port: 2886 scenario: htap log_disk_size: 20G datafile_size: 20GB production_mode: false enable_syslog_recycle: true enable_syslog_wf: false max_syslog_file_count: 4 root_password: ******** zone: zone1修改 obbinlog 配置
您可复制如下内容,根据自身实际场景进行修改。配置项的具体含义可参见 配置文件说明 中 配置项说明。
obbinlog-ce: depends: - oceanbase-ce servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 global: home_path: /home/admin/obbinlog service_port: 2983 # External port. The default value is 2983. prometheus_port: 2984 # The Prometheus port. The default value is 2984. init_schema: true部署 obbinlog
obd cluster deploy obbinlog -c distributed-binlog.yaml命令里的
obbinlog为 obbinlog 的部署名,您可根据实际情况自定义部署名。部署成功后命令行会输出对应的启动命令,输出如下:obbinlog deployed Please execute ` obd cluster start obbinlog ` to start Trace ID: b524a336-c748-11ef-ab02-00163e14c113 If you want to view detailed obd logs, please run: obd display-trace b524a336-c748-11ef-ab02-00163e14c113启动 obbinlog
obd cluster start obbinlog说明
依赖 OceanBase 数据库启动 obbinlog 时,obd 会自动在 OceanBase 数据库中创建
binlog租户,并将root@binlog用户充当 Binlog 服务元数据库的连接用户。启动成功后会输出集群的相关信息,输出如下:
Wait for observer init ok +-------------------------------------------------+ | oceanbase-ce | +---------------+---------+------+-------+--------+ | ip | version | port | zone | status | +---------------+---------+------+-------+--------+ | 10.10.10.1 | 4.3.3.0 | 2881 | zone1 | ACTIVE | +---------------+---------+------+-------+--------+ obclient -h10.10.10.1 -P2881 -uroot -p'********' -Doceanbase -A cluster unique id: f15c503b-a8e2-50b2-a027-ee1d11886199-1941b9f2469-00030304 +-----------------------------------------+ | obbinlog-ce | +---------------+---------+------+--------+ | ip | version | port | status | +---------------+---------+------+--------+ | 10.10.10.1 | 4.0.1 | 2983 | active | +---------------+---------+------+--------+ obclient -h10.10.10.1 -P2983 obbinlog running Trace ID: b5140f16-c749-11ef-809a-00163e14c113 If you want to view detailed obd logs, please run: obd display-trace b5140f16-c749-11ef-809a-00163e14c113
创建配置文件
执行如下命令创建配置文件,此处以文件名为
binlog-only-example.yaml为例,您可自定义配置文件名。完整配置文件内容可参见下文 配置文件示例。vim binlog-only-example.yaml修改用户信息
您可复制如下内容,根据自身实际场景进行修改。
## Only need to configure when remote login is required user: username: admin # password: your password if need key_file: /home/admin/.ssh/id_rsa # port: your ssh port, default 22 # timeout: ssh connection timeout (second), default 30username为登录到目标机器的用户名,确保您的用户名有家目录的写权限。password和key_file均用于验证用户,通常情况下只需要填写一个。注意
在配置秘钥路径后,如果您的秘钥不需要口令,请注释或者删除
password,以免password被视为秘钥口令用于登录,导致校验失败。修改 obbinlog 配置
您可复制如下内容,根据自身实际场景进行修改。配置项的具体含义可参见 配置文件说明 中 配置项说明。
obbinlog-ce: version: 4.0.1 servers: - name: server1 ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 global: home_path: /home/admin/obbinlog service_port: 2983 # External port. The default value is 2983. prometheus_port: 2984 # The Prometheus port. The default value is 2984. init_schema: true # init meta db, default true meta_host: 10.10.10.1 # meta support ob/mysql meta_port: 2883 meta_username: root@binlog # need tenant exist, if db is mysql, use root or other meta_password: ****** meta_db: binlog_database部署 obbinlog
obd cluster deploy obbinlog -c binlog-only-example.yaml命令里的
obbinlog为 obbinlog 的部署名,您可根据实际情况自定义部署名。部署成功后命令行会输出对应的启动命令,输出如下:obbinlog deployed Please execute ` obd cluster start obbinlog ` to start Trace ID: f29c81bc-c729-11ef-832f-00163e14c113启动 obbinlog
obd cluster start obbinlog启动成功后会输出 obbinlog 的信息,输出如下:
Get local repositories ok Load cluster param plugin ok Open ssh connection ok wait observer usable ok start obbinlog-ce ok obbinlog-ce program health check ok Connect to obbinlog-ce 10.10.10.1:2983 ok +-----------------------------------------+ | obbinlog-ce | +---------------+---------+------+--------+ | ip | version | port | status | +---------------+---------+------+--------+ | 10.10.10.1 | 4.0.1 | 2983 | active | +---------------+---------+------+--------+ obclient -h10.10.10.1 -P2983 obbinlog running Trace ID: 3ee817e8-c72a-11ef-a900-00163e14c113 If you want to view detailed obd logs, please run: obd display-trace 3ee817e8-c72a-11ef-a900-00163e14c113
配置文件示例
## Only need to configure when remote login is required
user:
username: admin
# password: your password if need
key_file: /home/admin/.ssh/id_rsa
# port: your ssh port, default 22
# timeout: ssh connection timeout (second), default 30
oceanbase-ce:
version: 4.3.3.0
# release: 100000242024032211.el7
# package_hash: c4a03c83614f50c99ddb1c37dda858fa5d9b14b7
servers:
- name: server1
ip: 10.10.10.1
global:
mysql_port: 2881
rpc_port: 2882
home_path: /home/admin/oceanbase
obshell_port: 2886
scenario: htap
log_disk_size: 20G
datafile_size: 20GB
production_mode: false
enable_syslog_recycle: true
enable_syslog_wf: false
max_syslog_file_count: 4
root_password: ********
zone: zone1
obbinlog-ce:
depends:
- oceanbase-ce
servers:
- name: server1
ip: 10.10.10.1
- name: server2
ip: 10.10.10.2
global:
home_path: /home/admin/obbinlog
service_port: 2983 # External port. The default value is 2983.
prometheus_port: 2984 # The Prometheus port. The default value is 2984.
init_schema: true
## Only need to configure when remote login is required
user:
username: admin
# password: your password if need
key_file: /home/admin/.ssh/id_rsa
# port: your ssh port, default 22
# timeout: ssh connection timeout (second), default 30
obbinlog-ce:
version: 4.0.1
servers:
- name: server1
ip: 10.10.10.1
- name: server2
ip: 10.10.10.2
global:
home_path: /home/admin/obbinlog
service_port: 2983 # External port. The default value is 2983.
prometheus_port: 2984 # The Prometheus port. The default value is 2984.
init_schema: true # init meta db, default true
meta_host: 10.10.10.1 # meta support ob/mysql
meta_port: 2883
meta_username: root@binlog # need tenant exist, if db is mysql, use root or other
meta_password: ******
meta_db: binlog_database
相关操作
本节以 obd 中 obbinlog 的部署名为 obbinlog 为例介绍如何使用 obd 管控 Binlog 服务。
停止 obbinlog
obd cluster stop obbinlog使用该命令停止 obbinlog 不影响 Binlog 实例,未被停止的 Binlog 实例仍在运行中。
重启 obbinlog
obd cluster restart obbinlog该命令会轮转重启 obbinlog 及 Binlog 实例。
销毁 Binlog 实例
obd cluster destroy obbinlog该命令会停止 obbinlog 及 Binlog 实例,并销毁 Binlog 服务目录。
创建 Binlog 实例
obd binlog create obbinlog obdemo ob_mysql --replicate-num=3该命令会为部署名为
obdemo的集群下的ob_mysql租户创建三个 Binlog 实例。更多 Binlog 服务的命令介绍可参见 Binlog 服务命令组。升级 obbinlog
obd cluster upgrade obbinlog -c obbinlog-ce -V 4.2.0obd 自 V3.2.0 起支持升级 obbinlog,且支持升级的目标版本为 V4.2.0 及之后版本。该命令会升级 obbinlog 版本并轮转升级 Binlog 实例。