首批通过分布式安全可靠测评,为关键业务系统打造
实例管理
更新时间:2026-04-15 16:28:52
创建 Binlog 实例
该命令主要用于为已开通 Binlog 的租户添加新的 Binlog 实例,需要注意的是,此处新创建的 Binlog 实例不会沿用已有的 Binlog 实例参数配置,配置项需要在 SQL 中显式地指定。
说明
为租户开通 Binlog 的命令介绍可参见 任务管理 中 创建 Binlog 任务 小节。
语法
CREATE BINLOG INSTANCE instance_name
FOR cluster.tenant cluster_url [, binlog_instance_option [, binlog_instance_option...]];
binlog_instance_option:
obcdc_option
| binlog_option
obcdc_option:
START_TIMESTAMP
| ROOTSERVER_LIST
| CLUSTER_USER
| CLUSTER_PASSWORD
| EXTRA_OBCDC_CFG
binlog_option:
MASTER_SERVER_ID
| MASTER_SERVER_UUID
| SERVER_ID
| SERVER_UUID
| BINLOG_EXPIRE_LOGS_SECONDS
| BINLOG_EXPIRE_LOGS_SIZE
| MAX_BINLOG_SIZE
| AUTO_START_OBCDC
| ACTIVE_STATE_AFTER_BOOT
| FAILOVER
| _INITIAL_OB_TXN_ID
| _INITIAL_OB_TXN_GTID_SEQ
参数介绍
| 参数 | 描述 |
|---|---|
| instance_name | Binlog 实例名,不可和 Binlog 集群中其他 Binlog 实例名重复。 |
| cluster.tenant | 待创建 Binlog 实例的租户名以及租户所在的集群名。 |
| cluster_url | OceanBase 集群的 config url,配置时需使用引号包裹。可通过 SHOW PARAMETERS LIKE 'obconfig_url'; 获得(value 值)。 |
| binlog_instance_option | 可选项,Binlog 实例的相关配置,多个选项之间使用英文逗号(,)间隔。配置时需使用英文逗号(,)与 cluster_url 隔开。可配置内容如下:
|
示例
为
obdemo集群的test1租户创建名为binlog1的实例。CREATE BINLOG INSTANCE binlog1 FOR obdemo.test1 CLUSTER_URL='http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=obdemo';为
obdemo集群的test1租户创建名为binlog2的实例,并指定 obcdc 配置。CREATE BINLOG INSTANCE binlog2 FOR obdemo.test1 CLUSTER_URL='http://10.10.10.1:8080/services?Action=ObRootServiceInfo&ObCluster=obdemo',EXTRA_OBCDC_CFG = 'memory_limit=6G progress_limit_sec_for_dml=30';
查询 Binlog 实例
用于查询 Binlog 实例相关信息,存在相关记录将返回一到多条记录,若无符合条件记录则返回空集。
语法
SHOW BINLOG INSTANCES {
FOR cluster.tenant
| [instance_name [, instance_name...]]
};
参数说明
| 参数 | 描述 |
|---|---|
| cluster.tenant | 待查询 Binlog 实例的租户名以及租户所在的集群名。 |
| instance_name | 待查询的 Binlog 实例名,可配置多个实例名,多个实例名之间使用英文逗号(,)分割。 |
示例
查询
obdemo集群test1租户中的 Binlog 实例信息SHOW BINLOG INSTANCES FOR obdemo.test1;查询指定 Binlog 实例的信息
SHOW BINLOG INSTANCES `eo46r4f2e8`,`gldwt7bnco`;
命令输出如下:
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| name | ob_cluster | ob_tenant | ip | port | zone | region | group | running | state | obcdc_running | obcdc_state | service_mode | convert_running | convert_delay | convert_rps | convert_eps | convert_iops | dumpers | version | odp_addr |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| eo46r4f2e8 | obdemo | test1 | 10.10.10.1 | 8104 | | | | Yes | Running | Yes | Running | enabled | Yes | 578 | 1 | 0 | 0 | 0 | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL |
| gldwt7bnco | obdemo | test1 | 10.10.10.1 | 8103 | | | | Yes | Running | Yes | Running | enabled | Yes | 478 | 1 | 0 | 0 | 0 | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
结果集说明:
| 字段 | 说明 |
|---|---|
| name | Binlog 实例名。 |
| ob_cluster | OceanBase 集群名。 |
| ob_tenant | OceanBase 集群租户名。 |
| ip | Binlog 实例所在节点。 |
| port | Binlog 实例 MySQL 服务端口,若为 0 表示还未分配出服务端口。 |
| zone | Binlog 实例所在 Zone。 |
| region | Binlog 实例所在 Region。 |
| group | Binlog 实例所在逻辑分组。 |
| running | 实例是否在运行中,有 Yes 和 No 两种输出值。 |
| state | Binlog 实例状态。 |
| obcdc_running | obcdc 是否在运行中,有 Yes 和 No 两种输出值。 |
| obcdc_state | obcdc 状态。 |
| service_mode | Binlog 实例对外服务状态,有 enabled 和 disabled 两种输出值。 |
| convert_running | Binlog 实例日志格式转换进程是否在运行中,有 Yes 和 No 两种输出值。 |
| convert_delay | Binlog 实例转换日志的延迟。 |
| convert_rps | Binlog 实例每秒转换的 records 数量。 |
| convert_eps | Binlog 实例每秒生产的 events 数量。 |
| convert_iops | Binlog 实例每秒生产的 events 大小。 |
| dumpers | Binlog 实例 dumpers 数量。 |
| version | obbinlog 版本号。 |
| odp_addr | 保留字段。 |
修改 Binlog 实例
用于修改指定 Binlog 实例的参数配置。
语法
ALTER BINLOG INSTANCE instance_name
SET binlog_instance_option [, binlog_instance_option...];
参数说明
| 参数 | 描述 |
|---|---|
| instance_name | 待修改参数的 Binlog 实例名。 |
| binlog_instance_option | 待修改的参数,当前仅支持以下参数:
|
示例
修改 binlog1 实例中 binlog 文件的有效时间为 6 天(518400 秒)。
ALTER BINLOG INSTANCE binlog1 SET BINLOG_EXPIRE_LOGS_SECONDS = 518400;
修改
binlog3实例中 obcdc 参数配置修改 obcdc 参数前需先查看对应实例下
binlog_instance.conf文件中的cdc_config.extra_obcdc_cfg值,实例文件存放在run目录下。执行修改命令时,需在cdc_config.extra_obcdc_cfg值后添加需要修改的 obcdc 参数。说明
若
cdc_config.extra_obcdc_cfg中包含待修改的 obcdc 参数,您需直接修改对应参数值,而不是在cdc_config.extra_obcdc_cfg后添加需要修改的 obcdc 参数。修改 Binlog 实例的 obcdc 参数后,需要重启实例使改动生效。
此处以修改
enable_output_virtual_generated_column值为例,您需将示例中的<cdc_config.extra_obcdc_cfg>替换为实际查看到的cdc_config.extra_obcdc_cfg值。ALTER BINLOG INSTANCE binlog3 SET EXTRA_OBCDC_CFG = '<cdc_config.extra_obcdc_cfg> enable_output_virtual_generated_column=1';
停止 Binlog 实例
用于停止指定 Binlog 实例。
语法
STOP BINLOG INSTANCE instance_name;
instance_name 为待停止的 Binlog 实例名。
示例
以停止实例名为 eo46r4f2e8 的 Binlog 实例为例,命令如下:
STOP BINLOG INSTANCE eo46r4f2e8;
停止后可执行 SHOW BINLOG INSTANCES eo46r4f2e8; 命令查看 Binlog 实例状态,停止后输出中 state 会变为 Stop,示例如下:
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| name | ob_cluster | ob_tenant | ip | port | zone | region | group | running | state | obcdc_running | obcdc_state | service_mode | convert_running | convert_delay | convert_rps | convert_eps | convert_iops | dumpers | version | odp_addr |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
| eo46r4f2e8 | obdemo | test1 | 10.10.10.1 | 8106 | | | | No | Stop | No | Stop | disabled | No | NULL | NULL | NULL | NULL | NULL | 4.0.1-92748c6c59534426d187977b13b61b7cdf4fa200 | NULL |
+------------+------------+-----------+---------------+------+------+--------+-------+---------+---------+---------------+-------------+--------------+-----------------+---------------+-------------+-------------+--------------+---------+------------------------------------------------+----------+
启动 Binlog 实例
用于启动指定 Binlog 实例。
语法
START BINLOG INSTANCE instance_name;
instance_name 为待启动的 Binlog 实例名。
示例
以启动实例名为 eo46r4f2e8 的 Binlog 实例为例,命令如下:
START BINLOG INSTANCE eo46r4f2e8;
切换主 Binlog 实例
用于手动切换指定租户的主 Binlog 实例。
语法
SWITCH MASTER INSTANCE TO instance_name FOR TENANT cluster.tenant [FULL]
参数说明
| 参数 | 描述 |
|---|---|
| instance_name | 待切换为主 Binlog 实例的 Binlog 实例名。 |
| cluster.tenant | 待切换的 Binlog 实例所属的租户名,以及对应租户所在的集群名。 |
| FULL | 可选值,控制是否断开原主 Binlog 实例的存量订阅连接。无需传值,配置即表示断开连接。 |
示例
以 obdemo 集群 test1 租户中的 Binlog 实例为例,示例如下:
查看主 Binlog 实例所在的节点
SHOW BINLOG SERVER FOR TENANT obdemo.test1;输出如下,主 Binlog 实例为
10.10.10.1的8103端口对应实例:+---------+--------+------------+------+--------+-------+ | cluster | tenant | ip | port | status | cause | +---------+--------+------------+------+--------+-------+ | obdemo | test1 | 10.10.10.1 | 8103 | OK | NULL | +---------+--------+------------+------+--------+-------+切换主 Binlog 实例
SWITCH MASTER INSTANCE TO eo46r4f2e8 FOR TENANT obdemo.test1;再次查看主 Binlog 实例所在节点信息
SHOW BINLOG SERVER FOR TENANT obdemo.test1;输出如下,主 Binlog 实例切换为了
10.10.10.1的8106端口对应实例:+---------+--------+------------+------+--------+-------+ | cluster | tenant | ip | port | status | cause | +---------+--------+------------+------+--------+-------+ | obdemo | test1 | 10.10.10.1 | 8106 | OK | NULL | +---------+--------+------------+------+--------+-------+
释放 Binlog 实例
用于删除指定的 Binlog 实例,Binlog 文件也会被同步清理。
语法
DROP BINLOG INSTANCE instance_name [FORCE]
参数说明
| 参数 | 描述 |
|---|---|
| instance_name | 待删除的 Binlog 实例名。 |
| FORCE | 可选值,控制是否强制删除 Binlog 实例。配置后可以删除正在运行的 Binlog 实例,若未配置 FORCE 且指定的 Binlog 实例未停止,执行 DROP 命令会报错。 |
示例
强制删除名为 binlog2 的实例:
DROP BINLOG INSTANCE binlog2 FORCE;