首批通过分布式安全可靠测评,为关键业务系统打造
部署 OceanBase 数据库
更新时间:2026-04-14 11:55:53
本节为您介绍安装 OceanBase 数据库的方法。
前提条件
(可选)已参考 安装准备 中获取如下软件包,在线安装仅需获取
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软件包添加至本地镜像。以 root 用户执行如下命令删除远程仓库。
rm -fr ~/.obd/mirror/remote/*.repo以 root 用户将如下软件包上传至任意路径下。
执行如下命令将已上传的软件包添加至本地镜像。
obd mirror clone *.rpm
操作步骤
获取部署 OceanBase 数据库所需的配置文件
*-example.yaml。*-example.yaml文件是针对 OceanBase 部署组网的一系列配置文件,本次安装以部署单机组网的 OceanBase 数据库为例做说明。部署单机组网需使用mini-single-example.yaml配置文件。方法一:下载,具体下载方法如下。
以 root 用户将已下载的
obdeploy-master.zip文件上传至/root/目录下,并执行如下命令解压,mini-single-example.yaml文件则在/root/obdeploy-master/example/路径下。yum -y install unzip unzip obdeploy-master.zip方法二:自建,具体方法如下。
以 root 用户执行如下命令在
/root/obdeploy-master/example/目录下创建mini-single-example.yaml文件。mkdir -p /root/obdeploy-master/example/ touch /root/obdeploy-master/example/mini-single-example.yaml将 *-example.yaml 中相应的内容复制到新建的文件中。
修改 mini-single-example.yaml 文件。
执行
vi /root/obdeploy-master/example/mini-single-example.yaml命令,然后按" i "键修改该文件如下: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 数据库时需使用。
执行
:wq命令退出并保存修改。
执行如下命令部署名为 test 的 OceanBase 集群。
obd cluster deploy test -c ./example/mini-single-example.yaml执行如下命令启动集群。
obd cluster start test使用客户端连接到该 OceanBase 数据库,测试是否安装成功。
- 使用 OBClient 连接执行命令:obclient -hxxx.xxx.xxx.xxx -u<用户名称>@<租户名词> -P2881
- 使用 MySQL 客户端连接执行命令:mysql -hxxx.xxx.xxx.xxx -u<用户名称>@<租户名词> -P2881