OceanBase 部署环境及部署集群详细步骤
一、安装准备及环境
0.软硬件配置
OceanBase 数据库 3.1.0 版本在以下配置进行了系统性测试验证,推荐您使用以下软硬件配置:
项目 | 描述 |
---|---|
系统 | Anolis OS 8.X 版本(内核 Linux 3.10.0 版本及以上)-- 推荐Red Hat Enterprise Linux Server 7.X 版本、8.X 版本(内核 Linux 3.10.0 版本及以上) -- 推荐CentOS Linux 7.X 版本、8.X 版本(内核 Linux 3.10.0 版本及以上) -- 推荐Debian 9.X 版本及以上版本 (内核 Linux 3.10.0 版本及以上)Ubuntu 20.X 版本及以上版本(内核 Linux 3.10.0 版本及以上) |
CPU | 企业用户最低要求 16 核,推荐 32 核及以上个人用户最低要求 2 核, 推荐 8 核及以上 |
内存 | 企业用户最低要求 64G,推荐 256G 及以上个人用户户最低要求 8G, 推荐 64G 及以上 |
磁盘类型 | 推荐使用 SSD |
磁盘存储空间 | 内存大小的 4 倍及以上 |
文件系统 | EXT4 戓 XFS,当数据超过 16T 时,使用 XFS |
网卡 | 千兆互联及以上 |
更多软硬件平台适配正在测试中。
说明
如果您部署 OceanBase 集群,确保集群内的所有机器配置相同。
对于 CentOS 或 Red Hat 操作系统,需要运行以下命令,手动关闭透明大页:
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
1.查看内核
运行以下命令,查看内核信息:
uname -r
OceanBase 数据库要求操作系统为 3.10.0 及以上。
2.查看内存
运行以下命令,查看内存:
free -g
如果可用内存小于配置文件中的 memory_limit
值,请清理缓存或者修改配置 memory_limit
,将 memory_limit
修改为小于可以内存的值。
执行以下命令,清理缓存:
echo 3 > /proc/sys/vm/drop_caches
3.查看磁盘
运行以下命令,查看磁盘:
df -h
确保配置文件中的 data_dir
、redo_dir
和 home_path
对应的磁盘已经完成挂载。data_dir
和 redo_dir
对应目录为空,data_dir
对应目录的磁盘已经使用率必须低于 4%。
4.查看网卡名称
您需要为配置文件中的 devname
配置项指定网卡。示例配置文件如下:
# 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
执行以下命令,查看网卡名称:
ifconfig
**注意**
要执行 `ifconfig` 命令,您必须安装 `net-tools`依赖。
二、环境配置
1.无密码SSH登录
介绍如何为集群内的多台机器设置无密码 SSH 登录。如果您在单机安装 OceanBase 数据库,则无需设置。
中控机器:
存储 OceanBase 数据库安装包和集群配置信息的机器。
目标机器:
安装 OceanBase 数据库的机器。
前提条件:
设置无密码 SSH 登录前,确保您拥有目标机器的 root 用户权限。
操作步骤
按以下步骤设置无密码 SSH 登录:
在中控机器上运行以下命令查看密钥是否存在:
ls ~/.ssh/id_rsa.pub
如果密钥已经存在,则无需生成新的密钥。
#1.(可选)在中控机器上运行以下命令生成 SSH 公钥和私钥:
ssh-keygen -t rsa
#2.在中控机器上运行以下命令将第一步生成的公钥上传至目标服务器的 .ssh 文件夹:
scp ~/.ssh/id_rsa.pub root@<server_ip>:~/.ssh/
#3.在目标机器上运行以下命令,将中控机器传入的公钥写到 authorized_keys:
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
#4.在中控机器上运行以下命令登录目标机器:
ssh root@<server_ip>
重复步骤,为每台机器设置无密码登录 SSH。
# !!注意
上述命令均仅需在中控机器上执行。
参考脚本(附录)
推荐您使用以下脚本,在集群中批量执行命令和复制文件。
使用以下脚本,批量复制文件。
#/usr/bin/bash
hosts=(
"ob001"
"ob002"
"ob003"
"obdriver"
)
for host in "{hosts[@]}"
do
echo "begin to scp "@ " on " host
scp -r1 host:2
done
使用以下脚本,批量执行命令。
/usr/bin/bash
hosts=(
"ob001"
"ob002"
"ob003"
"obdriver"
)
for host in "{hosts[@]}"
do
echo "begin to run "@ " on " host
sshhost $@
done
# !!注意
您必须将脚本中的 hosts 列表替换成您自己的实际机器列表。
2.时钟同步
如果您使用集群安装 OceanBase,则需要保证集群内各机器的时间同步。否则集群无法启动,服务在运行时也会出现异常。如果您已配置 NTP 时钟同步,则无需重新配置。
OceanBase 集群中的服务器时间必须保持一致,否则会导致 OceanBase 集群无法启动,运行时也会出现故障。物理机与时钟服务器的误差在 50ms 以下可认为时钟是同步状态,OceanBase 集群最大容忍误差不能超过 100ms。当超过 100ms 时,会出现无主情况。恢复时钟同步后。重启 OceanBase 集群, 可以恢复正常。
前提条件
配置 NTP 时钟源前,确保您拥有所有机器的 root 用户权限。
操作步骤
# 按以下步骤配置 NTP 时钟同步:
1.在每台机器上执行以下命令安装 NTP:
yum install ntp ntpdate -y
====================
2.运行以下命令查看服务器的 NTP 连接:
当物理机与时钟服务器的时间误差在 50ms 以内时,系统即认为时钟是同步的。
[root@centos-01 /root]#ntpq -4p
remote refid st t when poll reach delay offset jitter
--------------------
*time6.aliyun.co 10.137.38.86 2 u 712 1024 377 21.951 4.253 4.208
====================
3.(可选)开启 NTP 服务端服务
如果您已经有了 NTP 服务端服务器,则可跳过此步骤。本文档使用目标机器 10.244.0.114 作为 NTP 服务端服务器。
a.编辑配置文件。
以 root 用户登录 NTP 服务端服务器,运行以下命令编辑配置文件:
vi /etc/ntp.conf
在配置文件中添加以下内容:
server <yout_ntp_server_ip>
保存并关闭配置文件。
b.运行以下命令重启 NTP 服务端服务:
service ntpd restart
c.运行以下命令查看 NTP 服务端服务是否启动成功:
ps -ef | grep -i ntpd
d.运行以下命令设置 NTP 服务开机自启动:
chkconfig ntpd on
====================
4.开启 NTP 客户端服务。
# 注意!! #
NTP 服务端服务启动后,您需要等待 5 分钟再开启 NTP 客户端服务。否则系统会提示 “no server suitable for synchronization found”。
a.使用 root 用户登录 OceanBase 数据库。
b.运行以下命令停止 NTP 服务:
service ntpd stop
c.运行以下命令同步 NTP 服务端时间:
ntpdate 10.244.0.114
d.编辑配置文件。
运行以下命令打开配置文件:
vi /etc/ntp.conf
在配置文件中添加以下内容:
server <yout_ntp_server_ip>
e.运行以下命令,启动 NTP 服务:
/etc/init.d/ntpd start
====================
5.运行以下命令验证配置是否成功:
ntpstat
返回以下结果:
synchronised to NTP server (10.143.0.44) at stratum 3
time correct to within 2 ms
polling server every 64 s
timedatectl
返回以下结果:
Local time: Thu 2021-04-22 11:02:32 CST
Universal time: Thu 2021-04-22 03:02:32 UTC
RTC time: Thu 2021-04-22 11:02:32
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: n/a
# 说明 NTP 服务生效。
3.规划磁盘
OceanBase 数据库的服务器依赖数据盘、事务日志盘和 OceanBase 数据库的安装盘。本文介绍如何规划您的磁盘。如果您是个人用户, 您可以将所有数据放到一块盘上并跳过此步骤。如果您是企业用户,您必须将数据分别挂载至三块磁盘。
如果您的机器上没有三块磁盘,或者您使用的是 RAID 磁盘阵列, 您需要对磁盘或者磁盘阵列的逻辑卷进行分区。建议您采用以下方案分区:
- 数据盘
数据盘的配置参数为
data_dir
。数据盘用来存储基线数据。在您首次启动 OceanBase 数据库时,${data_dir}/sstable
将自动创建。数据盘的大小由datafile_disk_percentage
参数决定。datafile_disk_percentage
的默认值为95
。data_dir
创建后无法调整大小。您可以通过加减机器为 OceanBase 数据库进行扩容和缩容。目前,OceanBase 数据库不支持单机的磁盘级扩容和缩容。 -
事务日志盘
事务日志盘的配置参数为
redo_dir
。建议您将事务日志盘的大小设置为 OceanBase 数据库内存的 3 倍到 4 倍及以上。事务日志盘包含多个固定大小的文件。这些文件位于安装目录${redo_dir}/{clog,ilog,slog}
下。您可以根据您的需要自动创建和清除事务日志。事务日志达到磁盘总量的 80% 时,将触发自动清除。但是,只有事务日志对应的内存数据已经合并融至基线数据中时,事务日志才能被删除。在相同数据量的情况下,事务日志的大小约为内存数据大小的三倍。因此事务日志盘所需空间上限与两次合并后的数据总量成正比。经验公式:事务日志文件大小 = 增量数据内存上限的 3 到 4 倍。 -
OceanBase 数据库安装盘
OceanBase 数据库安装盘的配置参数为
home_path
。建议您为 OceanBase 数据库安装盘预留至少 200 G 空间,以保存 7 天及以上的日志。OceanBase 数据库的 RPM 包安装目录位于${home_path}
下。其中,基线数据文件和事务日志文件会通过软链接分别指向独立的数据盘和事务日志盘。OceanBase 数据库的运行日志位于${home_path}/log
下。运行日志会不断增长,并且 OceanBase 数据库无法自动删除运行日志。因此您需要定时删除运行日志。
磁盘划分后, 执行以下命令检查磁盘划分情况:
df -h
返回以下结果:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 31G 0 31G 0% /dev
tmpfs 31G 0 31G 0% /dev/shm
tmpfs 31G 516K 31G 1% /run
tmpfs 31G 0 31G 0% /sys/fs/cgroup
/dev/vda1 493G 171G 302G 37% /
tmpfs 6.2G 0 6.2G 0% /run/user/0
/dev/vdd1 984G 77M 934G 1% /data
/dev/vdc1 196G 61M 186G 1% /redo
/dev/vdb1 492G 73M 467G 1% /home/admin/oceanbase
其中,/data
为数据盘,大小为 1 TB。/redo
存放 redo 日志。/home/admin/oceanbase
存放 OceanBase 数据库的二进制文件和运行日志。
4. 配置 limits.conf
您可以通过配置 limits.conf
限制您的进程数量。如果您是个人用户,您可以跳过此步骤。如果您是企业用户,您必须配置 limits.conf
。
您可以使用以下两种方法修改资源限制:
- 通过启动时在会话级别修改。
- 通过配置文件
/etc/security/limits.conf
在全局级别修改。
OceanBase 数据库的进程涉及的限制包括线程最大栈空间大小(Stack)、最大文件句柄数(Open Files)和 core 文件大小 (Core File Size)。
更改配置
说明 : 您必须在每台机器上执行此操作。
将会话级别的最大栈空间大小设置为 unlimited
,最大文件句柄数设置为 655350
,Core 文件大小设置为 unlimited
。
执行以下命令,打开 /etc/security/limits.conf
配置文件:
vi /etc/security/limits.conf
在 /etc/security/limits.conf
配置文件中添加以下内容:
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft stack 20480
* hard stack 20480
* soft nproc 655360
* hard nproc 655360
* soft core unlimited
* hard core unlimited
退出当前会话,重新登录。执行以下命令,查看配置是否生效:
ulimit -a
5.配置 sysctl.conf
为保证 OceanBase 数据库正常运行,在安装 OceanBase 数据库之前,您需要修改所有机器的 sysctl.conf
配置,以提高 Linux 系统的性能。如果您是个人用户,您可以跳过此步骤。如果您是企业用户,您必须配置 sysctl.conf
。
说明 : 您必须在每台机器上执行此操作。
执行以下命令,打开 /etc/sysctl.conf
配置文件:
vi /etc/sysctl.conf
在 /etc/sysctl.conf
配置文件中添加以下内容:
# for oceanbase
## 修改内核异步 I/O 限制
fs.aio-max-nr=1048576
## 网络优化
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
# 此处为 OceanBase 数据库的 data 目录
kernel.core_pattern = /data/core-%e-%p-%t
其中,`kernel.core_pattern` 中的 `/data` 为 OceanBase 数据库的 `data` 目录。如果您只是测试,您可以只设置 `fs.aio-max-nr=1048576`。
更改配置完成后,执行以下命令,加载配置,使配置生效。
sysctl -p
6.关闭防火墙和 SELinux
依次执行以下命令,关闭防火墙:
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
执行以下命令关闭 SELinux,
1.打开 `/etc/selinux/linux` 配置文件:
vi /etc/selinux/linux
2.在 `/etc/selinux/linux` 配置文件中添加以下内容:
SELINUX=disabled
3.执行以下命令,使更改生效:
setenforce 0
4.执行以下命令,查看更改是否生效:
cat /etc/selinux/config
7.创建用户
如果您是个人用户,您可以直接使用 root 账号并跳过此步骤。如果您是企业用户,建议您在机器上创建普通用户,以确保安全。您可以根据实际需要,创建您的常用账户。
说明: 您必须在每台机器上执行此操作。
按照以下步骤创建用户。此处以创建 admin 用户为例进行说明。
- 执行以下命令,创建账户 admin。
useradd -U admin -d /home/admin -s /bin/bash mkdir -p /home/admin sudo chown -R admin:admin /home/admin
- 执行以下命令,为账户 admin 设置密码。
passwd admin
- (可选)为账户 admin 设置 sudo 权限。
执行以下命令,打开
/etc/sudoers
文件。在/etc/sudoers
文件添加以下内容:## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL admin ALL=(ALL) NOPASSWD: ALL
- 执行以下命令,查看目录权限。
ls –al
返回以下结果:
drwxr-xr-x 2 admin admin 4096 2 月 9 18:43 drwxr-xr-x 2 admin admin 4096 2 月 9 18:43 log1
若 admin 用户无权限,则以 root 用户执行以下命令:
chown -R admin:admin /data chown -R admin:admin /redo chown -R admin:admin /home/admin
此处填写您真实的挂载目录。此处
/data
、/redo
、/home/admin
为示例挂载目录。
三、详细安装及配置
1.安装 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 安装包。
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/ob-deploy-1.0.0-1.el7.x86_64.rpm
注意 示例中的安装包可能不是最新版本,建议您下载最新的安装包。详细信息,参考 OBD 发行版本。
运行以下命令,安装 OBD。
yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm
source /etc/profile.d/obd.sh
2.获取 OceanBase 数据库安装包
运行以下命令,下载 OceanBase 数据库安装包:
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-3.1.0-1.el7.x86_64.rpm
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/obproxy-3.1.0-1.el7.x86_64.rpm
注意 示例中的安装包可能不是最新版本,建议您下载最新的安装包。详细信息,参考 OceanBase 数据库发行版本。
3.设置本地镜像
运行以下命令,将 OceanBase 数据库安装包设置为本地镜像:
obd mirror clone oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm
obd mirror clone oceanbase-ce-3.1.0-1.el7.x86_64.rpm
obd mirror clone obproxy-3.1.0-1.el7.x86_64.rpm
4.下载并修改配置文件
从 GitHub 上下载对应的配置文件模板。
推荐配置文档
user:
username: root
password: 123
oceanbase-ce:
servers:
- 10.0.0.9
global:
home_path: /root/store
data_dir: /data
redo_dir: /redo
devname: eth0
mysql_port: 2881
rpc_port: 2882
zone: zone1
cluster_id: 1
memory_limit: 10G
system_memory: 2G
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
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
syslog_level: INFO
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
root_password: 123
obproxy:
depends:
- oceanbase-ce
servers:
- 10.0.0.9
global:
listen_port: 2883
prometheus_listen_port: 2884
home_path: /root/obproxy
enable_cluster_checkout: false
skip_proxy_sys_private_check: true # 跳过个人代理检验
auto_create_tenant: true # 自动创建租户
a.如果您采用本地安装,即中控机器和目标机器是同一台机器,请下载 本地安装配置文件。
## 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
- 192.168.1.3
global:
home_path: /root/observer
# data_dir: /data
# redo_dir: /redo
devname: eth0
mysql_port: 2881
rpc_port: 2882
zone: zone1
cluster_id: 1
memory_limit: 8G # The maximum running memory for an observer
system_memory: 4G
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
syslog_level: INFO
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
b.如果您采用单机安装,即中控机器和目标机器不是同一台机器,且目标机器只有一台,请下载 单机安装配置文件。
oceanbase-ce:
servers:
- 127.0.0.1
global:
home_path: /root/observer
devname: lo
mysql_port: 2881
rpc_port: 2882
zone: zone1
cluster_id: 1
memory_limit: 8G
system_memory: 4G
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
net_thread_count: 4
sys_bkgd_migration_retry_num: 3
minor_freeze_times: 10
enable_separate_sys_clog: 0
enable_merge_by_turn: FALSE
datafile_disk_percentage: 20
syslog_level: INFO
enable_syslog_wf: false
enable_syslog_recycle: true
max_syslog_file_count: 4
c.如果您采用分布式安装,即目标机器有多台,请下载 分布式安装配置文件。
## Only need to configure when remote login is required
user:
username: 用户名
password: 密码
#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:
- name: server1
# Please don't use hostname, only IP can be supported
ip: 192.168.99.77
- name: server2
ip: 192.168.99.115
- name: server3
ip: 192.168.99.158
global:
# 本地中控机器网卡名称
devname: enp1s0
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: 4G # 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.
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: 4 # 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: obcluster
# root_password: # root user password, can be empty
# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
server1:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /usr/local/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
zone: zone1
server2:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /usr/local/observer
# The directory for data storage. The default value ishome_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
server3:
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /usr/local/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
zone: zone3
obproxy:
# 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
servers:
- 192.168.99.77
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: /usr/local/obproxy
# oceanbase root server list
# format: ip:mysql_port;ip:mysql_port. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# rs_list: 192.168.1.2:2881;192.168.1.3:2881;192.168.1.4:2881
enable_cluster_checkout: false
# observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# cluster_name: obcluster
skip_proxy_sys_private_check: true
# obproxy_sys_password: # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
# observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
注意:如何修改配置文件。您必须按照您的安装方式选择对应的配置文件模板。
在配置文件顶部添加用户密码信息(服务器互通账户,非数据库账户):
其中,`username` 为登录到目标机器的用户名,确保您的用户名有 observer 进程工作目录 `home_path` 的权限。
**注意**:通常情况下,您只能使用登录密码或者私钥登录中的一种方式登录目标机器。
vim oceanbase.yaml # 新建编辑配置文件
=======================================================
# 修改用户名密码
user:
username: <您的账号名>
password: <您的登录密码>
#key_file: <您的私钥路径>
# 修改配置文件中的 IP 地址:
oceanbase-ce:
servers:
- name: z1
# Please don't use hostname, only IP can be supported
ip: 11.166.80.01
# 修改配置文件中的 `devname` 变量和 `home_path`。
oceanbase-ce:
global:
home_path: <your_observer_work_path>
# 修改网卡名称
devname: eth0
.......更多其他配置
5.自动安装并启动
1.) 运行以下命令部署集群:
obd cluster deploy <deploy_name> -c <deploy_config_path>
其中,参数 `deploy_name` 为部署配置名称,可以理解为配置文件名称,且部署配置名称不能重复。
#================================
1. 部署过程会自动安装OBP到中控机器以及OB数据库到各个目标机器,并自动验证和部署所有节点。
'注意部署ssh互通,设置网卡名这2个问题。'
2. home_path: /usr/local/observer
data_dir: /data
redo_dir: /redo
代理home_path: /usr/local/obproxy
'注意安装目录需要有权限,并且文件夹为空。'
#================================
'------------------------------------------------'
'------------------------------------------------'
# !!常用命令
'----------------'
obd cluster edit-config test1 #修改集群配置
obd cluster destroy test1 #删除存在集群
list #List all the deployments.
redeploy #Redeploy a started cluster.
reload #Reload a started cluster.
restart #Restart a started cluster.
start #Start a deployed cluster.
stop #Stop a started cluster.
tenant #Create or drop a tenant.
upgrade #升级 a cluster.
autodeploy #自动创建集群
deploy #创建集群
display #显示集群
2.)运行以下命令启动集群:
obd cluster start <deploy_name>
3.)运行以下命令查看集群状态:
obd cluster display <deploy_name>
4.)查看所有集群
obd cluster list
+------------------------------------------------------------------------+
| Cluster List |
+------------+-----------------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+------------+-----------------------------------------+-----------------+
| oceantest1 | /home/oceanbase/.obd/cluster/oceantest1 | running |
+------------+-----------------------------------------+-----------------+
5.)报错情况
安装之后执行启动和查询状态报错:
# 可以使用下面的第七步OBC方式验证是否成功,无法查询到集群。(权限问题,需要拥有安装集群的用户权限下才可以查看到。)
6.连接 OceanBase 数据库
1.)安装OBC
安装 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 的依赖包 LibOBClient。示例中的安装包可能不是最新版本,建议您下载最新的安装包。详细信息,参考 下载中心。
2.)连接OBC
运行以下命令,使用 OBClient 客户端连接 OceanBase 数据库:
obclient -u[用户名]@[租户名]#[集群名称] -P[端口号] -h[ip地址] -p[密码] -D[数据库名] -c
obclient -h<your_ip> -P<observer_mysql_port> -uroot
其中,`your_ip` 为您 OceanBase 实例所在的机器 IP 地址。`observer` 默认使用端口 `2881` 连接 OBClient。如果您对端口做了更改,此处使用您实际的端口号。
obclient -h 127.0.0.1 -P 2881 -uroot
返回以下信息:
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)]>
7.验证集群
连接 OceanBase 数据库,运行以下命令验证集群:
MySQL [oceanbase]> USE oceanbase;
MySQL [oceanbase]> SELECT * FROM __all_server;
返回以下结果:
以上返回结果说明集群部署成功。