---
title: "部署 obbinlog | OceanBase 文档中心"
description: 部署 obbinlog 部署 obbinlog 时，您可以选择单独部署，也可以和将 OceanBase 数据库作为 MetaDB 一起部署，本文分别介绍如何操作。 前提条件 您的机器中已安装 V3.1.0 或之后版本的 obd，建议安装最新版本，安装操作可参见 安装 obd 。 当依赖 OceanBase 数据库部署…
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*Qq8pT6yBPTcAAAAAAAAAAAAADiGDAQ/original) 安装部署工具 OBDV 3.2.0 社区版

# 部署 obbinlog

更新时间：2026-04-14 17:55:42

[编辑](https://github.com/oceanbase/obd-doc/edit/V3.2.0/zh-CN/400.user-guide/300.command-line-operations/200.deploy-component/355.deploy-binlog.md)  

部署 obbinlog 时，您可以选择单独部署，也可以和将 OceanBase 数据库作为 MetaDB 一起部署，本文分别介绍如何操作。

## 前提条件

- 您的机器中已安装 V3.1.0 或之后版本的 obd，建议安装最新版本，安装操作可参见 [安装 obd](https://www.oceanbase.com/docs/community-obd-cn-1000000002691290)。
 - 当依赖 OceanBase 数据库部署 obbinlog 时，OceanBase 数据库需为 V4.2.1.0 或以上版本。
 - 您的机器可以联网，或者 obd 本地镜像库中有部署所需安装包。

  可执行 `obd mirror list local` 命令查看本地镜像库中的安装包。离线场景下上传安装包到本地镜像库的操作可参见 [安装 obd](https://www.oceanbase.com/docs/community-obd-cn-1000000002691290) 中 **使用 RPM 安装** 部分。

## 操作步骤

#### 说明

本文默认所使用的机器可以连接公网，或者已配置好所需软件（OceanBase 数据库、obbinlog 等）。

启动 obbinlog 依赖元数据库，本节分为 **部署 obbinlog 及 MetaDB（OceanBase 数据库）** 和 **已有 MetaDB 部署 obbinlog** 两种方法介绍如何部署 Binlog 服务：

- **部署 obbinlog 及 MetaDB（OceanBase 数据库）**：可在配置文件中同时配置 OceanBase 数据库和 obbinlog 信息，启动 obbinlog 时，会根据配置启动 OceanBase 数据库作为 Binlog 服务的元数据库。
 - **已有 MetaDB 部署 obbinlog**：您需确保已存在可用作 Binlog 服务元数据库的 OceanBase 数据库或 MySQL 数据库。

    部署 obbinlog 及 MetaDB（OceanBase 数据库）   已有 MetaDB 部署 obbinlog

1. 创建配置文件

   执行如下命令创建配置文件，此处以 `distributed-binlog.yaml` 为例，您可自定义配置文件名。完整配置文件内容可参见下文 [配置文件示例](#配置文件示例)。

   ```shell
   vim distributed-binlog.yaml

   ```
 2. 修改用户信息

   您可复制如下内容，根据自身实际场景进行修改。

   ```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 30

   ```

   `username` 为登录到目标机器的用户名，确保您的用户名有家目录的写权限。`password` 和 `key_file` 均用于验证用户，通常情况下只需要填写一个。

   #### 注意

   在配置秘钥路径后，如果您的秘钥不需要口令，请注释或者删除 `password`，以免 `password` 被视为秘钥口令用于登录，导致校验失败。
 3. 修改 OceanBase 数据库配置

   您可复制如下内容，根据自身实际场景进行修改。OceanBase 数据库的配置项详细介绍可参见 [配置文件说明](https://www.oceanbase.com/docs/community-obd-cn-1000000002691254) 中 **配置项说明**。

   ```yaml
   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

   ```
 4. 修改 obbinlog 配置

   您可复制如下内容，根据自身实际场景进行修改。配置项的具体含义可参见 [配置文件说明](https://www.oceanbase.com/docs/community-obd-cn-1000000002691254) 中 **配置项说明**。

   ```yaml
   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

   ```
 5. 部署 obbinlog

   ```shell
   obd cluster deploy obbinlog -c distributed-binlog.yaml

   ```

   命令里的 `obbinlog` 为 obbinlog 的部署名，您可根据实际情况自定义部署名。部署成功后命令行会输出对应的启动命令，输出如下：

   ```shell
   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

   ```
 6. 启动 obbinlog

   ```shell
   obd cluster start obbinlog

   ```

   #### 说明

   依赖 OceanBase 数据库启动 obbinlog 时，obd 会自动在 OceanBase 数据库中创建 `binlog` 租户，并将 `root@binlog` 用户充当 Binlog 服务元数据库的连接用户。

   启动成功后会输出集群的相关信息，输出如下：

   ```shell
   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

   ```

1. 创建配置文件

   执行如下命令创建配置文件，此处以文件名为 `binlog-only-example.yaml` 为例，您可自定义配置文件名。完整配置文件内容可参见下文 [配置文件示例](#配置文件示例)。

   ```shell
   vim binlog-only-example.yaml

   ```

   #### 注意

   在配置秘钥路径后，如果您的秘钥不需要口令，请注释或者删除 `password`，以免 `password` 被视为秘钥口令用于登录，导致校验失败。
 3. 修改 obbinlog 配置

   ```yaml
   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

   ```
 4. 部署 obbinlog

   ```shell
   obd cluster deploy obbinlog -c binlog-only-example.yaml

   ```

   ```shell
   obbinlog deployed
   Please execute ` obd cluster start obbinlog ` to start
   Trace ID: f29c81bc-c729-11ef-832f-00163e14c113

   ```
 5. 启动 obbinlog

   ```

   启动成功后会输出 obbinlog 的信息，输出如下：

   ```shell
   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

   ```

## 配置文件示例

    distributed-binlog.yaml   binlog-only-example.yaml

```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 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

```

```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 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

  ```shell
  obd cluster stop obbinlog

  ```

  使用该命令停止 obbinlog 不影响 Binlog 实例，未被停止的 Binlog 实例仍在运行中。
 - 重启 obbinlog

  ```shell
  obd cluster restart obbinlog

  ```

  该命令会轮转重启 obbinlog 及 Binlog 实例。
 - 销毁 Binlog 实例

  ```shell
  obd cluster destroy obbinlog

  ```

  该命令会停止 obbinlog 及 Binlog 实例，并销毁 Binlog 服务目录。
 - 创建 Binlog 实例

  ```shell
  obd binlog create obbinlog obdemo ob_mysql --replicate-num=3

  ```

  该命令会为部署名为 `obdemo` 的集群下的 `ob_mysql` 租户创建三个 Binlog 实例。更多 Binlog 服务的命令介绍可参见 [Binlog 服务命令组](https://www.oceanbase.com/docs/community-obd-cn-1000000002691280)。
 - 升级 obbinlog

  ```shell
  obd cluster upgrade obbinlog -c obbinlog-ce -V 4.2.0

  ```

  obd 自 V3.2.0 起支持升级 obbinlog，且支持升级的目标版本为 V4.2.0 及之后版本。该命令会升级 obbinlog 版本并轮转升级 Binlog 实例。

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
