---
title: "部署 OceanBase 集群 - 安装部署工具 OBD V3.6.0 | OceanBase 文档中心"
description: 部署 OceanBase 集群 本文介绍如何使用 obd 在单台机器上部署 OceanBase 集群。操作示例仅用于帮助了解 OceanBase 数据库，不建议生产环境中使用。 说明 使用 obd 白屏部署的操作介绍可参见 通过图形化界面部署 OceanBase 集群 。 使用 obd 部署多节点集群的操作介绍可参见…
---
切换语言

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

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

# 部署 OceanBase 集群

更新时间：2025-10-14 19:23:43

[编辑](https://github.com/oceanbase/obd-doc/edit/V3.6.0/zh-CN/400.user-guide/300.command-line-operations/200.deploy-component/200.start-the-oceanbase-cluster-by-using-obd.md)  

本文介绍如何使用 obd 在单台机器上部署 OceanBase 集群。操作示例仅用于帮助了解 OceanBase 数据库，不建议生产环境中使用。

#### 说明

- 使用 obd 白屏部署的操作介绍可参见 [通过图形化界面部署 OceanBase 集群](https://www.oceanbase.com/docs/common-obd-cn-1000000003892312)。
 - 使用 obd 部署多节点集群的操作介绍可参见《OceanBase 数据库文档》中 [使用命令行部署 OceanBase 数据库生产环境](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002013496)。

## 前提条件

在开始之前，请确保您已满足以下条件：

- 仅部署 OceanBase 数据库，至少需要 2vCPU、6 GB 内存、20 GB 磁盘的可用资源。需要注意，要求中的内存限制是指执行 `free -g` 命令后，输出中的 `available` 列对应的值。

  数据目录和日志目录均至少要求为 OceanBase 数据库内存规格的两倍，推荐三倍以上。部署前请查看规划的目录是否满足规格要求，并确保部署用户拥有规划目录的执行和读写权限。

  #### 说明

  在 CPU 核心数较少的环境中，obd 默认设置的最低 CPU_Count 为 8。CPU 核心数配置过低会对 OceanBase 数据库的性能产生负面影响。
 - 使用 x86 架构服务器部署时，需确保 OBServer 节点机器支持 AVX 指令集。可执行 `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 或之后版本。
 - 离线部署场景下，使用 ARM 架构服务器部署时，需查看 OBServer 节点机器是否支持 LSE 指令集，可执行 `lscpu | grep Flags | grep atomics` 命令查看是否支持。若机器不支持 LSE 指令集，需下载带 `nonlse` 的 OceanBase 数据库安装包，并使用 `obd mirror clone` 命令将安装包上传到 obd 本地镜像库。

  #### 说明

  OceanBase All in One 包中未包含带有 `nonlse` 的 OceanBase 数据库安装包。
 - 如需修改机器内核参数，要求部署用户需拥有 sudo 权限。
 - 您的机器中已安装 obd，交互式方式部署要求 obd 为 V3.4.0 或之后版本，建议安装最新版本，详细信息请参考 [安装 obd](https://www.oceanbase.com/docs/common-obd-cn-1000000003892241)。
 - obd 镜像库中存在部署所需组件安装包（OceanBase 数据库、ODP 等）。

  若 obd 所在机器可以连接外部网络，部署时会自动从远程镜像库获取社区版组件安装包。若您计划部署企业版 OceanBase 数据库，可联系技术支持人员获取安装包，并执行 `obd mirror clone` 命令上传至 obd 本地镜像库，上传后可执行 `obd mirror list local` 命令查看本地镜像库中的安装包。

  #### 说明

  通过 OceanBase All in One 安装 obd 后默认禁用远程镜像仓库，如需访问远程镜像仓库，可执行 `obd mirror enable remote` 命令启用远程镜像仓库。
 - 您的机器中已安装 OBClient 客户端，详细信息请参考 [OBClient 文档](https://github.com/oceanbase/obclient/blob/master/README.md)。

#### 说明

- 当机器无法连接到外部网络时，建议通过 OceanBase All in One 安装 obd。OceanBase All in One 中提供需要的全部组件（除 obbinlog 组件），且组件已经经过相互适配测试。
 - OceanBase All in One 安装时会自动安装 obd 和 OBClient 客户端，因此，若您通过 OceanBase All in One 安装 obd，可忽略前提条件中除资源要求外的其他内容。

## 操作步骤

#### 注意

- 本文操作以 x86 架构的 CentOS Linux 7.9 镜像作为环境，其他环境可能略有不同。
 - obd 支持部署社区版和企业版 OceanBase 数据库，本节以部署社区版 OceanBase 数据库为例介绍部署 OceanBase 数据库的操作。

     交互式部署 OceanBase 数据库   通过配置文件部署 OceanBase 数据库

执行 `obd cluster deploy -i` 命令即可启动交互式部署流程，您需在交互式安装流程中配置如下内容。

1. 填写用户信息

   进入交互式安装流程后，需在打印内容的对应位置输入待安装 OceanBase 数据库的机器 IP 及密码，并二次确认用户的登录密码，示例如下：

   #### 说明

   默认在对应机器的当前同名用户下部署 OceanBase 集群，需保证输入的机器中包含当前同名用户。例如，使用 admin 用户执行命令进入交互式部署，此处输入的机器中需存在 admin 用户，密码也需填写对应 admin 用户的密码。

   ```shell
   Enter the IP (Default: 10.10.10.1):
   Enter the current user password : *******
   Re-enter the current user password : *******

   ```

   若已为当前用户设置免密登录，可直接单击键盘上 `Enter` 跳过。
 2. 修改内核参数

   配置节点信息后，若未修改过目标机器的内核参数，obd 会获取节点的内核参数，并向您确认是否需要修改，具体如下：

   ```shell
   get system config ok
   +---------------------------------------------------------------------------------------+
   |                              System Parameter Change List                             |
   +---------------+---------------------------------+---------------+---------------------+
   | ip            | name                            | current_value | expected_value      |
   +---------------+---------------------------------+---------------+---------------------+
   | 10.10.10.1    | fs.aio-max-nr                   | 65536         | 1048576             |
   | 10.10.10.1    | net.core.somaxconn              | 128           | 2048                |
   | 10.10.10.1    | net.core.netdev_max_backlog     | 1000          | 10000               |
   | 10.10.10.1    | net.core.rmem_default           | 212992        | 16777216            |
   | 10.10.10.1    | net.core.wmem_default           | 212992        | 16777216            |
   | 10.10.10.1    | net.core.rmem_max               | 212992        | 16777216            |
   | 10.10.10.1    | net.core.wmem_max               | 212992        | 16777216            |
   | 10.10.10.1    | net.ipv4.conf.default.rp_filter | 0             | 1                   |
   | 10.10.10.1    | net.ipv4.tcp_rmem               | 6291456       | 4096 87380 16777216 |
   | 10.10.10.1    | net.ipv4.tcp_wmem               | 16384         | 4096 65536 16777216 |
   | 10.10.10.1    | net.ipv4.tcp_max_syn_backlog    | 1024          | 16384               |
   | 10.10.10.1    | net.ipv4.tcp_fin_timeout        | 60            | 15                  |
   | 10.10.10.1    | vm.min_free_kbytes              | 67584         | 2097152             |
   | 10.10.10.1    | fs.file-max                     | 3175323       | 6573688             |
   | 10.10.10.1    | fs.pipe-user-pages-soft         | 16384         | 0                   |
   | 10.10.10.1    | vm.max_map_count                | 65530         | 655360              |
   | 10.10.10.1    | nofile                          | 65535         | 655350              |
   +---------------+---------------------------------+---------------+---------------------+
   Please run `obd host user init -u root --host=10.10.10.1` to init user.
   Please run `obd host init root 10.10.10.1` to init host.
   Do you want to modify the parameters above? [y/n] [Default: y]:

   ```

   您可在如上输出位置输入 `y` 或 `n`：

      - 若您输入为 `y`，程序会开始修改对应内核参数，并输出如下提示。

       #### 说明

       修改内核参数要求用户拥有 sudo 权限，若当前用户无 sudo 权限，修改会报错，但报错不影响集群部署。

       ```shell
       modify system parameters
       10.10.10.1: ( fs.aio-max-nr,net.core.somaxconn,net.core.netdev_max_backlog,net.core.rmem_default,net.core.wmem_default... ) have been successfully modified!
       Do you want to quit the script and manually restart the machine to apply the optimizations? [y/n] [Default: n]:

       ```

       此处输入 `y` 会退出部署脚本，输入 `n` 则继续部署流程。
      - 若您输入为 `n`，对应内核参数不会被修改，并继续部署流程。
 3. 配置集群信息

   您需在对应位置设置 OceanBase 集群的部署名、端口、密码和资源信息，直接单击键盘 `Enter` 表示使用默认值，示例如下：

   #### 说明

      - 脚本会根据机器的资源情况自动获取集群资源配置的取值范围和默认值，机器资源情况不同时，输出的取值范围和默认值也不相同。
      - 为集群配置目录时，请确保部署用户拥有配置目录的执行和读写权限。  

   ```shell
   #设置集群名，支持大小写字母、数字和下划线，不区分首字符类型
   Enter the cluster name (Default: myoceanbase; allowed characters: letters, numbers, and underscores):
   #选择部署的 OceanBase 数据库类型
   #仅在 obd 镜像库中存在对应类型（单机版、企业版、社区版）的 OceanBase 数据库安装包时展示
   Enter the cluster name (Default: myoceanbase; allowed characters: letters, numbers, and underscores):
       Multiple OceanBase packages found in the mirror. Please choose one:
       1) oceanbase (Business)
       2) oceanbase-ce (Community)
       3) oceanbase-standalone (Business)
   Enter the number of the oceanbase type you want to use: 2
   #设置 OceanBase 数据库版本，默认输出当前镜像库中最新的五个 OceanBase 数据库版本
   +-----------------------------------------------------------------------------------------------------------------------------+
   |                                                     Available Oceanbase                                                     |
   +--------------+---------+------------------------+--------+------------------------------------------------------------------+
   | name         | version | release                | arch   | md5                                                              |
   +--------------+---------+------------------------+--------+------------------------------------------------------------------+
   | oceanbase-ce | 4.3.5.2 | 102010012025052715.el7 | x86_64 | 9a686c637798f0b465acef7be7911e79ef6fe705a23a45679eaa24e5d6bbb2e3 |
   | oceanbase-ce | 4.3.5.1 | 101020012025061620.el7 | x86_64 | cbca16ad25003e65bafed2455c2e442b9f0563661c7f7eb149b368322e76f4a5 |
   | oceanbase-ce | 4.3.5.0 | 100000202024123117.el7 | x86_64 | 08314aa05c1993c6df2bf3bfb867ea0df85f2b234c31226524d352d99f781f50 |
   | oceanbase-ce | 4.3.4.1 | 101000032024121814.el7 | x86_64 | 36006ed8bf531b17892eaf3a9e43d1e4284049d22b54b9b5b8fe656624713573 |
   | oceanbase-ce | 4.3.4.0 | 100000162024110717.el7 | x86_64 | 3067df2369964aa19f93f1448cf507d0f20df6ea2761120a5adfca3711cd97ff |
   +--------------+---------+------------------------+--------+------------------------------------------------------------------+
   ......
   #若计划安装最新版本，可输入 y 安装；若计划安装其他版本，可输出 n 后，在后续交互中输出待安装版本
   Are you sure to deploy using this latest version(4.3.5.2) of Oceanbase.:  [y/n] [Default: y]:
   #输出计划安装的 OceanBase 数据库版本
   Enter the version of oceanbase-ce you want to use (e.g.: 4.3.5.2): 4.3.5.1
   Download oceanbase-ce-4.3.5.1-101020012025061620.el7.x86_64.rpm (161.15 M): 100% [#################] Time: 0:00:12  13.62 MB/s
   +-----------------------------------------------------------------------------------------------------+
   |                                         Available Oceanbase                                         |
   +--------------+---------+------------------------+--------+------------------------------------------+
   | name         | version | release                | arch   | md5                                      |
   +--------------+---------+------------------------+--------+------------------------------------------+
   | oceanbase-ce | 4.3.5.1 | 101020012025061620.el7 | x86_64 | fe7d924524546c9e0188a36194aa69332933e36c |
   +--------------+---------+------------------------+--------+------------------------------------------+
   #设置集群的 SQL 端口，对应配置文件中的 mysql_port
   Enter the OB SQL port (Default: 2881):
   #设置集群的 RPC 端口，对应配置文件中的 rpc_port
   Enter the OB RPC port (Default: 2882):
   #设置集群的 obshell 端口，对应配置文件中的 obshell_port
   Enter the obshell port (Default: 2886):
   #设置集群 root@sys 用户密码，对应配置文件中的 root_password。未设置时默认会生成一个随机字符串
   Enter the OB root password (Default: ************):
   #二次确认 root@sys 用户密码，仅在手动配置密码时需要二次确认
   Confirm the OB root password:
   #设置集群可用 CPU 总数，对应配置文件中的 cpu_count
   #配置的值不能小于 8，小于 8 时会自动将值置为 8。未设置时 obd 会自动检测
   Enter the OB cpu count (Default: 8):
   #设置集群所用内存，对应配置文件中的 memory_limit
   Enter the OB memory limit (Configurable Range[6, 28]， Default: 28, Unit: G): 12
   #设置 OceanBase 集群的安装目录，对应配置文件中的 home_path，未设置时默认在用户家目录下创建集群同名文件夹
   Enter the OB installation directory (Default: /home/admin/myoceanbase):
   #设置存储 SSTable 等数据的目录，对应配置文件中的 data_dir，未设置时默认为 /data/1/${cluster_name}
   Enter the OB data directory (Default: /data/1/myoceanbase):
   #设置存储日志的目录，对应配置文件中的 redo_dir，未设置时默认为 /data/log1/${cluster_name}
   Enter the OB log directory (Default: /data/log1/myoceanbase):
   #设置集群负载类型，对应配置文件中的 scenario，未设置时默认为 htap
   #该部分仅在待部署的 OceanBase 数据库版本号不小于 V4.2.5 时展示
   Cluster optimization scenario not specified, please specify the scenario you want to optimize.
   1. express_oltp
   2. complex_oltp
   3. olap
   4. htap (default)
   5. kv
   Please input the scenario you want to optimize [default: 4]:
   #设置集群的日志磁盘大小，对应配置文件中的 log_disk_size，推荐为内存规格的三倍以上
   Enter the log disk size (Configurable Range[24, 26], Default: 26 , unit: G):
   #设置集群的磁盘数据文件自动扩容的最大空间，对应配置文件中的 datafile_maxsize
   Enter the datafile maxsize (Configurable Range[24, 130], Default: 130 , unit: G):
   #控制是否设置开机自启动，对应配置文件中的 enable_auto_start
   #仅在非容器环境下展示，开启自启动功能需确保部署用户拥有 sudo 权限，否则部署会报错
   Do you want to enable the OceanBase service to start automatically when the system boots up? [y/n] [Default: n]:
   #控制是否创建业务租户
   Do you want to create tenant for your business workload? [y/n] [Default: y]:

   ```
 4. （可选）配置租户信息

   若上文询问是否创建业务租户处输入 `y`，可参照本步骤介绍设置租户信息，若输入 `n`，可跳过本步骤继续部署流程。

   #### 说明

   本文以部署 OceanBase 数据库社区版为例，若您部署所用的 OceanBase 数据库为企业版或单机版，设置租户名后将会输出 `Please select the tenant mode (enter the corresponding number):` 字段，您可在此处配置待创建租户的兼容模式，支持设置为 MySQL（输入 `1`）或 Oracle（输入 `2`）租户兼容模式。

   ```shell
   # sys 租户资源信息
   Tenant: sys conifguration: 2C/2G/4G(CPU/Memory/Log disk)
   system_memory configuration(Unit: G): 5G
   #设置租户名，支持大小写字母、数字和下划线，不区分首字符类型
   Enter the tenant name (Default: test; allowed characters: letters, numbers, and underscores): obmysql
   #设置租户的管理员用户密码，未设置时默认为空
   Enter the tenant password:
   #二次确认租户的管理员用户密码
   Confirm the tenant password:
   #设置待创建租户的可用 CPU
   Enter the tenant cpu (Configurable Range[1, 6], Default: 6 ): 2
   #设置待创建租户的可用内存
   Enter the tenant memory (Configurable Range[2, 5], Default: 5 , unit: G): 2
   #设置待创建租户的可用日志磁盘大小
   Enter the tenant log disk size (Configurable Range[4, 22], Default: 4 , unit: G): 5
   #设置待创建租户的字符集
       Please select the character (enter the corresponding number):
       1) utf8mb4
       2) utf16
       3) gbk
       4) gb18030
       5) binary
   Enter the tenant charset (Default: 1):
   #设置待创建租户的字符序
      Please select the tenant collation (enter the corresponding number):
       1) utf8mb4_general_ci
       2) utf8mb4_bin
       3) utf8mb4_unicode_ci
       4) utf8mb4_unicode_520_ci
       5) utf8mb4_croatian_ci
       6) utf8mb4_czech_ci
       7) utf8mb4_0900_ai_ci
   Enter the tenant collation (Default: 1):
   #设置待创建租户的时区
       Please select the tenant time zone (enter the corresponding number):
       1) -12:00(International Date Line West)
       2) -11:00(Samoa Standard Time)
       3) -10:00(Hawaii-Aleutian Standard Time)
       4) -09:00(Alaska Standard Time)
       5) -08:00(Pacific Standard Time)
       6) -07:00(Mountain Standard Time)
       7) -06:00(Central Standard Time)
       8) -05:00(Eastern Standard Time)
       9) -04:00(Atlantic Standard Time)
       10) -03:00(Brasilia Standard Time)
       11) -02:00(Mid-Atlantic Standard Time)
       12) -01:00(Azores Standard Time)
       13) +00:00(Greenwich Mean Time)
       14) +01:00(Central European Time)
       15) +02:00(Eastern European Time)
       16) +03:00(Moscow Standard Time)
       17) +04:00(Gulf Standard Time)
       18) +05:00(Pakistan Standard Time)
       19) +06:00(Bangladesh Standard Time)
       20) +07:00(Indochina Time)
       21) +08:00(China Standard Time)
       22) +09:00(Japan Standard Time)
       23) +10:00(Australian Eastern Standard Time)
       24) +11:00(Solomon Islands Time)
       25) +12:00(New Zealand Standard Time)
       26) +13:00(Tonga Standard Time)
       27) +14:00(Line Islands Time)
   Enter the tenant time zone (Default: 21):
   #设置待创建租户中是否表名大小写敏感，仅在创建 MySQL 租户兼容模式时需要配置
      Please select case sensitivity for table names:
       0) Table names are stored as specified and compared case-sensitively
       1) Table names are stored in lowercase and compared case-insensitively
       2) Table names are stored as specified but compared case-insensitively
   Please enter your choice [0/1/2] [default 1]:

   ```
 5. （可选）配置监控信息

   若您在 `Do you need to install the monitoring components` 处输入 `y`，您需设置监控相关信息，若此处输入 `n`，可跳过本步骤继续部署流程。

   ```shell
   #设置 OBAgent 监控服务端口，对应配置文件中的 monagent_http_port
   Enter the OBAgent monitoring service port (Default: 8088):
   #设置 OBAgent 管理服务端口，对应配置文件中的 mgragent_http_port
   Enter the OBAgent management service port (Default: 8089):
   #设置 Prometheus 端口
   Enter the Prometheus port (Default: 9090):
   #设置 Grafana 端口
   Enter the Grafana port (Default: 3000):

   ```
 6. 控制是否开启密码加密功能

   ```shell
   Do you want to enable encryption for password security (default_encryption_passkey: 123456)? [y/n] [Default: n]:

   ```

   您可在上文位置输入 `n` 选择不开启密码加密功能，输入 `n` 将跳过本环节继续部署流程。您也可输出 `y` 设置密码加密，设置后查看集群信息时，密码输出为加密状态。如需查看集群相关密码，需通过 `--epk` 选项配置正确的通行密钥，如，`obd cluster display myoceanbase --epk ******`。

   默认通行密钥为 123456，部署后您需及时通过 `obd pwd set-epk` 命令修改密钥，具体可参见 [密码命令组](https://www.oceanbase.com/docs/common-obd-cn-1000000003892231) 介绍。
 7. 确认配置

   程序会输出您刚刚设置的配置，您需确认这些配置是否正确，示例如下：

   ```shell
   #Saved configurations:
   cluster name: myoceanbase
   mysql port: 2881
   rpc port: 2882
   obshell port: 2886
   cpu count: 8
   memory limit: 12G
   home path: /home/admin/myoceanbase/oceanbase_name
   data dir: /data/1/myoceanbase
   log dir: /data/log1/myoceanbase
   datafile maxsize: 130G
   log disk size: 26G
   tenant name: obmysql
   tenant cpu: 2
   tenant memory: 2G
   tenant log disk size: 5G
   monagent http port: 8088
   mgragent http port: 8089
   prometheus port: 9090
   grafana port: 3000
   Are you sure these configurations are correct? [y/n] [Default: y]:

   ```

   您需在确认位置输入 `y` 或 `n`：若您输入为 `y`，程序会开始根据配置部署 OceanBase 集群；若您输入为 `n`，部署流程会直接结束。
 8. 部署成功

   集群部署成功后会输出组件的部署情况以及对应连接串，具体如下：

   ```shell
   Wait for observer init ok
   +------------------------------------------------+
   |                  oceanbase-ce                  |
   +--------------+---------+------+-------+--------+
   | ip           | version | port | zone  | status |
   +--------------+---------+------+-------+--------+
   | 10.10.10.1   | 4.3.5.1 | 2881 | zone1 | ACTIVE |
   +--------------+---------+------+-------+--------+
   obclient -h10.10.10.1 -P2881 -uroot@sys -p'******' -Doceanbase -A

   cluster unique id: 64ccbd30-c104-5576-ad47-1cd0a8010f73-197d381436b-02050304

   Connect to Obagent ok
   +-----------------------------------------------------------------+
   |                             obagent                             |
   +--------------+--------------------+--------------------+--------+
   | ip           | mgragent_http_port | monagent_http_port | status |
   +--------------+--------------------+--------------------+--------+
   | 10.10.10.1   | 8089               | 8088               | active |
   +--------------+--------------------+--------------------+--------+
   Connect to Prometheus ok
   +----------------------------------------------------------+
   |                        prometheus                        |
   +--------------------------+-------+--------------+--------+
   | url                      | user  | password     | status |
   +--------------------------+-------+--------------+--------+
   | http://10.10.10.1:9090   | admin | '******'     | active |
   +--------------------------+-------+--------------+--------+
   Connect to grafana ok
   +---------------------------------------------------------------------+
   |                               grafana                               |
   +--------------------------------------+-------+-------------+--------+
   | url                                  | user  | password    | status |
   +--------------------------------------+-------+-------------+--------+
   | http://10.10.10.1:3000/d/oceanbase   | admin | '******'    | active |
   +--------------------------------------+-------+-------------+--------+

   obshell program health check ok
   display ob-dashboard ok
   +------------------------------------------------------------+
   |                        ob-dashboard                        |
   +---------------------------+------+----------------+--------+
   | url                       | user | password       | status |
   +---------------------------+------+----------------+--------+
   | http://10.10.10.1:2886    | root | '********'     | active |
   +---------------------------+------+----------------+--------+
   myoceanbase running
   Get local repositories ok
   Open ssh connection ok
   Connect to observer 10.10.10.1:2881 ok
   Create tenant obmysql ok
   obclient -h10.10.10.1 -P'2881' -p'' -uroot@obmysql -Doceanbase -A

   optimize tenant with scenario: htap ok
   Encrypt password ok

   ```

### 验证部署结果

1. 查看集群列表

   可执行 `obd cluster list` 命令查看集群列表，输入如下，存在部署名为 `myoceanbase` 的集群且状态为 `running`，表示集群处于运行中。

   ```shell
   +----------------------------------------------------------------------+
   |                             Cluster List                             |
   +-------------+--------------------------------------+-----------------+
   | Name        | Configuration Path                   | Status (Cached) |
   +-------------+--------------------------------------+-----------------+
   | myoceanbase | /home/admin/.obd/cluster/myoceanbase | running         |
   +-------------+--------------------------------------+-----------------+

   ```
 2. 查看集群具体状态

   ```shell
   [admin@test001 ~]$ obd cluster display myoceanbase

   ```

   输出如下：

   ```shell
   Get local repositories and plugins ok
   Open ssh connection ok
   Connect to observer 10.10.10.1:2881 ok
   Wait for observer init ok
   +------------------------------------------------+
   |                  oceanbase-ce                  |
   +--------------+---------+------+-------+--------+
   | ip           | version | port | zone  | status |
   +--------------+---------+------+-------+--------+
   | 10.10.10.1   | 4.3.5.1 | 2881 | zone1 | ACTIVE |
   +--------------+---------+------+-------+--------+
   obclient -h10.10.10.1 -P2881 -uroot@sys -p'******' -Doceanbase -A

   Connect to Obagent ok
   +-----------------------------------------------------------------+
   |                             obagent                             |
   +--------------+--------------------+--------------------+--------+
   | ip           | mgragent_http_port | monagent_http_port | status |
   +--------------+--------------------+--------------------+--------+
   | 10.10.10.1   | 8089               | 8088               | active |
   +--------------+--------------------+--------------------+--------+
   Connect to Prometheus ok
   +------------------------------------------------------+
   |                      prometheus                      |
   +--------------------------+-------+----------+--------+
   | url                      | user  | password | status |
   +--------------------------+-------+----------+--------+
   | http://10.10.10.1:9090   | admin | '******' | active |
   +--------------------------+-------+----------+--------+
   Connect to grafana ok
   +------------------------------------------------------------------+
   |                             grafana                              |
   +--------------------------------------+-------+----------+--------+
   | url                                  | user  | password | status |
   +--------------------------------------+-------+----------+--------+
   | http://10.10.10.1:3000/d/oceanbase   | admin | '******' | active |
   +--------------------------------------+-------+----------+--------+
   obshell program health check ok
   display ob-dashboard ok
   +------------------------------------------------------------+
   |                        ob-dashboard                        |
   +---------------------------+------+----------------+--------+
   | url                       | user | password       | status |
   +---------------------------+------+----------------+--------+
   | http://10.10.10.1:2886    | root | '******'       | active |
   +---------------------------+------+----------------+--------+

   ```
 3. 查看集群租户

   ```shell
   obd cluster tenant show myoceanbase

   ```

   输出如下，集群中存在 `sys` 租户和创建的 `obmysql` 租户。

   ```shell
   Get local repositories ok
   Get deployment connections ok
   Connect to observer 10.10.10.1:2881 ok
   Select tenant ok
   +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   |                                                                                    tenant basic info                                                                                    |
   +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+
   | tenant_name | tenant_type | compatibility_mode | primary_zone | max_cpu | min_cpu | memory_size | max_iops            | min_iops            | log_disk_size | iops_weight | tenant_role |
   +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+
   | sys         | SYS         | MYSQL              | RANDOM       | 2.0     | 2.0     | 2G          | 9223372036854775807 | 9223372036854775807 | 4G            | 2           | PRIMARY     |
   | obmysql     | USER        | MYSQL              | RANDOM       | 2.0     | 2.0     | 2G          | 9223372036854775807 | 9223372036854775807 | 5G            | 2           | PRIMARY     |
   +-------------+-------------+--------------------+--------------+---------+---------+-------------+---------------------+---------------------+---------------+-------------+-------------+

   ```
 4. 连接集群

   您可复制 `obd cluster display` 命令中输出的连接串连接 OceanBase 集群的 sys 租户，也可根据配置的租户名和密码连接用户租户。连接 OceanBase 集群的具体介绍可参见 [通过 OBClient 连接 OceanBase 租户（MySQL 模式）](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002013251) 或 [通过 OBClient 连接 OceanBase 租户（Oracle 模式）](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002013208)。

   ```shell
   obclient -h10.10.10.1 -P2881 -uroot@sys -p'******' -Doceanbase -A

   ```

   输出如下，成功使用 root 用户登录 OceanBase 集群 sys 租户。

   ```shell
   Welcome to the OceanBase.  Commands end with ; or \g.
   Your OceanBase connection id is 3221490663
   Server version: OceanBase_CE 4.3.5.1 (r101020012025061620-3ee44736ead7f159c8b2dd0593ab3d1346997903) (Built Jun 16    2025 21:02:30)

   Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

   obclient(root@sys)[oceanbase]>

   ```

### 步骤一：修改配置文件

若您机器中的 obd 是通过直接下载的方式安装，则可在 `/usr/obd/example` 目录下查看 obd 提供的配置文件示例。

若您机器中的 obd 是通过解压 all-in-one 安装包的方式安装，则可在 `~/.oceanbase-all-in-one/obd/usr/obd/example` 目录下查看 obd 提供的配置文件示例。

不同配置文件示例的区别可参见 [配置文件说明](https://www.oceanbase.com/docs/common-obd-cn-1000000003892319) 中 **获取配置文件示例**，请根据您的资源条件选择相应的配置文件。

#### 说明

本文末会提供完整的单机部署 OceanBase 集群的 [配置文件示例](#配置文件示例)，您也可直接复制并进行修改。

此处以小规格开发模式-单机部署（`mini-single-example.yaml`）为例介绍配置文件。

#### 说明

您需根据您环境的真实情况修改下述参数。

1. 修改用户信息

   ```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` 为登录到目标机器（安装 OceanBase 集群的机器）的用户名，确保您的用户名有下文 `home_path` 的写权限。`password` 和 `key_file` 均用于验证用户，通常情况下只需要填写一个。

   #### 注意

   在配置秘钥路径后，如果您的秘钥不需要口令，请注释或者删除 `password`，以免 `password` 被视为秘钥口令用于登录，导致校验失败。
 2. 修改机器的 IP、端口和相关目录，并配置内存相关参数及 root@sys 用户密码

   ```yaml
   oceanbase-ce:
     # version: 4.3.5.0
     servers:
       - name: server1
         ip: 10.10.10.1
     global:
       # Please set devname as the network adaptor's name whose ip is  in the setting of severs.
       # if set severs as "127.0.0.1", please set devname as "lo"
       # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
       devname: eth0
       cluster_id: 1
       # please set memory limit to a suitable value which is matching resource.
       memory_limit: 6G # The maximum running memory for an observer
       system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
       datafile_size: 2G # Size of the data file.
       datafile_next: 2G # the auto extend step. Please enter an capacity, such as 2G
       datafile_maxsize: 20G # the auto extend max size. Please enter an capacity, such as 20G
       log_disk_size: 14G # The size of disk space used by the clog files.
       cpu_count: 16
       scenario: htap
       enable_auto_start: true
       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.
       obshell_port: 2886 # Operation and maintenance port for Oceanbase Database. The default value is 2886. This parameter is valid only when the version of oceanbase-ce is 4.2.2.0 or later.
       production_mode: false
       # 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
       root_password: ****** # root user password, can be empty
       zone: zone1

   ```

   配置文件中各配置项含义可参见 [配置文件说明](https://www.oceanbase.com/docs/common-obd-cn-1000000003892319) 一文中 **配置项说明** 部分介绍。需注意如下几点：

      - 配置文件中若未配置密码，obd 会自动生成随机密码，部署成功后可通过 `obd cluster edit-config` 命令查看配置文件中对应的配置项获取密码。
      - 若待部署的 OceanBase 数据库版本号不小于 V4.2.5，配置文件中未配置 `scenario` 时，obd 会提供交互式选项供用户选择负载类型。
      - 配置 `enable_auto_start` 为 `true` 即表示开启 observer 进程开机自启动功能，该功能需确保部署用户拥有 sudo 权限，且部署环境非容器环境。
      - 如需部署单机多节点 OceanBase 集群，可在 `oceanbase-ce->servers` 下使用同一 IP 配置多个 server，需确保不同 server 下使用不同的端口和目录。配置文件具体可参见下文 [配置文件示例](#配置文件示例)。

### 步骤二：部署 OceanBase 数据库

#### 说明

本节中所使用命令的详细使用方法可参考 [集群命令组](https://www.oceanbase.com/docs/common-obd-cn-1000000003892230)。

1. 部署 OceanBase 集群

   ```shell
   [admin@test001 ~]$ obd cluster deploy obtest -c mini-single-example.yaml

   ```

   示例中是以部署集群名为 `obtest`，配置文件为 `mini-single-example.yaml` 为例，您可自定义部署集群名，并根据实际情况指定所需配置文件。

   此命令会检查 `home_path` 和 `data_dir` 指向的目录是否为空，目录不为空时将报错。若您确认该目录下的内容可全部删除，可以加上 `-f` 选项，强制清空目录。
 2. 启动 OceanBase 集群

   ```shell
   [admin@test001 ~]$ obd cluster start obtest

   ```

   集群启动成功后会输出组件的部署情况以及对应连接串，具体如下：

   ```shell
   Wait for observer init ok
   +-------------------------------------------------+
   |                   oceanbase-ce                  |
   +---------------+---------+------+-------+--------+
   | ip            | version | port | zone  | status |
   +---------------+---------+------+-------+--------+
   | 10.10.10.1    | 4.3.5.2 | 2881 | zone1 | ACTIVE |
   +---------------+---------+------+-------+--------+
   obclient -h10.10.10.1 -P2881 -uroot@sys -p'******' -Doceanbase -A

   cluster unique id: 14c23fe5-e9dc-576f-9a93-d13ca1b2e915-197d4e2de9b-02050304

   obshell program health check ok
   display ob-dashboard ok
   +-----------------------------------------------------------+
   |                        ob-dashboard                       |
   +---------------------------+------+---------------+--------+
   | url                       | user | password      | status |
   +---------------------------+------+---------------+--------+
   | http://10.10.10.1:2886    | root | '******'      | active |
   +---------------------------+------+---------------+--------+

   ```

### 步骤三：验证部署结果

1. 查看集群列表

   可执行 `obd cluster list` 命令查看集群列表，输入如下，存在部署名为 `obtest` 的集群且状态为 `running`，表示集群处于运行中。

   ```shell
   +----------------------------------------------------------------------+
   |                             Cluster List                             |
   +-------------+--------------------------------------+-----------------+
   | Name        | Configuration Path                   | Status (Cached) |
   +-------------+--------------------------------------+-----------------+
   | obtest      | /home/admin/.obd/cluster/test        | running         |
   +-------------+--------------------------------------+-----------------+

   ```shell
   [admin@test001 ~]$ obd cluster display obtest

   ```

   输出如下：

   ```shell
   Get local repositories and plugins ok
   Open ssh connection ok
   Connect to observer 10.10.10.1:2881 ok
   Wait for observer init ok
   +-------------------------------------------------+
   |                   oceanbase-ce                  |
   +---------------+---------+------+-------+--------+
   | ip            | version | port | zone  | status |
   +---------------+---------+------+-------+--------+
   | 10.10.10.1    | 4.3.5.2 | 2881 | zone1 | ACTIVE |
   +---------------+---------+------+-------+--------+
   obclient -h10.10.10.1 -P2881 -uroot@sys -p'******' -Doceanbase -A

   ```
 3. 连接集群

   ```

   ```shell
   Welcome to the OceanBase.  Commands end with ; or \g.
   Your OceanBase connection id is 3221494505
   Server version: OceanBase_CE 4.3.5.2 (r102010012025052715-2291c2a4ef1863f12286914f6bb56108fb7bc25c) (Built May 27 2025 15:15:24)

   ```

## 相关操作

您可执行如下命令对 obd 部署的集群进行管理。更多操作详见 [集群命令组](https://www.oceanbase.com/docs/common-obd-cn-1000000003892230)。

- 查看集群列表

  ```shell
  obd cluster list

  ```
 - 查看集群状态，以部署名为 `obtest` 为例

  ```shell
  obd cluster display obtest

  ```
 - 创建用户租户，以为 `obtest` 集群创建 `test` 租户为例

  ```shell
  obd cluster tenant create obtest -n test --max-cpu=2 --memory-size=2G --log-disk-size=3G --max-iops=10000 --iops-weight=2 --unit-num=1 --charset=utf8 -o htap -s 'ob_tcp_invited_nodes="%"'

  ```

  #### 说明

  部署 OceanBase 集群之后，建议创建业务租户进行业务操作。sys 租户仅做集群管理使用，不适合在业务场景中使用。您可执行 `obd cluster tenant create` 命令创建租户，或连接到 OceanBase 数据库后执行 SQL 命令创建租户，obd 命令介绍可参见 [集群命令组](https://www.oceanbase.com/docs/common-obd-cn-1000000003892230)，使用 SQL 命令创建租户的详细操作可参见官网《OceanBase 数据库》文档 [管理数据库/租户管理/租户常见操作/创建租户](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002013128)。
 - 修改集群参数

  OceanBase 数据库有数百个配置项，有些配置是耦合的，在您熟悉 OceanBase 数据库之前，不建议您修改示例配件文件中的配置。

  执行如下命令打开配置文件，修改集群配置

  ```shell
  obd cluster edit-config obtest

  ```

  修改配置并保存退出后，obd 会告知如何使得此次修改生效，复制 obd 输出的命令即可。保存修改后输出如下：

  ```shell
  Search param plugin and load ok
  Search param plugin and load ok
  Parameter check ok
  Save deploy "obtest" configuration
  Use `obd cluster reload obtest` to make changes take effect.

  ```

  复制执行输出中的 `obd cluster reload obtest` 命令即可使修改生效。
 - 停止运行中的集群，以部署名为 `obtest` 为例

  ```shell
  obd cluster stop obtest

  ```
 - 销毁已部署的集群，以部署名为 `obtest` 为例

  ```shell
  obd cluster destroy obtest

  ```

## 配置文件示例

    单机单节点   单机多节点

```yaml
user:
  username: admin
  password: ********
  # key_file: /home/admin/.ssh/id_rsa
