本文使用基于CentOS 8的Docker来测试运行oceanbase数据库。
前提要求:
功能学习,CPU至少两核,硬件内存至少10G,磁盘空间至少10G。
如果要做性能测试,需要24核,128G内存,SSD 500G 以上
若要用于生产环境,需要32核,256G内存,SSD 2T 以上,且至少“三台”这样的计算机。

本文,仅限功能学习,最小化配置:CentOS 8+ Docker。

第一步,安装docker工具

yum install -y yum-utils

第二步,添加yum源

yum-config-manager  --add-repo   https://download.docker.com/linux/centos/docker-ce.repo

第三步,安装 docker

yum install -y docker-ce docker-ce-cli containerd.io

第四步,启用和启动docker服务

systemctl enable docker
systemctl start docker

第五步,拉取 OceanBase 数据库相关镜像

docker pull oceanbase/obce-mini

第六步,启动 OceanBase Docker 容器

docker run \
-p 2881:2881 \
--name obce-mini \
-d \
-e OB_HOME_PATH="/root/obce/" \
-e OB_TENANT_NAME="obmysql" \
--restart=always \
oceanbase/obce-mini

第七步,查看容器启动日志

docker logs obce-mini

输出如下信息,表示启动完成

generate boot.yaml ...
create boot dirs and deploy ob cluster ...
Package oceanbase-ce-3.1.0 is available.
install oceanbase-ce-3.1.0 for local ok
+-----------------------------------------------------------------------------+
|                                   Packages                                  |
+--------------+---------+---------+------------------------------------------+
| Repository   | Version | Release | Md5                                      |
+--------------+---------+---------+------------------------------------------+
| oceanbase-ce | 3.1.0   | 2.el7   | afd11d52f83eef4b456d77969fde620c4bfba85e |
+--------------+---------+---------+------------------------------------------+
Open ssh connection ok
Remote oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e repository install ok
Remote oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e repository lib check !!
[WARN] 127.0.0.1 oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e require: libaio.so.1
[WARN] 127.0.0.1 oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e require: libmariadb.so.3

Try to get lib-repository
Package oceanbase-ce-libs-3.1.0 is available.
install oceanbase-ce-libs-3.1.0 for local ok
Use oceanbase-ce-libs-3.1.0-47300ca1ac4c62493caf3e9235b105e242e533b5 for oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e
Remote oceanbase-ce-libs-3.1.0-47300ca1ac4c62493caf3e9235b105e242e533b5 repository install ok
Remote oceanbase-ce-3.1.0-afd11d52f83eef4b456d77969fde620c4bfba85e repository lib check ok
Cluster status check ok
127.0.0.1 initializes cluster work home
mini-ce deployed
start ob cluster ...
Get local repositories and plugins ok
Open ssh connection ok
Cluster param config check ok
Check before start observer ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.0   | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+

mini-ce running
generate init_tenant.sql ...
init tenant and sysbench database ...
boot success!

第八步,安装 oceanbase client,也可以用mysql client

yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
yum install -y obclient

第九步,链接oceanbase数据库

obclient -h 127.1 -P2881
#修改root密码
alter user root identified by 'rootPWD123'

查询数据库

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]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.004 sec)

Oceanbase Developer Center连接字符串

obclient -h192.168.240.59 -P2881 -uroot@sys -Doceanbase -prootPWD123

官方文档链接
https://open.oceanbase.com/docs/tutorials-cn/V1.0.0/10000000000012294

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