---
title: "使用 OCP 接管 OBD 部署的集群 | OceanBase 文档中心"
description: 使用 OCP 接管 OBD 部署的集群 本文将以一个使用配置文件 distributed-example.yaml 启动的 test 部署为例，介绍如何使用 OCP 接管 OBD 部署的集群。 前提条件 请确保您安装的 OBD 版本在 V1.3.0 及以上。 请确保您安装的 OCP 版本在 V3.1.1 及以上。 修…
---
切换语言

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

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

# 使用 OCP 接管 OBD 部署的集群

更新时间：2026-04-13 17:15:40

[编辑](https://github.com/oceanbase/obd-doc/edit/V1.6.1/zh-CN/300.user-guide/400.OCP-takeover-OBD-deployment-cluster.md)  

本文将以一个使用配置文件 distributed-example.yaml 启动的 test 部署为例，介绍如何使用 OCP 接管 OBD 部署的集群。

## 前提条件

- 请确保您安装的 OBD 版本在 V1.3.0 及以上。
 - 请确保您安装的 OCP 版本在 V3.1.1 及以上。

## 修改 OceanBase 集群

### 检查是否满足条件

在使用 OCP 接管 OBD 部署的集群前，您需先使用如下命令检查是否满足接管条件。如条件不满足，则可以根据提示参考下文进行修改。

```shell
obd cluster check4ocp <deploy-name>

# 示例
obd cluster check4ocp test

```

有关 `obd cluster check4ocp` 命令的具体信息请参考 [obd cluster check4ocp](https://www.oceanbase.com/docs/community-obd-cn-10000000001031933)。

### 设置 IDC 信息

默认风格的配置文件不支持配置 IDC 信息，因此需要使用 OBD 1.3.0 版本的新功能，将配置文件风格转换成 cluster 风格。

您可使用如下命令进行转换：

```shell
obd cluster chst <deploy name> --style <STYLE> [-c/--components]

# 示例
obd cluster chst test -c oceanbase-ce --style cluster

```

有关 `obd cluster chst` 命令的具体信息请参考 [obd cluster chst](https://www.oceanbase.com/docs/community-obd-cn-10000000001031933)。

配置风格文件转换完成后，您需使用如下命令进入到编辑模式为 Zone 添加 IDC 信息。

```shell
obd cluster edit-config <deploy name>

# 示例
obd cluster edit-config test

```

有关 `obd cluster edit-config` 命令的具体信息请参考 [obd cluster edit-config](https://www.oceanbase.com/docs/community-obd-cn-10000000001031933)。

参考配置如下：

```yaml
## Only need to configure when remote login is required
# user:
#   username: your username
#   password: your password if need
#   key_file: your ssh-key file path if need
#   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30
oceanbase-ce:
  style: cluster
  config:
    devname: eth0
    memory_limit: 64G
    system_memory: 30G
    datafile_disk_percentage: 20
    syslog_level: INFO
    enable_syslog_wf: false
    enable_syslog_recycle: true
    max_syslog_file_count: 4
    skip_proxy_sys_private_check: true
    enable_strict_kernel_release: false
    mysql_port: 2881
    rpc_port: 2882
    home_path: /root/observer
    root_password: ********
  zones:
    zone1:
      idc: idc1
      servers:
      - name: server1
        ip: xxx.xxx.xxx.xxx
    zone2:
      idc: idc2
      servers:
      - name: server2
        ip: xxx.xxx.xxx.xxx
    zone3:
      idc: idc3
      servers:
      - name: server3
        ip: xxx.xxx.xxx.xxx

```

配置文件修改后，您需运行如下命令使改动生效。

```shell
obd cluster reload <deploy name>

# 示例
obd cluster reload test

```

有关 `obd cluster reload` 命令的具体信息请参考 [obd cluster reload](https://www.oceanbase.com/docs/community-obd-cn-10000000001031933)。

### 配置密码

使用 OCP 接管集群时需要填写 sys 租户下 root 用户连接集群的密码，您可使用如下命令编辑配置文件，并使用 `root_passwd` 来配置密码。

部分配置文件示例如下：

```yaml
## Only need to configure when remote login is required
# user:
#   username: your username
#   password: your password if need
#   key_file: your ssh-key file path if need
#   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30
oceanbase-ce:
servers:
    - name: server1
    # Please don't use hostname, only IP can be supported
    ip: xxx.xxx.xxx.xxx
    - name: server2
    ip: xxx.xxx.xxx.xxx
    - name: server3
    ip: xxx.xxx.xxx.xxx
global:
    # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /root/observer
    # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
    mysql_port: 2881
    # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
    rpc_port: 2882
    # The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.
    memory_limit: 64G
    # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.
    system_memory: 30G
    # Password for root. The default value is empty.
    root_password: ********
    # Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.
    # proxyro_password:
server1:
    zone: zone1
server2:
    zone: zone2
server3:
    zone: zone3

```

上述为默认风格的配置文件示例，cluster 风格的配置文件请参考上文 **设置 IDC 信息** 中的配置示例。

### 修改用户

OCP 要求进程必须是使用 admin 用户启动，且 admin 用户需要有免密 sudo 的权限。因此我们需要准备好可以免密 sudo 的 admin 用户。如果你已经满足此条件可以直接参考下文 **更改用户** 进行操作。

#### 创建用户

您可使用 root 用户参考如下操作在部署了 OceanBase 数据库的机器中创建 admin 用户。

```shell
# 创建用户组
groupadd admin
# 创建用户
useradd admin -g admin

```

创建 admin 用户后，您需为 admin 用户配置免密登录。有关如何配置免密 SSH 登录，详情请参考 [设置无密码 SSH 登录](https://www.oceanbase.com/docs/community-observer-cn-0000000000160095)。

#### 注意

1. 您需要为 admin 用户配置 SSH 免密登录。
 2. 这里需要配置的为私钥，即 `id_rsa`。

#### 免密 sudo

以下操作请在 root 用户下进行:

```yaml
# 添加 sudoers 文件的写权限
chmod u+w /etc/sudoers
# vi /etc/sudoers
echo 'admin ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# 撤销 sudoers 文件写权限
chmod u-w /etc/sudoers

```

#### 更改用户

您可使用如下命令进入编辑模式修改 user 字段。

修改后的配置示例：

```yaml
## Only need to configure when remote login is required
user:
  username: admin
#   password: your password if need
  key_file: your ssh-key file path if need # 设置为 admin 的 id_rsa 文件路径
#   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30

```

修改配置文件后，您需使用如下命令使改动生效。

```shell
obd cluster restart <deploy name>

# 示例
obd cluster restart test --wp

```

有关 `obd cluster restart` 命令的具体信息请参考 [obd cluster restart](https://www.oceanbase.com/docs/community-obd-cn-10000000001031933)。

### 单机多 Server

OCP 要求一个台机器只能有一个 observer 进程，目前没有适配单机多 server 进程的场景。如果需要 OCP 接管单机多 server 进程的集群，您需手动停止其他的 observer 进程，保证一台机器只有一个 observer 进程 在运行。

#### 说明

上述所有操作完成后，您可再次执行 `obd cluster check4ocp
     ` 命令检查是否满足接管条件，若条件不满足，则可以根据提示进行修改。

## 使用 OCP 接管集群

### 处理 proxyro 密码

在 OCP 接管集群之前，需要确认待接管集群中的 proxyro 用户的密码，如果该密码非默认值，则需将 OCP 中的 proxyro 密码修改为待接管集群中的 proxyro 用户的密码。

- 若您使用的 OCP 为 V4.0.3 及之后版本，可参考 OCP 手册中 [修改 Proxyro 账号的密码](https://www.oceanbase.com/docs/community-ocp-cn-10000000001832468) 一文修改 proxyro 用户密码。
 - 若您使用 OCP 为 V4.0.3 之前版本，可参考如下命令调用 OCP API 进行修改。

  ```shell
  curl --user user:pass -X POST "http://ocp-site-url:port/api/v2/obproxy/password" -H "Content-Type:application/json" -d '{"username":"proxyro","password":"*****"}'

  ```

  说明：

     - `user:pass` 分别为 OCP 的用户和密码，并且要求调用的用户需要有 admin 权限。
     - `-d` 参数后面的 `password` 为待接管集群的 proxyro 用户的密码。

修改 proxyro 用户密码操作会生成运维任务，不仅会将 OCP 中现有 OceanBase 集群的 proxyro 密码修改，同时还修改 OBProxy 集群对应的配置。

您需等运维任务成功结束后才可进行后述步骤，如果任务失败，则需要重试并将任务执行成功之后才能执行后面的步骤。

![任务示例](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/obd/V1.3.0/zh-CN/4.configuration-file-description-01.png)

### OCP 接管 OceanBase 集群

您可直接在 OCP 的白屏页面进行接管 OceanBase 集群的操作，具体步骤请参考 [接管集群](https://www.oceanbase.com/docs/community-ocp-cn-10000000001834160)。

使用 OCP 接管 OceanBase 集群后，您需新建 OBProxy 集群并关联接管的 OceanBase 集群，具体步骤请参考 [创建 OBProxy 集群](https://www.oceanbase.com/docs/community-ocp-cn-10000000001832462)。

如果原 ODP 使用了 VIP，可以将 OCP 上新建的 ODP 逐个添加到 VIP 中，再逐个从 VIP 中下线原 ODP。

### FAQ

1. 为什么要修改 OCP 中的 proxyro 账号的密码？

   因为 OCP 中管理的 ODP 一般是通过 configserver 拉起的，设计上是可以连接多个 OceanBase 集群，但是 ODP 只能全局的修改 proxyro 的用户密码，所以这个配置在 OCP 中是一个全局的配置，proxyro 用户的密码仅用来让 ODP 查询一些元数据，修改并不影响业务租户。
 2. 切换新的 ODP，可以复用原来的机器吗？

   如果原来部署了多台 ODP 并且通过 VIP 来访问，可以逐个下线，并且用相同的机器在 OCP 中部署 ODP，再添加回 VIP，通过这种方式实现机器复用。
 3. 不切换 ODP 是否可以？

   可以的，原 ODP 仍然可以正常连接接管的 OceanBase 集群，但是还是建议用 OCP 新建 ODP 进行替换，方便以后的运维管理。

 上一篇 下一篇 ![有帮助](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) 咨询热线
