一文读懂 | 如何快速部署 OceanBase 开源版

2024年 5月 7日 17.1k 0

本文节选自《OceanBase 开源版入门实战课程》的一部分,主要分享如何快速部署 OceanBase 开源版,希望对大家有帮助。

01 部署准备


OceanBase 是一个分布式集群产品,在生产环境至少是三台机器。学习环境可以部署单机版本。

OceanBase 的部署跟传统数据库的部署有很多共同的地方,对操作系统硬件、软件设置、文件系统等会有一些最佳实践建议。那些是 OceanBase 发挥高性能稳定运行的基础。社区版也提供了工具能实现一定程度的自动化。

软件介绍

OceanBase 本质上是一个单进程的软件,可执行文件名叫 observer 。可以通过 RPM 包安装,也可以通过源码直接编译安装。本课程都是通过 RPM 包方式安装。

软件包下载地址有:

官网下载:

open.oceanbase.com/softwareCenter/community

GitHub 下载:

github.com/oceanbase/oceanbase/releases/

阿里云 Yum 源:

mirrors.aliyun.com/oceanbase/OceanBase.repo

一文读懂 | 如何快速部署 OceanBase 开源版-1

注意:版本号后期会变,以实际版本为主。

如果机器可以连公网,可以将阿里云 YUM 源添加到本地仓库,使用 yum 命令安装。

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

部署资源要求

OceanBase 数据库运行的时候会对主机资源有一些要求,主要是 CPU、内存和磁盘空间。安装 OceanBase 的目的不一样,对资源的要求也不一样。

一文读懂 | 如何快速部署 OceanBase 开源版-2

注意:上面性能测试环境和生产环境的资源要求是建议。在社区版后续版本,会进一步降低对内存的要求。

OceanBase 对操作系统也有一些要求,目前支持下面这些系统:

  • Redhat / CentOS 7.x/8.x
  • SUSE / OpenSUSE 15.x
  • Anlios 7.x/8.x
  • Debian 9.x
  • Ubuntu 20.x

部署过程简介

自动化部署过程简单来说分为几步:

  • 初始化 OceanBase 各个节点环境。包括参数配置、文件系统目录设置等。
  • (可选)初始化中控机到OceanBase 各个节点的 SSH 免密登录。
  • 准备 OBD 自动化部署配置文件。
  • 使用 OBD 部署集群节点目录。
  • 使用 OBD 启动并初始化集群。

后面还会详细介绍单节点和三节点集群的部署方法,以及手动部署的一些步骤。

02 如何快速体验 OceanBase


在部署 OceanBase 社区版之前,建议您快速通过 Docker 环境看一下一个部署好的 OceanBase 社区版环境。我们提供了一个 OceanBase 社区版 Docker 镜像,您可以在您的笔记本或电脑上使用 Docker 技术快速部署并启动 OceanBase 社区版的 Docker 容器。

03 如何规划OceanBase集群部署


集群架构规划

OceanBase 以集群形态运行,生产环境最小规模是 3 台服务器(节点)。整个集群里,业务数据会有三份,所以也叫三副本。学习测试的时候,可以部署 单副本单节点 OceanBase 集群。

这里特别说明的是,单副本跟单节点并不完全对等。单副本单节点是最小集群规模,单副本也是可以扩容为多个节点,整个集群里数据依然是一份,所以叫单副本。

生产环境,每个机器上启动一个 observer 进程,所以一台机器就对应一个节点。学习环境,一个机器可以启动多个 observer 进程,模拟多个节点。每个节点的监听端口(默认是 2881 和 2882 )、数据总目录是独立的,互不冲突。每个节点进程启动的最小内存是 10G ,空间需要至少 10G 。

所以,如果只有一台服务器,如果机器可用内存不足 10G, 则不能启动 observer 进程。如果可用内存在10G ~ 20G 之间,则只可以启动一个 observer 进程。如果可用内存在 20G ~ 30G 之间,可以启动 2 个 observer 进程。如果可用内存超过 30G ,则可以启动 3个 observer 进程。当然,内存充足的时候,也可以调大每个 observer 进程能获取的内存。内存越大,节点的资源能力就越大。如果有三台机器,就没必要在一个机器上模拟多个节点了。

