首批通过分布式安全可靠测评,为关键业务系统打造
通过命令行部署 OBLogProxy
更新时间:2026-04-14 17:55:41
本文以 全组件部署 和 最小化部署 两种场景为例,介绍如何使用命令行部署 OBLogProxy。
说明
本文默认所使用的机器可以连接公网,或者已配置好所需软件(OceanBase、ODP、OBLogProxy、Config Server 等)。配置所需软件的详细操作可参考 安装并配置 OBD 中 配置 OBD。
组件介绍
OBProxy
OceanBase Database Proxy,OceanBase 数据库代理,是 OceanBase 数据库专用的代理服务器,简称为 ODP(又称为 OBProxy)。详细信息请参见 OceanBase 数据库代理。
Config Server
OceanBase Configserver,Config Server 可提供 OceanBase 的元数据注册,存储和查询服务。详细信息请参见 ob-configserver。
OBLogProxy
OceanBase 的增量日志代理服务,它可以与 OceanBase 建立连接并进行增量日志读取,为下游服务提供了变更数据捕获(CDC)的能力。详细信息请参见 OceanBase 日志代理服务文档。
配置文件
OBD 提供了部署 OBLogProxy 所需的配置文件示例,您可根据自身机器资源情况进行修改。
若您机器中的 OBD 是通过直接下载的方式安装,则可在
/usr/obd/example/oblogproxy目录下查看 OBD 提供的 OBLogProxy 配置文件示例。若您机器中的 OBD 是通过解压 all-in-one 安装包的方式安装,则可在
~/.oceanbase-all-in-one/obd/usr/obd/example/oblogproxy目录下查看 OBD 提供的 OBLogProxy 配置文件示例。您也可在 OBD 的 GitHub 仓库 中查看 OBD 提供的 OBLogProxy 配置文件示例。
OBD 提供的和部署 OBLogProxy 相关的配置文件示例有如下几个。
全组件部署(oceanbase-ce、obproxy-ce、ob-configserver、oblogproxy):distributed-with-obproxy-and-oblogproxy-example.yaml
最小化部署(仅部署 OBLogProxy):oblogproxy-only-example.yaml
前提条件
部署 OBLogProxy 前,您需确认已安装 V2.5.0 或之后版本的 obd。若您环境中 obd 为 V2.5.0 之前版本,可参考 常见问题 中 如何升级 obd 一节升级 obd。
操作步骤
本节介绍如下两种部署方法,您可根据实际需要选择合适的方法:
全组件部署:当前环境中未部署任何 OceanBase 组件,所有组件(oceanbase-ce、obproxy-ce、ob-configserver、oblogproxy)均由 OBD 在一个集群中进行部署。
说明
若使用 OBLogProxy 的 Binlog Service 服务,必须部署 OBProxy 和 Config Server。
最小化部署:环境中已存在 OceanBase 集群,需要使用 OBLogProxy 的服务,此时仅需要部署 OBLogProxy。若 OBLogProxy 为 Binlog Service 模式,需提前部署 OBProxy 和 Config Server。
此处以 distributed-with-obproxy-and-oblogproxy-example.yaml 配置文件为例,介绍如何部署 OBLogProxy。
配置用户信息
配置文件中,用户信息相关的配置如下:
## 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为登录到目标机器的用户名,确保您的用户名有home_path的写权限。password和key_file均用于验证用户,通常情况下只需要填写一个。注意
在配置秘钥路径后,如果您的秘钥不需要口令,请注释或者删除
password,以免password被视为秘钥口令用于登录,导致校验失败。配置 oceanbase-ce 组件
部署 OBLogProxy 时需要为 OBLogProxy 创建一个拥有只读权限的用户(
cdcro@sys)。cdcro@sys用户归属于 OceanBase 数据库,OBLogProxy 仅拥有该用户的使用权。注意
OBD V2.6.x 仅支持部署 OceanBase 数据库 V4.2.2 及之前版本。
配置文件中,oceanbase-ce 组件的配置信息如下:
oceanbase-ce: servers: - name: server1 # Please don't use hostname, only IP can be supported ip: 10.10.10.1 - name: server2 ip: 10.10.10.2 - name: server3 ip: 10.10.10.3 depends: - ob-configserver global: memory_limit: 64G # The maximum running memory for an observer # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. system_memory: 30G datafile_size: 192G # Size of the data file. log_disk_size: 192G # The size of disk space used by the clog files. enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false. max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0. # observer cluster name, consistent with obproxy's cluster_name appname: obcluster root_password: ******** # root user password, can be empty proxyro_password: ******** # proxyro user password, consistent with obproxy's observer_sys_password, can be empty cdcro_password: ******** # cdcro user password, consistent with oblogproxy's observer_sys_password, can be empty server1: mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /home/admin/observer # The directory for data storage. The default value is $home_path/store. # data_dir: /data # The directory for clog, ilog, and slog. The default value is the same as the data_dir value. # redo_dir: /redo zone: zone1 server2: mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /home/admin/observer # The directory for data storage. The default value is $home_path/store. # data_dir: /data # The directory for clog, ilog, and slog. The default value is the same as the data_dir value. # redo_dir: /redo zone: zone2 server3: mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /home/admin/observer # The directory for data storage. The default value is $home_path/store. # data_dir: /data # The directory for clog, ilog, and slog. The default value is the same as the data_dir value. # redo_dir: /redo zone: zone3详细的配置项介绍可参见 配置文件说明 中 配置项说明 章节下 OceanBase 数据库 部分介绍。与单独部署 OceanBase 集群相比,配置文件中新增了配置项
cdcro_password,该配置项用于配置cdcro@sys用户密码,未配置的情况下,OBD 会自动生成随机字符串。配置 obproxy-ce 和 ob-configserver 组件
若无需使用 OBLogProxy 的 Binlog Service 服务,可不部署 OBProxy 和 Config Server。配置文件中,obproxy-ce 和 ob-configserver 组件的配置信息如下:
obproxy-ce: depends: - oceanbase-ce servers: - 10.10.10.1 global: listen_port: 2883 # External port. The default value is 2883. prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884. home_path: /home/admin/obproxy enable_cluster_checkout: false # observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. # cluster_name: obcluster skip_proxy_sys_private_check: true enable_strict_kernel_release: false obproxy_sys_password: ******** # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. # observer_sys_password: # proxyro user password, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. ob-configserver: servers: - 10.10.10.1 global: listen_port: 8080 # 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: /home/admin/ob-configserver # The working directory for prometheus. ob-configserver is started under this directory. This is a required field. ## log config # log_level: info # Log printing level of ob-configserver。The default value is `info` # log_maxsize: 30 # The total size of manager ob-configserver.Log size is measured in Megabytes.The default value is 30 # log_maxage: 7 # The days of manager expired ob-configserver.Log retention days. The default value is 7 # log_maxbackups: 10 #The number of manager expired ob-configserver.Log. The default value is 10 # log_localtime: true # Switch of ob-configserver.Log naming with localtime. The default value is true # log_compress: true # Compress ob-configserver.Log switch. The default value is true ## vip config, configserver will generate url with vip_address and port and return it to the client ## do not use some random value that can't be connected # vip_address: "10.10.10.1" # vip_port: 8080 ## storage config # storage: # database_type: sqlite3 # sqlite3 or mysql. Default sqlite3 # connection_url: "" # When database_type is set to sqlite3, the connection_url parameter can be left empty. If it is empty, the default value $home_path/.data.db?cache=shared&_fk=1 will be used. When database_type is set to mysql, the connection_url parameter must be configured, with a sample value of user:password@tcp(10.10.10.1:2883)/test?parseTime=true.详细的配置项介绍可参见 配置文件说明 中 配置项说明 章节下 ODP 和 Config Server 部分介绍。
配置 oblogproxy 组件
配置文件中,oblogproxy 组件的配置信息如下:
oblogproxy: version: 2.0.0 depends: - oceanbase-ce - obproxy-ce servers: - 10.10.10.1 global: home_path: /home/admin/oblogproxy service_port: 2983 # binlog_dir: /home/admin/oblogproxy/run # The directory for binlog file. The default value is $home_path/run. # binlog_mode: true # enable binlog mode, default true配置文件中配置 oblogproxy 依赖于 oceanbase-ce 和 obproxy-ce 组件,配置文件介绍如下:
配置项 是否必选 默认值 说明 version 可选 默认部署最新版本 指定待部署组件版本,通常情况下不需要指定。 servers 必选 无 每台机器需要用 - name: 机器标识名 (换行)ip: 机器 IP指定,也可以使用- <ip>的格式指定,此时- <ip>的格式相当于- name: 机器标识名(换行)ip: 机器 IP。home_path 必选 无 OBLogProxy 的安装路径。 service_port 必选 2983 OBLogProxy 服务监听端口。 binlog_dir 可选 $home_path/run Binlog 服务目录根路径,需配置为绝对路径。 binlog_mode 可选 true 控制是否开启 Binlog 模式。 其他 OBLogProxy 相关配置项可参见《OceanBase 日志代理服务》文档中 配置文件 一文,需要注意如下几点:
使用 OBD 部署 OBLogProxy 时,OBD 中的
binlog_dir配置项对应 OBLogProxy 原本的binlog_log_bin_basename配置项。使用 OBD 部署 OBLogProxy 时,
binlog_mode配置项的默认值为true。
部署集群
[admin@test001 ~]$ obd cluster deploy obtest -c distributed-with-obproxy-and-oblogproxy-example.yaml联网情况下,在您执行了
obd cluster deploy命令之后,OBD 将检查本地镜像库中是否有部署所需安装包。如果没有安装包,OBD 将自动从 YUM 源获取。启动集群
[admin@test001 ~]$ obd cluster start obtest查看集群状态
[admin@test001 ~]$ obd cluster display obtest
此处以 oblogproxy-only-example.yaml 配置文件为例,介绍如何部署 OBLogProxy。
配置用户信息
配置文件中,用户信息相关的配置如下:
## 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为登录到目标机器的用户名,确保您的用户名有home_path的写权限。password和key_file均用于验证用户,通常情况下只需要填写一个。注意
在配置秘钥路径后,如果您的秘钥不需要口令,请注释或者删除
password,以免password被视为秘钥口令用于登录,导致校验失败。配置 oblogproxy 组件
配置文件中,oblogproxy 组件的配置信息如下:
oblogproxy: version: 2.0.0 servers: - 10.10.10.1 global: home_path: /home/admin/oblogproxy service_port: 2983 ob_sys_username: cdcro # A user under the sys tenant of oceanbase-ce, oblogproxy communicates with oceanbase-ce using this user, default '' ob_sys_password: ******** # ob_sys_username`s password, default '' # binlog_dir: /home/admin/oblogproxy/run # The directory for binlog file. The default value is $home_path/run. # binlog_mode: true # enable binlog mode, default true配置项介绍如下:
配置项 是否必选 默认值 说明 version 可选 默认部署最新版本 指定待部署组件版本,通常情况下不需要指定。 servers 必选 无 每台机器需要用 - name: 机器标识名 (换行)ip: 机器 IP指定,也可以使用- <ip>的格式指定,此时- <ip>的格式相当于- name: 机器标识名(换行)ip: 机器 IP。home_path 必选 无 OBLogProxy 的安装路径。 service_port 必选 2983 OBLogProxy 服务监听端口。 ob_sys_username 可选 默认为空 OBLogProxy 与 OceanBase 数据库通信的用户名,需要是 sys 租户下的用户,需提前创建。此处的用户名仅需配置 user_name,不需要包含集群名称或租户名称。 ob_sys_password 可选 默认为空 ob_sys_username配置项对应用户的密码,需与 OceanBase 数据库中对应用户的密码保持一致。binlog_dir 可选 $home_path/run Binlog 服务目录根路径,需配置为绝对路径。 binlog_mode 可选 true 控制是否开启 Binlog 模式。 其他 OBLogProxy 相关配置项可参见《OceanBase 日志代理服务》文档中 配置文件 一文,需要注意如下几点:
使用 OBD 部署 OBLogProxy 时,OBD 中的
binlog_dir配置项对应 OBLogProxy 原本的binlog_log_bin_basename配置项。使用 OBD 部署 OBLogProxy 时,
binlog_mode配置项的默认值为true。使用 OBD 部署 OBLogProxy 时,
ob_sys_username和ob_sys_password配置项需配置为明文。
部署 OBLogProxy
[admin@test001 ~]$ obd cluster deploy obtest -c oblogproxy-only-example.yaml联网情况下,在您执行了
obd cluster deploy命令之后,OBD 将检查本地镜像库中是否有部署所需安装包。如果没有安装包,OBD 将自动从 YUM 源获取。启动 OBLogProxy
[admin@test001 ~]$ obd cluster start obtest查看 OBLogProxy 状态
[admin@test001 ~]$ obd cluster display obtest
验证
根据是否开启 Binlog 模式(binlog_mode),有如下两种验证方法。
方法一:
binlog_mode配置为true时,您可复制启动成功后 OBD 打印的连接串并执行,验证是否可以成功连接 OBLogProxy。obclient -h10.10.10.1 -P2983方法二:
binlog_mode配置为false时,您可在 OBLogProxy 所在机器执行如下命令,查看是否有 oblogproxy 进程。ps axu | grep logproxy输出如下:
admin 10493 1.1 0.0 634812 2940 ? Sl 16:21 0:07 /home/admin/oblogproxy/bin/logproxy -f /home/admin/oblogproxy/conf/conf.json admin 18071 0.0 0.0 112812 980 pts/1 S+ 16:32 0:00 grep --color=auto logproxy
相关文档
您可使用 OBD 对管理部署的 OBLogProxy,如启动、停止、重启、销毁等,详细的命令使用可参见 集群命令组。需要注意的是,执行
obd cluster stop命令停止 OBLogProxy 时,OBD 只会停止 oblogproxy 进程,不会停止 Binlog 进程(binlog_converter)。Binlog 模式的详细介绍,以及部署 OBLogProxy 后如何使用 Binlog Service 服务的详细操作可参见《OceanBase 日志代理服务》文档中 Binlog 模式。
说明
全组件部署场景下,OBD 会自动在 OceanBase 数据库中创建
cdcro用户并配置到 OBLogProxy 的配置文件中,您在创建 Binlog 服务时无需配置用户信息。最小化部署场景下,若您已配置有效的用户名和密码,OBD 会自动配置到 OBLogProxy 的配置文件中,您在创建 Binlog 服务时无需配置用户信息。