oceanbase-ce:
  # version: 4.3.5.0
  servers:
    - name: server1
      ip: 10.10.10.1
  global:
    devname: eth0
    cluster_id: 1
    memory_limit: 6G
    system_memory: 1G
    datafile_size: 2G
    datafile_next: 2G
    datafile_maxsize: 20G
    log_disk_size: 14G
    cpu_count: 16
    scenario: htap
    enable_auto_start: true
    mysql_port: 2881
    rpc_port: 2882
    obshell_port: 2886
    production_mode: false
    home_path: /home/admin/observer
    data_dir: /data/date
    redo_dir: /data/redo
    root_password: ******
    zone: zone1

```

```yaml
user:
  username: admin
  password: ********
  # key_file: /home/admin/.ssh/id_rsa
oceanbase-ce:
  servers:
    - name: server1
      ip: 10.10.10.1
    - name: server2
      ip: 10.10.10.1
    - name: server3
      ip: 10.10.10.1
  global:
    devname: eth0
    cluster_id: 1
    memory_limit: 6G # The maximum running memory for an observer
    system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants.
    datafile_size: 2G # Size of the data file.
    datafile_next: 2G
    datafile_maxsize: 20G
    log_disk_size: 14G
    production_mode: false
    scenario: htap
    enable_auto_start: true
    appname: obdemo
    root_password: ********
  server1:
    zone: zone1
    mysql_port: 3881
    rpc_port: 3882
    obshell_port: 3886
    home_path: /home/admin/observer1
    data_dir: /data/data1
    redo_dir: /data/redo1
  server2:
    zone: zone2
    mysql_port: 4881
    rpc_port: 4882
    obshell_port: 4886
    home_path: /home/admin/observer2
    data_dir: /data/data2
    redo_dir: /data/redo2
  server3:
    zone: zone3
    mysql_port: 5881
    rpc_port: 5882
    obshell_port: 5886
    home_path: /home/admin/observer3
    data_dir: /data/data3
    redo_dir: /data/redo3

```

## 相关文档

[使用 obd 命令行部署单机版](https://www.oceanbase.com/docs/common-oceanbase-database-standalone-1000000002701718)

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