除了要部署 observer 进程,还需要部署 obproxy 。 obproxy 也是单进程软件,是访问 OceanBase 的反向代理。虽然 observer 节点都可以直接访问,生产环境还是建议通过 obproxy 访问 OceanBase 集群。

obproxy 进程部署位置没有要求。可以部署在应用服务器上,也可以部署在独立的机器上,或者部署在 OceanBase 机器上。obproxy 可以部署多个,生产环境建议至少部署两个。

用户规划

OceanBase 本质上是一个软件,可以运行在任意用户下。OceanBase 软件包默认解压目录是在 /home/admin/ 下,生产环境默认也是安装在用户 admin 下。社区版的软件 RPM 包也是这个特点,支持部署在任意用户的任意目录下。

为了安全起见,我们不建议在 root 用户下直接部署。所以后面都以部署在用户 admin 下为前提。在部署之前初始化环境的时候,可能需要修改操作系统的配置,或者设置目录的权限等,这些操作需要 root 用户权限。不同客户内部主机登录规范不一样,可以通过 su 切换到 root 用户,或者给 admin 用户增加 sudo 权限。

目录规划

跟 observer 有关的目录有好几个:

  • 软件安装目录。

如果是安装 OceanBase 的 RPM 包,则需要提前创建好用户 admin ,并被自动安装在目录 /home/admin/oceanbase 下。

[root@obce00 ~]# useradd admin
[root@obce00 ~]# rpm -ivh rpm/*
准备中...                          ################################# [100%]
正在升级/安装...
   1:oceanbase-ce-libs-3.1.0-1.el7    ################################# [ 33%]
   2:oceanbase-ce-3.1.0-1.el7         ################################# [ 67%]
   3:obproxy-3.1.0-1.el7              ################################# [100%]

[root@obce00 ~]# rpm -ql oceanbase-ce-3.1.0-1.el7.x86_64
/home/admin/oceanbase
/home/admin/oceanbase/bin
/home/admin/oceanbase/bin/import_time_zone_info.py
/home/admin/oceanbase/bin/observer
/home/admin/oceanbase/etc
/home/admin/oceanbase/etc/timezone_V1.log
[root@obce00 ~]# rpm -ql obproxy-3.1.0-1.el7
/home/admin/obproxy-3.1.0/bin
/home/admin/obproxy-3.1.0/bin/obproxy
/home/admin/obproxy-3.1.0/bin/obproxyd.sh

如果是通过OBD 软件自动化安装,则会将 RPM 包解压到 用户 HOME 目录的隐藏文件夹 .obd 下,如:/.obd/repository/oceanbase-ce/3.1.0/afd11d52f83eef4b456d77969fde620c4bfba85e 。这种方式是可以同时部署多个版本。

后面讲解部署方法会首先介绍 OBD 软件自动化部署方法。手动部署方法留在最后,供感兴趣的朋友参考。

04 如何初始化服务器环境


OceanBase 数据库是单进程软件,需要访问网络,需要打开多个文件以及开启很多 TCP 连接,所以需要修改内核参数和用户会话设置。

注意:OBProxy 软件如果独立服务器部署的话,也按这个要求初始化服务器环境。

内核参数修改

修改配置文件。

vim /etc/sysctl.conf

net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.ip_local_port_range = 3500 65535
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_slow_start_after_idle=0

vm.swappiness = 0
vm.min_free_kbytes = 2097152
vm.max_map_count=655360
fs.aio-max-nr=1048576

让配置生效

sysctl -p

修改会话变量设置

您可以通过配置 limits.conf 限制修改会话限制。OceanBase 数据库的进程涉及的限制包括线程最大栈空间大小(Stack)、最大文件句柄数(Open Files)和 core 文件大小 (Core File Size)。

您可以使用以下两种方法修改资源限制:

  • 通过启动时在会话级别修改。如:ulimit -c unlimited , 只影响当前会话。如果会话断开重连了,则又是默认配置。
  • 通过配置文件 /etc/security/limits.conf 在全局级别修改。注意修改后,已经登录的会话需要退出重登录才生效。

更改配置文件说明

将会话级别的最大栈空间大小设置为 unlimited,最大文件句柄数设置为 655350,Core 文件大小设置为 unlimited 。

修改 /etc/security/limits.conf 配置文件,如果已有设置值低于这个设置值。

vi /etc/security/limits.conf

* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited

查看配置

