OceanBase数据库简单安装部署——筑梦之路

环境说明:

操作系统:CentOS 7

官方文档:

OceanBase 社区

参考资料:

基于CentOS系统安装OceanBase数据库 - 简书

# 添加yum源

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

# 修改配置文件

## 配置示例文件

https://gitee.com/oceanbase/oceanbase/raw/master/tools/quick_start/quick_start_demo.yaml

## 配置数据库工作目录

oceanbase-ce:
  global:
    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /home/observer

home_path 是 OceanBase 数据库的工作目录,OceanBase 数据库在此目录下启动

# 部署并启动 OceanBase 数据库

## 部署集群

obd cluster autodeploy obtest -c quick_start_demo.yaml -A

其中,obtest 为集群名称,这里只是示例,您可自行定义集群名称。一个集群只能有一个名称,且集群名称不能重复。增加 -A 参数后,将自动用系统剩余资源创建 test 租户

命令详细参考:https://open.oceanbase.com/docs/obd-cn/V1.3.3/10000000000182177


## 查看集群状态

obd cluster display obtest

命令详细参考:https://open.oceanbase.com/docs/obd-cn/V1.3.3/10000000000182177

# 连接数据库

## 安装客户端

sudo yum install -y obclient

## 连接数据库

obclient -h127.0.0.1 -P2881 -uroot@test

OBClient 默认使用端口 2881 来连接 OBServer,如果您对端口做了更改,此处使用您实际的端口号。tenant_name 为您将要连接的租户名

## 检查租户信息

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;

 Docker部署OceanBase数据库

机器的资源至少可以运行 2 核 8GB 以上的 Docker 容器

# 根据当前容器部署最大规格的实例
docker run -p 2881:2881 --name obstandalone -d oceanbase/oceanbase-ce

## 部署 mini 的独立实例
docker run -p 2881:2881 --name obstandalone -e MINI_MODE=1 -d oceanbase/oceanbase-ce


说明
上述命令默认拉取最新版本,可根据实际需求在 Docker 镜像 中选择版本。

启动预计需要 2-5 分钟。执行以下命令,如果返回 boot success!,则启动成功。

$ docker logs obstandalone | tail -1
boot success!


# 连接数据库

oceanbase-ce 镜像安装了 OceanBase 数据库客户端 OBClient,并提供了默认连接脚本 ob-mysql

docker exec -it obstandalone ob-mysql sys # 连接 sys 租户的 root 用户
docker exec -it obstandalone ob-mysql root # 连接 test 租户的 root 用户
docker exec -it obstandalone ob-mysql test # 连接 test 租户的 test 用户

本机OBClient 或者 MySQL 客户端连接

mysql -uroot -h127.1 -P2881

连接成功后,终端将显示如下内容:


$ docker exec -it obstandalone ob-mysql sys

login as root@sys
Command is: obclient -h127.1 -uroot@sys -A -Doceanbase -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 3221487638
Server version: 5.7.25 OceanBase 3.1.3 (r10100032022041510-a09d3134c10665f03fd56d7f8bdd413b2b771977) (Built Apr 15 2022 02:16:22)

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 [oceanbase]>

生产环境部署:OceanBase 社区

帮助信息

# obd -h
Usage: obd <command> [options]

Available commands:

cluster        Deploy and manage a cluster.

mirror         Manage a component repository for OBD.

repo           Manage local repository for OBD.

test           Run test for a running deployment.

update         Update OBD.


Options:
  --version      show program's version number and exit
  -h, --help     Show help and exit.
  -v, --verbose  Activate verbose output.

# 查看obd管理的集群列表

obd cluster list

sysbench对oceanbase基准性能测试:Sysbench对OceanBase开源版3.1.3数据库的OLTP性能测试_shunwahma的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/126294630