前提条件
在安装 OceanBase 数据库之前,确保您的机器可以连接公网。并且您的软硬件环境满足以下要求:
项目 | 描述 |
|---|---|
系统 |
|
CPU |
|
内存 |
|
磁盘类型 | 推荐使用 SSD |
磁盘存储空间 | 内存大小的 4 倍及以上 |
文件系统 | EXT4 戓 XFS,当数据超过 16T 时,使用 XFS |
网卡 | 千兆互联及以上 |
说明
以下内容以 x86 架构的 CentOS Linux 7.2 镜像作为环境,其他环境可能略有不同。
步骤 1:下载安装 OBD
获取 OceanBase 数据库最快的方式是使用数据库部署工具 OceanBase Deployer(简称 OBD),因此推荐您使用此方式体验 OceanBase 数据库。按照以下步骤下载并安装 OBD。
方案1:通过 YUM 软件源安装 OBD
如您的机器可以访问公网,并能够添加三方 YUM 软件源,您可以运行以下命令,使用 OceanBase 的官方软件源安装 OBD:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy方案2:离线安装 OBD
下载 OBD 离线 RPM 安装包。
运行以下命令安装 OBD。
yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm source /etc/profile.d/obd.sh
步骤 2:部署 OceanBase 数据库
本节介绍如何使用 OBD 部署 OceanBase 数据库。按照以下步骤部署 OceanBase 数据库:
从 Github 上下载对应的配置文件模板。
在配置文件顶部添加用户密码信息。
user: username: <您的账号名> password: <您的登录密码> key_file: <您的私钥路径>其中,
username为登录到目标机器的用户名,确保您的用户名有home_path权限。注意
通常情况下,您只能使用登录密码或者私钥登录中的一种方式登录目标机器,如果同时填写,password 将被认为是您私钥的密码。
修改配置文件中的 IP 地址(可选)。
oceanbase-ce: servers: - name: z1 # Please don't use hostname, only IP can be supported ip: 11.166.80.01修改配置文件中的
home_path。oceanbase-ce: servers: # Please don't use hostname, only IP can be supported - 192.168.1.3 global: # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field. home_path: /root/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
步骤 3:启动 OceanBase 数据库
按照以下步骤部署并启动 OceanBase 数据库实例:
运行以下命令部署集群:
obd cluster autodeploy <deploy_name> -c <deploy_config_file> -A其中,
deploy_name为集群名称,一个集群只能有一个名称,且集群名称不能重复。增加 -A 参数后,将自动用系统剩余资源创建 test 租户。运行以下命令查看集群状态:
obd cluster display <deploy_name>
步骤 4:连接 OceanBase 数据库
按照以下步骤连接 OceanBase 数据库:
安装 OceanBase 数据库客户端 OBClient:
如您的机器已添加 OceanBase 官方 YUM 源作为软件源,使用以下命令直接安装:
sudo yum install -y obclient否则您需要在机器上准备好离线安装包,并执行以下命令安装:
sudo yum install -y libobclient-2.0.0-2.el7.x86_64.rpm sudo yum install -y obclient-2.0.0-2.el7.x86_64.rpm运行以下命令,使用 OBClient 客户端连接 OceanBase 数据库:
obclient -h<your_ip> -P<observer_mysql_port> -uroot其中,
your_ip为您 OceanBase 实例所在的机器 IP 地址。observer默认使用端口2883连接 OBClient。如果您对端口做了更改,此处使用您实际的端口号。检查 test 租户拥有多少资源, 返回以下信息:
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221546072 Server version: 5.7.25 OceanBase 3.1.0 (r1-) (Built Apr 7 2021 08:14:49) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> use oceanbase; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MySQL [oceanbase]> select * from gv$tenant;