退出当前会话,重新登录。执行以下命令,查看配置是否生效:

ulimit -a

关闭防火墙和 SELinux

不同操作系统的防火墙设置可能有点不同,下面以 CentOS 系统为例。

  • 关闭防火墙

查看防火墙状态

systemctl status firewalld

如果是 inactive 那就不用管。如果是 active,那就永久关闭。

systemctl disable firewalld 
systemctl stop firewalld
systemctl status firewalld

  • 关闭 SELinux

修改 SELinux 配置文件中的 SELINUX 选项。

注意:必须使用注释中的三个值之一。如果写错了,机器重启后操作系统会报错起不来,那时候就只能进入单用户模式修改了。

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled

配置文件修改后只会重启后生效,还需要使用下面命令立即生效。

setenforce 0

配置时间同步服务

OceanBase 是分布式数据库产品,是一个集群软件,对各个节点之间的时间同步性有要求。技术上要求所有节点之间的时间误差控制在 50ms 以内。实际生产环境为了稳定性和性能考虑,建议时间误差控制在 10ms 以内。通常只要节点配置时间同步服务器跟公网时间保持同步即可。实际上在企业机房里,企业会有统一的时间服务器跟机房提供的时间服务器或者直接跟公网时间服务器同步,OceanBase 节点只需要跟机房统一的时间服务器进行同步即可。

CentOS 或 RedHat 7.x 版本推荐使用 chrony 服务做时间源。Chrony 是 NTP(Network Time Protocol,网络时间协议,服务器时间同步的一种协议)的另一种实现,与 ntpd 不同,它可以更快且更准确地同步系统时钟,最大程度的减少时间和频率误差。有关时间同步技术请参考时间同步产品官方介绍。

配置安装用户

前面分析过,建议安装部署在普通用户下,后面都以用户 admin 为例。

注意:给用户 admin 赋 sudo 权限不是必须的,只是为了某些时候方便。您可以结合企业安全规范决定是否执行。

验证方法,切换到 admin 用户下,执行命令:sudo date 。输入密码后能返回结果。

配置 SSH 免密登录

如果您是完全手动部署 OceanBase 集群,则登录到相应节点上安装相关软件包,并启动 observer 或 obproxy 进程,则不需要配置 SSH 免密登录。

如果您是使用自动化技术部署 OceanBase 集群,则需要一台中控机。所有的命令通过中控机向 OceanBase 集群节点发出。则需要配置中控机的 OBD 运行的用户到 OceanBase 集群节点的 OBSERVER 安装的用户的 SSH 免密登录。本文示例是中控机的用户 admin 到 OBSERVER 节点的用户 admin 的免密登录。

这个配置 SSH 免密登录方法有很多,这里选择将中控机的 RSA 或 DSA 公钥复制到目标节点的 SSH 配置文件中。

磁盘文件系统划分

OceanBase 读写磁盘主要是三类文件:

  • 运行日志。在启动目录下的 log 目录里。主要记录进程 observer 的运行日志、选举服务的运行日志和 rootservice 的运行日志。主要读写特点是顺序写。
  • 数据文件。主要是指数据文件 block_file ,一次性初始化大小,后面可以在线扩容,但是不能缩容。主要读写特点是随机读、顺序写。偶尔密集的随机写。
  • 日志文件。主要是指事务和sstable相关的日志 ,包括 clogilog 和 slog 等。主要读写特点是顺序写。

这三个文件尽可能的分散在不同的磁盘上存储。如果物理上只有一块盘,则可以使用 fdisk 或 lvm 划分为多个逻辑盘。

下面针对机器提供的裸盘(/dev/vdb) 演示如何分盘。

  • 方法一是使用 fdisk 直接将 /dev/vdb 划分为两个逻辑盘 (/dev/vdb1 和 /dev/vdb2 )。
  • 这个方法的缺陷是这里 /dev/vdb 是云盘,后期还可以扩容,使用 fdisk 分盘后,扩容比较麻烦。
  • 方法二是对 /dev/vdb 使用 LVM 技术,划分出两个 LV 出来,一个给数据文件用,一个给日志文件。

fdisk 或者 parted ,以及 LVM 技术都是磁盘划分组合的手段。这里就不详细描述方法。

