基于湖库一体架构,统一管理结构化、半结构化与非结构化等多模态数据,一个系统承载事务处理、实时分析与 AI 工作负载。
使用 OBD 部署 OceanBase 数据库
更新时间:2023-09-08 14:55:57
本文介绍如何使用 OBD 部署 OceanBase 数据库。
获取 OceanBase 数据库最快的方式是使用 OBD 获取,因此推荐您通过安装 OBD 获取 OceanBase 数据库。您还可以通过以下方式获取 OceanBase 数据库:
名词解释
中控机器
存储 OceanBase 数据库安装包和集群配置信息的机器。
目标机器
安装 OceanBase 数据库的机器。
前提条件
在安装 OceanBase 数据库之前,您需要确认以下信息:
您的机器满足软硬件要求。详细信息请参考 资源准备。
您的机器可以连接公网。
如果您的机器不能连接公网,您需要 使用 RPM 包安装 OceanBase 数据库。
您已经在中控机器安装了 OBD。详细信息请参考 安装 OBD。
您已经在中控机器安装了 OceanBase 数据库的客户端 OBClient。详细信息请参考 OBClient 文档。
部署步骤
修改配置文件
从 GitHub 上下载对应的配置文件模板。
如果您采用本地安装,即中控机器和目标机器是同一台机器,请下载 本地安装配置文件。
如果您采用单机安装,即中控机器和目标机器不是同一台机器,且目标机器只有一台,请下载 单机安装配置文件。
如果您采用分布式安装,即中控机器和目标机器不是同一台机器,且目标机器有多台,请下载 分布式安装配置文件。
注意
此处以本地安装为例,介绍如何修改配置文件。您需按照您的安装方式选择对应的配置文件模板。
在配置文件顶部添加用户密码信息。
user: username: <您的账号名> password: <您的登录密码> key_file: <您的私钥路径>其中,
username为登录到目标机器的用户名,确保您的用户名有 OBServer 进程工作目录home_path的权限。注意
通常情况下,您只能使用密码登录或者私钥登录中的一种方式登录目标机器。
修改配置文件中的 IP 地址。
oceanbase-ce: servers: - name: z1 # Please don't use hostname, only IP can be supported ip: 10.xxx.xx.01修改配置文件中的
devname变量和home_path变量。oceanbase-ce: global: home_path: <your_observer_work_path> # 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: bond0注意
您需要拥有
home_path目录的权限。
启动 OceanBase 数据库
运行以下命令部署集群:
obd cluster deploy <deploy_name> -c <deploy_config_path>其中,参数
deploy_name为部署集群名称,可以理解为配置文件的别名。此命令会检查
home_path和data_dir指向的目录是否为空。若目录不为空,则报错。此时可以加上-f选项,强制清空。在您执行了
obd cluster deploy命令之后,OBD 将检查您的目标机器是否有 OceanBase 数据库安装包。如果没有安装包,OBD 将自动从 yum 源获取。如果您的机器不能访问公网,您可以从 OceanBase 官网下载安装包。详细信息,参考 安装包下载说明。运行以下命令启动集群:
obd cluster start <deploy_name>此命令会检查系统参数
fs.aio-max-nr是否不小于1048576。通常情况下一台机器启动一个节点不需要修改fs.aio-max-nr。但当一台机器需要启动 4 个及以上的节点时,请务必修改fs.aio-max-nr。运行以下命令查看集群状态:
obd cluster display <deploy_name>
连接 OceanBase 数据库
您可运行如下命令,使用 OBClient 客户端连接 OceanBase 数据库:
obclient -h<your_ip> -P<observer_mysql_port> -uroot -p******
其中,your_ip 为您 OceanBase 实例所在的机器 IP 地址。observer 默认使用端口 2881 连接 OBClient。如果您对端口做了更改,此处使用您实际的端口号。
使用 OBClient 客户端连接 OceanBase 集群的详细操作可参考 通过 OBClient 连接 OceanBase 租户。
返回如下信息:
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is xxxx
Server version: 5.6.25 OceanBase 3.1.3 (r10100032022041510-xxxxxxxxxxxxxxxxxxx) (Built Apr 15 2022 02:16:22)
Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
(可选)验证集群
连接 OceanBase 数据库,运行以下命令验证集群:
MySQL [oceanbase]> USE oceanbase;
MySQL [oceanbase]> SELECT * FROM __all_server;
返回如下结果:
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| gmt_create | gmt_modified | svr_ip | svr_port | id | zone | inner_port | with_rootserver | status | block_migrate_in_time | build_version | stop_time | start_service_time | first_sessid | with_partition | last_offline_time |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
| 2022-04-21 10:59:04.967158 | 2022-04-21 10:59:20.344774 | 10.xxx.xx.01 | 2882 | 1 | zone1 | 2881 | 1 | active | 0 | 3.1.3_10100032022041510-a09d3134c10665f03fd56d7f8bdd413b2b771977(Apr 15 2022 02:16:22) | 0 | 1618973957346877 | 0 | 1 | 0 |
| 2022-04-21 10:59:04.956632 | 2022-04-21 10:59:20.223340 | 10.xxx.xx.02 | 2882 | 2 | zone2 | 2881 | 0 | active | 0 | 3.1.3_10100032022041510-a09d3134c10665f03fd56d7f8bdd413b2b771977(Apr 15 2022 02:16:22) | 0 | 1618973958225270 | 0 | 1 | 0 |
| 2022-04-21 10:59:03.956853 | 2022-04-21 10:59:22.415147 | 10.xxx.xx.03 | 2882 | 3 | zone3 | 2881 | 0 | active | 0 | 3.1.3_10100032022041510-a09d3134c10665f03fd56d7f8bdd413b2b771977(Apr 15 2022 02:16:22) | 0 | 1618973958416271 | 0 | 1 | 0 |
+----------------------------+----------------------------+---------------+----------+----+-------+------------+-----------------+--------+-----------------------+--------------------------------+-----------+--------------------+--------------+----------------+-------------------+
3 rows in set (0.00 sec)
以上返回结果说明集群部署成功。