首批通过分布式安全可靠测评,为关键业务系统打造
部署 oblogproxy
更新时间:2025-11-16 18:11:54
本文以 全组件部署(和 OceanBase 数据库一起部署) 和 添加 oblogproxy 两种场景为例,介绍如何使用命令行部署 oblogproxy。
说明
本文默认所使用的机器可以连接公网,或者已配置好所需软件(OceanBase 数据库、ODP、oblogproxy、obconfigserver 等)。若您通过 OceanBase All in One 安装 obd,本地镜像库中默认包含所有部署所需组件的安装包。
全组件部署:指当前环境中未部署任何 OceanBase 组件,所有组件(oceanbase-ce、obproxy-ce、ob-configserver、oblogproxy)均由 obd 一次性进行部署, obd 需为 V2.5.0 或更高版本。
添加 oblogproxy: 指当前环境中已存在 OceanBase 集群,需要使用 oblogproxy 的服务,此时可以向 OceanBase 集群中添加 oblogproxy。通过 obd 添加 oblogproxy 时,obd 版本需要为 2.9.0 或更高版本,否则,请参考文档 oblogproxy 安装 进行部署。
组件介绍
OBProxy
OceanBase Database Proxy,OceanBase 数据库代理,是 OceanBase 数据库专用的代理服务器,简称为 ODP(又称为 OBProxy)。详细信息请参见 OceanBase 数据库代理文档。
obconfigserver
OceanBase Configserver,obconfigserver 可提供 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 组件:oblogproxy-component-add.yaml
操作步骤
使用场景
当前环境中未部署任何 OceanBase 组件,所有组件(oceanbase-ce、obproxy-ce、ob-configserver、oblogproxy)均由 obd 在一个集群中进行部署。
说明
若使用 oblogproxy 的 Binlog Service 服务,需要部署 OBProxy 和 obconfigserver。
前提条件
部署 oblogproxy 前,您需确认已安装 V2.5.0 或之后版本的 obd,建议安装最新版本,详细安装操作请参见 安装 obd。
同时部署 OceanBase 集群时,需确保 OBServer 节点机器支持 AVX 指令集(仅 x86 架构服务器有此限制)。可执行
lscpu | grep Flags | grep avx命令查看是否支持 AVX 指令集。说明
当使用 x86 架构机器时,若待部署的 OceanBase 数据库版本在以下范围中,不再限制机器是否支持 AVX 指令集:
- 对于 V4.2.x 版本,要求为 V4.2.5.6 或之后版本。
- 对于 V4.3.x 版本,要求为 V4.3.5.4 或之后版本。
- 对于 V4.4.x 版本,要求为 V4.4.1.0 或之后版本。
离线部署场景下,若同时部署 OceanBase 集群,且使用 ARM 架构服务器部署,需查看 OBServer 节点机器是否支持 LSE 指令集,可执行
lscpu | grep Flags | grep atomics命令查看是否支持。若机器不支持 LSE 指令集,需下载带nonlse的 OceanBase 数据库安装包,并使用obd mirror clone命令将安装包上传到 obd 本地镜像库。说明
OceanBase All in One 包中未包含带有
nonlse的 OceanBase 数据库安装包。
操作步骤
此处以 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 仅拥有该用户的使用权。配置文件中,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 scenario: htap 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 和 obconfigserver。
配置文件中,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. rpc_listen_port: 2885 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 和 obconfigserver 部分介绍。
配置 oblogproxy 组件
配置文件中,oblogproxy 组件的配置信息如下:
oblogproxy: 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: 机器 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 时,
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
使用场景
环境中已存在 OceanBase 集群,需要使用 oblogproxy 的服务,此时可以向 OceanBase 集群中添加 oblogproxy。
前提条件
参考本节步骤添加 oblogproxy 前,您需确认已安装 V2.9.0 或之后版本的 obd。若您环境中 obd 为 V2.9.0 之前版本,可参考 升级 obd 内容升级,也可参考文档 oblogproxy 安装 手动部署。
若 oblogproxy 为 Binlog Service 模式,需要提前部署 OBProxy 和 obconfigserver。
操作步骤
此处以 oblogproxy-component-add.yaml 配置文件为例,介绍如何部署 oblogproxy。
配置 oblogproxy 组件
此处以配置文件名为
oblogproxy-component-add.yaml为例,实际操作时您可自由定义文件名。配置文件内容如下:oblogproxy: depends: - oceanbase-ce servers: - 10.10.10.1 version: 2.0.0 global: home_path: /root/oblogproxy service_port: 2983 # External port. The default value is 2983.配置项介绍如下:
配置项 是否必选 默认值 说明 version 可选 默认部署最新版本 指定待部署组件版本,通常情况下不需要指定。 servers 必选 无 每台机器需要用 - name: 机器标识名(换行)ip: 机器 IP指定,也可以使用- <ip>的格式指定,此时- <ip>的格式相当于- name: 机器 IP(换行)ip: 机器 IP。home_path 必选 无 oblogproxy 的安装路径。 service_port 必选 2983 oblogproxy 服务监听端口。 其他 oblogproxy 相关配置项可参见《OceanBase 日志代理服务》文档中 配置文件 一文。
添加 oblogproxy
[admin@test001 ~]$ obd cluster component add obtest -c oblogproxy-component-add.yaml此处以已存在的 OceanBase 集群为
obtest为例,您需根据实际集群名称替换。obd cluster component add命令的详细介绍可参见 集群命令组。命令输出如下:
Check before start oblogproxy ok start oblogproxy ok +--------------------------------+ | oblogproxy | +---------------+-------+--------+ | ip | port | status | +---------------+-------+--------+ | 10.10.10.1 | 2983 | active | +---------------+-------+--------+ obclient -h10.10.10.1 -P2983 test running Trace ID: b082e760-2889-11ef-9e33-00163e0808cc If you want to view detailed obd logs, please run: obd display-trace b082e760-2889-11ef-9e33-00163e0808cc验证是否添加成功
[admin@test001 ~]$ obd cluster display obtest输出中可以看到 oblogproxy 组件信息,即表示 oblogproxy 已成功部署并添加到 OceanBase 集群中。
验证
根据是否开启 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 服务时无需配置用户信息。