不管是哪种办法,优先考虑日志文件的大小,生产环境建议是可用内存大小的 3-4 倍。剩余的大小再留给数据文件。如果是学习环境,总的盘大小本身就很小,可以不遵守这个规则,日志文件大小比内存大 1-2 倍也可以。

注意:OBProxy 独立部署的服务器就不用做这个文件系统划分了。

05 如何安装 OBD自动化部署软件


根据中控机器能否连接公网,提供两个安装方法:离线和在线二选一。

安装 OBD 软件(离线)

首先在中控机上部署 OBD 软件。如果中控机不能上网,则需要提前下载好 OBD 、 OBSERVER 和 OBPROXY 相关软件包。

  • 下载相关软件包

软件包地址:https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/

将上面文件都复制到中控机上临时目录。

  • 离线安装 OBD
[admin@obce00 obd]$ sudo rpm -ivh ob-deploy-1.1.0-1.el8.x86_64.rpm

ob-deploy 软件默认安装在 /usr/obd 下。不同版本可能有点变化。可以通过下面命令查看位置。

rpm -ql `rpm -qa|grep ob-deploy`

但是 OBD 工作的文件都在当前用户 HOME 目录下:~/.obd/ 。熟悉下面目录结构对以后排查 OBD 问题有用。

[admin@obce00 ~]$ tree ~/.obd -L 1
/home/admin/.obd
├── cluster
├── log
├── mirror
├── obd.conf
├── plugins
├── repository
└── version

5 directories, 2 files

  • 将软件包加到离线仓库

首先要删除远程仓库,使用下面命令。

注意:下面命令要在部署运行 OBD 的操作系统用户下操作。这里是用户 admin 。

/bin/rm -rf ~/.obd/mirror/remote/OceanBase.repo

然后将前面的软件包都复制到本地仓库,使用下面命令。

