---
title: "部署 OceanBase 数据库 | OceanBase 文档中心"
description: 部署 OceanBase 数据库 本节为您介绍安装 OceanBase 数据库的方法。 前提条件 （可选）已参考 安装准备 中获取如下软件包，在线安装仅需获取 obdeploy-master.zip 软件包。 oceanbase-ce-libs-3.1.2-1.el7.x86_64.rpm oceanbase-ce-…
---
切换语言

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

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*lJTmRZ61jSUAAAAAAAAAAAAADiGDAQ/original) 云平台 OCPV 3.1.1 社区版

# 部署 OceanBase 数据库

更新时间：2026-04-14 11:55:53

[编辑](https://github.com/oceanbase/ocp-doc/edit/V3.1.1/zh-CN/200.deployment-guide/500.prepare-metadb-and-monitordb/200.deploy-the-oceanbase-database.md)  

本节为您介绍安装 OceanBase 数据库的方法。

## 前提条件

- （可选）已参考 [安装准备](https://www.oceanbase.com/docs/community-ocp-cn-10000000000012332) 中获取如下软件包，在线安装仅需获取 `obdeploy-master.zip` 软件包。

     - oceanbase-ce-libs-3.1.2-1.el7.x86_64.rpm
     - oceanbase-ce-3.1.2-1.el7.x86_64.rpm
     - obdeploy-master.zip
 - OCP 宿主机已安装好 sshpass 命令。 若未安装请以 root 用户在宿主机上执行 `yum -y install sshpass` 命令安装。
 - 如果您的机器不能访问公网，则需要将`oceanbase-ce-libs-3.1.2-1.el7.x86_64.rpm`和`oceanbase-ce-3.1.2-1.el7.x86_64.rpm`软件包添加至本地镜像。

     1. 以 root 用户执行如下命令删除远程仓库。

       ```java
       rm -fr ~/.obd/mirror/remote/*.repo

       ```
     2. 以 root 用户将如下软件包上传至任意路径下。
     3. 执行如下命令将已上传的软件包添加至本地镜像。

       ```java
       obd mirror clone *.rpm

       ```

## 操作步骤

1. 获取部署 OceanBase 数据库所需的配置文件 `*-example.yaml`。

   `*-example.yaml` 文件是针对 OceanBase 部署组网的一系列配置文件，本次安装以部署单机组网的 OceanBase 数据库为例做说明。部署单机组网需使用 `mini-single-example.yaml` 配置文件。

      - 方法一：下载，具体下载方法如下。

       以 root 用户将已下载的 `obdeploy-master.zip` 文件上传至 `/root/` 目录下，并执行如下命令解压， `mini-single-example.yaml` 文件则在 `/root/obdeploy-master/example/` 路径下。

       ```java
       yum -y install unzip
       unzip obdeploy-master.zip

       ```
      - 方法二：自建，具体方法如下。

            1. 以 root 用户执行如下命令在 `/root/obdeploy-master/example/` 目录下创建 `mini-single-example.yaml` 文件。

              ```java
              mkdir -p /root/obdeploy-master/example/
              touch /root/obdeploy-master/example/mini-single-example.yaml

              ```
            2. 将 [*-example.yaml](https://www.oceanbase.com/docs/community-ocp-cn-10000000000012371) 中相应的内容复制到新建的文件中。
 2. 修改 mini-single-example.yaml 文件。

      1. 执行 `vi /root/obdeploy-master/example/mini-single-example.yaml` 命令，然后按" **i** "键修改该文件如下：

        ```java
        user:
           username: ******
           password: ******
        oceanbase-ce:
          servers:
            - xxx.xxx.xxx.xxx
          global:
            home_path: /home/admin/observer
            devname: bond0
            mysql_port: 2881
            rpc_port: 2882
            zone: zone1
            cluster_id: 1
            memory_limit: 50G
            system_memory: 10G
            stack_size: 512K
            cpu_count: 16
            cache_wash_threshold: 1G
            __min_full_resource_pool_memory: 268435456
            workers_per_cpu_quota: 10
            schema_history_expire_time: 1d
            net_thread_count: 4
            major_freeze_duty_time: Disable
            minor_freeze_times: 10
            enable_separate_sys_clog: 0
            enable_merge_by_turn: FALSE
            datafile_disk_percentage: 20
            syslog_level: INFO
            enable_syslog_wf: false
            enable_syslog_recycle: true
            max_syslog_file_count: 4
            root_password: ********

        ```

        其中应注意如下参数：

             - username：OceanBase 的安装用户，按规划应配置为 admin。
             - password：admin 用户的密码。
             - servers：OceanBase 安装的目标主机。
             - home_path：OceanBase 数据库的安装目录，需确保 admin 用户对该目录有读写权限。
             - data_dir： OceanBase 数据库的数据存储目录，需确保 admin 用户对该目录有读写权限。
             - redo_dir：OceanBase 数据库的 clog 存储目录，需确保 admin 用户对该目录有读写权限。
             - devname：OceanBase 数据库使用的网卡，需确保主机上已挂载该网卡。
             - memory_limit：OBServer 可占用服务器的最大内存。
             - system_memory：OBServer 分配给系统租户的内存大小。
             - cpu_count：该 OceanBase 数据库占用服务器的 CPU 资源。
             - root_password：sys 租户的 root 用户密码，使用 root@sys 登录 OceanBase 数据库时需使用。
      2. 执行 **`:wq`** 命令退出并保存修改。
 3. 执行如下命令部署名为 test 的 OceanBase 集群。

   ```java
   obd cluster deploy test -c ./example/mini-single-example.yaml

   ```
 4. 执行如下命令启动集群。

   ```java
   obd cluster start test

   ```
 5. 使用客户端连接到该 OceanBase 数据库，测试是否安装成功。

      - 使用 OBClient 连接执行命令：obclient -hxxx.xxx.xxx.xxx -u<用户名称>@<租户名词> -P2881
      - 使用 MySQL 客户端连接执行命令：mysql -hxxx.xxx.xxx.xxx -u<用户名称>@<租户名词> -P2881

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