obd mirror clone /tmp/obd/*.rpm

查看仓库的RPM列表。

obd mirror list local

安装 OBD (在线)

首先在中控机上部署 OBD 软件。如果中控机能上网,则可以直接添加 OceanBase 的仓库,使用 YUM 安装。

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

06 使用OBD自动化部署单节点集群


OBD 对 OceanBase 的管理权限很高,所以 OBD 要部署在数据库服务器的中控机上,需要 DBA 有完全的控制权限。

部署规划

这里我使用一台机器。

  • 机器信息如下:

一文读懂 | 如何快速部署 OceanBase 开源版-3

  • 机器和角色划分:

一文读懂 | 如何快速部署 OceanBase 开源版-1

磁盘划分,这里就使用 LVM 技术对 /dev/vdb 进行划分。LVM 划分 LV 大小时请根据实际磁盘大小调整参数。

# lvm 分盘
pvcreate /dev/vdb
vgcreate obvg /dev/vdb
lvcreate -L 20G obvg -n lvredo
lvcreate -l 100%FREE obvg -n lvdata

# 格式化文件系统
mkfs.ext4 /dev/obvg/lvdata
mkfs.ext4 /dev/obvg/lvredo

# 修改 mount 参数文件
vim /etc/fstab 
/dev/obvg/lvredo          /redo              ext4            defaults,noatime,nodiratime,nodelalloc,barrier=0        0 0
/dev/obvg/lvdata             /data         ext4            defaults,noatime,nodiratime,nodelalloc,barrier=0        0 0

# 挂载文件系统
mkdir -p /data /redo
vim /etc/fstab
mount /data
mount /redo
chown -R admin.admin /data /redo

# 检查
df -h

输出:
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/obvg-lvdata   59G   53M   56G    1% /data
/dev/mapper/obvg-lvredo   20G   45M   19G    1% /redo
  

编辑 OBD 配置文件

OBD 针对不同的部署场景提供不同的配置文件。这些配置文件示例在 OceanBase 开源项目地址里,具体是:https://github.com/oceanbase/obdeploy/tree/master/example 。

如果是部署单节点版本,就下载其中两个配置文件:

  • 部署单节点 observer 进程: https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-example.yaml
  • 部署单节点 observer 和 obproxy 进程:https://github.com/oceanbase/obdeploy/blob/master/example/mini-single-with-obproxy-example.yaml

这里简单起见,只部署单节点 observer 进程,所以下载第一个配置文件。

注意:后续版本的配置文件格式可能会有些变化,请参考 OBD 工具具体使用说明。

[admin@obce00 ~]$ cat obce-single.yaml
## Only need to configure when remote login is required
# user:
#   username: your username
#   password: your password if need
#   key_file: your ssh-key file path if need
#   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30
oceanbase-ce:
  servers:
    # Please don't use hostname, only IP can be supported
    - 172.20.249.50
  global:
    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /home/admin/oceanbase-ce
    # 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
    # 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: eth0
    mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
    rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
    zone: zone1
    cluster_id: 1
    # please set memory limit to a suitable value which is matching resource.
    memory_limit: 8G # The maximum running memory for an observer
    system_memory: 3G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
    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
    # The value of net_thread_count had better be same as cpu's core number.
    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 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
    datafile_size: 50G
    syslog_level: WARN # System log level. The default value is INFO.
    enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
    enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
    max_syslog_file_count: 10 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
    root_password: bzNvgyhB  # root user password, can be empty

这个配置文件是专门针对最小内存(可用内存大于 8G)的节点配置,里面指定了很多进程 observer 的启动参数。注意 yaml 的格式,每个配置项后面冒号(:) 跟后面的值之间必须有个空格(' ')。

下面就关键的几个参数补充说明如下:

一文读懂 | 如何快速部署 OceanBase 开源版-5

一文读懂 | 如何快速部署 OceanBase 开源版-6 一文读懂 | 如何快速部署 OceanBase 开源版-2

当上面部署成功后,OBD 会把配置文件 obce-single.yaml 复制到自己的工作目录里(~/.obd/cluster/obce-single/config.yaml ),后期再改外面这个 obce-single.yaml 文件,是不生效的。

注意:如果你机器内存大于 64G 时,上面参数跟内存有关的参数可以不设置。

OBD 开始部署集群

配置文件准备好后,就可以部署这个配置文件对应的集群了,部署内容主要包含:

  • 复制软件到相应节点,并安装软件。
  • 在相应节点创建相关目录。

部署使用命令:obd cluster deploy [集群名] -c 集群配置文件 

这个集群名只是这个配置文件在 OBD 里的唯一标识,可以跟配置文件中的集群名一样,也可以跟文件名一样,这个不强要求。

obd cluster deploy obce-single -c obce-single.yaml

检查一下部署的结果。

  • 首先看部署状态,用命令 obd cluster list 。
obd cluster list

  • 第二主要看目录结构。其中 目录 /store 、/data 和 /redo 的目录关系是重点。总体结构不变,后期映射关系可能会细微调整。
[admin@obce00 ~]$ tree /home/admin/oceanbase-ce/
/home/admin/oceanbase-ce/
├── admin
├── bin
│   └── observer -> /home/admin/.obd/repository/oceanbase-ce/3.1.0/84bd2fe27f8b8243cc57d8a3f68b4c50f94aab80/bin/observer

<......>

├── log
└── store -> /data
[admin@obce00 ~]$ tree /data
/data
├── clog -> /redo/clog
├── ilog -> /redo/ilog
├── slog -> /redo/slog
└── sstable

4 directories, 0 files
[admin@obce00 ~]$ tree /redo
/redo
├── clog
├── ilog
└── slog

3 directories, 0 files

OBD 开始启动和初始化集群

上面 deploy 操作只是安装了软件和准备初始化目录,还需要启动集群节点并初始化集群,使用 obd cluster start 命令。

第一次运行 start 会对集群进行初始化(boostrap),以后再 start 就只会启动集群中节点进程。

obd cluster start obce-single

这个命令会在 bootstrap 要几分钟。当可用内存不足 8G 或者 日志目录剩余可用空间比例不足 5% 的时候,这个 bootstrap 是很可能会失败的。

接下来进一步确认集群初始化成功。这个步骤是可选的。第一次学习或生产部署的时候,建议检查一下。具体请参考原文。

连接 OceanBase 集群的内部实例(sys)

传统的 mysql 客户端可以连接 OceanBase 社区版,前提是 mysql 的版本是 5.5/5.6/5.7 。OceanBase 也提供自己的客户端工具 obclient 需要安装使用。

跟传统MySQL 不一样的地方是 OBSERVER 连接端口是 2881 , 连接用户名是 :root@sys ,密码是前面 OBD 配置文件里指定的。

[admin@obce00 ~]$ mysql -h 172.20.249.50 -uroot@sys -P2881 -pbzNvgyhB -c -A oceanbase

在数据库列表里看到 oceanbase 这个数据库,就表示集群初始化成功。

obclient 安装和使用示例。

sudo rpm -ivh /tmp/obd/obclient-2.0.0-2.el8.x86_64.rpm /tmp/obd/libobclient-2.0.0-2.el8.x86_64.rpm

obclient -h 172.20.249.50 -uroot@sys -P2881 -pbzNvgyhB -c -A oceanbase

07 附录


A1.生存环境三节点 OB 集群部署配置文件

生产环境机器内存大于 256G 时,参考下面配置文件。这里多了一个 OBPROXY 配置。

## Only need to configure when remote login is required
user:
   username: admin
#   password: your password if need
   key_file: /home/admin/.ssh/id_rsa.pub
   port: your ssh port, default 22
#   timeout: ssh connection timeout (second), default 30
oceanbase-ce:
  servers:
    - name: obce01
      # Please don't use hostname, only IP can be supported
      ip: 172.20.249.53
    - name: obce02
      ip: 172.20.249.55
    - name: obce03
      ip: 172.20.249.56
  global:
    # 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
    cluster_id: 2
    # please set memory limit to a suitable value which is matching resource.
    # memory_limit: 200G # The maximum running memory for an observer
    # system_memory: 30G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
    minor_freeze_times: 100
    minor_warm_up_duration_time: 0
    freeze_trigger_percentage: 40
    enable_merge_by_turn: FALSE
    datafile_disk_percentage: 50 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
    # datafile_size: 500G
    syslog_level: INFO # System log level. The default value is INFO.
    enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
    enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
    max_syslog_file_count: 50 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
    # observer cluster name, consistent with obproxy's cluster_name
    appname: obce-3zones
    root_password: 0EI5N08d # root user password, can be empty
    proxyro_password: FAKEPASSWORD02 # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
  obce01:
    mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
    rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /home/admin/oceanbase-ce
    # 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
    zone: zone1
  obce02:
    mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
    rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /home/admin/oceanbase-ce
    # 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
    zone: zone2
  obce03:
    mysql_port: 2881 # External port for OceanBase Database. The default value is 2881.
    rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882.
    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
    home_path: /home/admin/oceanbase-ce
    # 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
    zone: zone3
obproxy:
  servers:
    - 172.20.249.53
    - 172.20.249.55
    - 172.20.249.56
  # Set dependent components for the component.
  # When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
  depends:
    - oceanbase-ce
  global:
    listen_port: 2883 # External port. The default value is 2883.
    prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
    home_path: /home/admin/obproxy
    # oceanbase root server list
    # format: ip:mysql_port;ip:mysql_port
    rs_list: 172.20.249.53:2881;172.20.249.55:2881;172.20.249.56:2881
    enable_cluster_checkout: false
    # observer cluster name, consistent with oceanbase-ce's appname
    cluster_name: obce-3zones
    obproxy_sys_password: FAKEPASSWORD01 # obproxy sys user password, can be empty
    observer_sys_password: FAKEPASSWORD02 # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty

上面是配置文件,使用 OBD 部署方法跟前面单节点集群部署方法一样。

当 OBPROXY 安装成功后,数据库连接方式就如下。OceanBase 数据库连接方法请查看公众号以前的文章或官网文档等。

obclient -h172.20.249.54 -uroot@obmysql#obce-3zones -P2883 -p123456 -c -A test

欢迎广大 OceanBase 爱好者、用户和客户有任何问题联系我们反馈:

社区版官网论坛:

open.oceanbase.com/answer

社区版项目网站:

github.com/oceanbase/oceanbase/issues

欢迎持续关注 OceanBase 技术社区,我们将不断输出技术干货内容,与千万技术人共同成长!!!

搜索🔍钉钉群(33254054),或扫描下方二维码,还可进入 OceanBase 技术答疑群,有任何技术问题在里面都能找到答案哦~

一文读懂 | 如何快速部署 OceanBase 开源版-8

相关文章

pt-kill工具的使用
pt-ioprofile工具包的使用
数据库管理-第216期 Oracle的高可用-01(20240703)
DBMS_REPAIR EXAMPLE SCRIPT WITH PARTITION
数据库事务的四大特性: ACID 
使用BBED修复损坏的SYSTEM文件头

发布评论