对于一款软件而言,除了基础理论认知外,还需要进行工程实践,而安装不亚于万里长征的第一步,成功的安装,就初步摆脱了ppt层面,进入实战环节。
在使用oceanbase时,经常需要使用较少资源,快速搭建一个开发测试环境,本文以2C、8G虚拟机的较低配置,安装部署OceanBase社区版3.1。安装使用了rpm包,采用本地离线方式安装,即先将介质下载到本地,在无联网情况下进行安装,且中控机器(OBD)和目标机器(OceanBase-ce)是同一台机器。OceanBase安装运行以oceanbase用户执行、维护,安装目录/ob。

0. ENV
0.1 部署环境
使用vmware workstation虚拟机一台,安装CentOS7.7。
| 序号 | 项目 | 内容 | 官方建议 |
| 1 | CPU | 2C | CPU数量不低于2 |
| 2 | MEMOERY | 8G | 内存不低于16G |
| 3 | DISK | 200G(/ob) | N/A |
| 4 | IP | 192.168.80.20 | 可单机、分布式多种方式部署 |
| 5 | OS | CentOS7.7 | CentOS7.2/8.3 |
| 6 | oceanbase | 社区版3.1 | N/A |
| 7 | 部署方式 | 本机在线部署,中控机器和目标机器是同一台机器 |
0.2 软件介质清单
官网介质下载
https://www.oceanbase.com/softwareCenter/community
共5个rpm包,下载后上传至安装主机/soft目录。
OBD V1.0.0:OceanBase Database Deployer社区版部署工具
oceanbase-ce:OceanBase数据库社区版V3.1.0
OceanBase libs V3.1.0:oceanbase运行时所依赖的部分3方动态库
Obproxy V3.1.0:ob数据库专用的代理服务器
OBClient-交互式和批量处理查询工具
小插曲
[2021-06-27]官方提供的OBClient离线包为libobclient-2.0.0-1.el7.x86_64.rpm,该包为OBClient库文件,并不包含obclient,应同时提供OBClient软件包:obclient-2.0.0-1.el7.x86_64.rpm
OBClient离线包下载(可异机下载):
[root@oceanbase ~]# yum -y install yum-utils[root@oceanbase ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo[root@oceanbase ~]# yum install obclient --downloadonly --downloaddir=/soft[root@oceanbase ~]# ls -l soft/obclient-2.0.0-1.el7.x86_64.rpm-rw-r--r--. 1 root root 31573968 May 28 06:22 soft/obclient-2.0.0-1.el7.x86_64.rpm
0.3 yaml配置文件
在页面https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml,拷贝mini-local-example.yaml内容并保存为mini-local-example.yaml,上传至安装服务器/soft目录。
0.4 安装说明
以下操作如无特别说明,均以root用户执行。
1. 准备工作[root]
1.1 selinux关闭
#临时关闭setenforce 0getenforce#开机不启动selinux,需重启生效。已临时关闭,本次不需要重启生效。sed -i 's/=enforcing/=disabled/g' etc/selinux/config#查看配置已生效cat /etc/selinux/config
1.2 firewalld关闭
#关闭防火墙systemctl stop firewalld#开机不启动防火墙systemctl disable firewalld
1.3 修改主机名
#修改主机名为oceanbase,当前已生效,退出会话,再登录后显示新主机名hostnamectl set-hostname oceanbase
1.4 配置hosts
#主机名解析添加主机信息cat >> etc/hosts << HOST192.168.80.20 oceanbaseHOST#查看主机名信息cat etc/hosts
1.5 添加oceanbase用户
oceanbase安装和维护均由oceanbase用户操作。
#添加oceanbase用户useradd -u 1000 oceanbase#更改密码echo "Rundba.com_800" | passwd --stdin oceanbase#运行oceanbase可运行任何命令,不需要密码vi etc/sudoers #添加oceanbase一行内容## Same thing without a password# %wheel ALL=(ALL) NOPASSWD: ALLoceanbase ALL=(ALL) NOPASSWD: ALL
1.6 创建key认证-本机安装不需要
[root@oceanbase ~]# su - oceanbase[oceanbase@oceanbase ~]$ ssh-keygen -t rsa #两次回车[root@oceanbase ~]# ssh-copy-id 192.168.80.20 #传输私钥[oceanbase@oceanbase ~]$ ssh 192.168.80.20 date #登录验证Sat Jun 26 21:41:22 EDT 2021
1.7 安装目录准备
以root用户安装时,默认安装在/root/observer目录下,本文以oceanbase用户安装在/ob/observer目录下。
#查看安装目录大小[root@oceanbase ~]# df -Th /obFilesystem Type Size Used Avail Use% Mounted on/dev/mapper/vgob-lvob xfs 200G 33M 200G 1% ob#/ob属主、属组均为oceanbase[root@oceanbase ~]# ls -ld obdrwxr-xr-x. 2 oceanbase oceanbase 6 Jun 26 21:38 ob
1.8 sysctl.conf配置
#添加内容echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf#配置生效sysctl -p
1.9 打开文件数限制
#添加内容cat >> etc/security/limits.conf << LIMIT* soft nofile 655350* hard nofile 655350LIMIT#退出当前会话,重新登录,使配置生效。#检查open files当前值,应为655350,否则后续启动集群会报错ulimit -n
2. 下载并安装OBD[oceanbase用户]
获取OceanBase数据库最快的方式是使用数据库部署工具OceanBase Deployer(简称OBD),因此推荐您使用此方式体验OceanBase数据库。
2.1 在线安装安装OBD-本次采用离线方式,跳过该步骤
通过 YUM 软件源安装 OBD
如您的机器可以访问公网,并能够添加三方YUM软件源,您可以运行以下命令,使用 OceanBase 的官方软件源安装 OBD:
[oceanbase@oceanbase ~]$ sudo yum install -y yum-utils[oceanbase@oceanbase ~]$ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo[oceanbase@oceanbase ~]$ sudo yum install -y ob-deploy
2.2 离线安装OBD-本次采用方式
1) 检查OBD离线RPM安装包
[oceanbase@oceanbase ~]$ cd soft[oceanbase@oceanbase soft]$ ls ob-deploy-1.0.0-1.el7.x86_64.rpmob-deploy-1.0.0-1.el7.x86_64.rpm
2) 本机安装OBD
#oceanbase用户安装[oceanbase@oceanbase soft]$ sudo yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm#root用户使变量生效[root@oceanbase ~]# source etc/profile.d/obd.sh
3. 本地oceanbase镜像[oceanbase用户]
当前主机不能连接公网,将之前OceanBase数据库的rpm离线软件包镜像到本地。
3.1 检查离线包
[oceanbase@oceanbase soft]$ pwd/soft[oceanbase@oceanbase soft]$ ls -lrt *rpm #oceanbase-ce、obproxy、oceanbase-ce-libs等均已下载-rwxrwxrwx. 1 root root 422984 Jun 25 21:38 oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm-rwxrwxrwx. 1 root root 8074612 Jun 25 21:38 obproxy-3.1.0-1.el7.x86_64.rpm-rwxrwxrwx. 1 root root 658620 Jun 25 21:39 libobclient-2.0.0-1.el7.x86_64.rpm-rwxrwxrwx. 1 root root 46315968 Jun 25 21:39 oceanbase-ce-3.1.0-1.el7.x86_64.rpm-rwxrwxrwx. 1 root root 12887020 Jun 25 21:40 ob-deploy-1.0.0-1.el7.x86_64.rpm-rwxrwxrwx. 1 root root 31573968 Jun 27 13:21 obclient-2.0.0-1.el7.x86_64.rpm
3.2 将OceanBase数离线软件包加入本地镜像
在中控机器(192.168.80.20)运行以下命令,将OceanBase数据库的离线软件包加入本地镜像:
[oceanbase@oceanbase soft]$ pwd/soft[oceanbase@oceanbase soft]$ obd mirror clone *.rpmname: libobclientversion: 2.0.0release:1.el7arch: x86_64md5: e452cd99c900847967982004ea4cc916e6f26013add libobclient-2.0.0-1.el7.x86_64.rpm to local mirrorname: ob-deployversion: 1.0.0release:1.el7arch: x86_64md5: 3cf38c88852f09d81cb0a1e8add3feaac32edb0aadd ob-deploy-1.0.0-1.el7.x86_64.rpm to local mirrorname: obproxyversion: 3.1.0release:1.el7arch: x86_64md5: 0b17cf0459a3b53c5a2febb6572894d183154c64add obproxy-3.1.0-1.el7.x86_64.rpm to local mirrorname: oceanbase-ceversion: 3.1.0release:1.el7arch: x86_64md5: 56f57e9843e719d830ec03c206d914f4b3adc82badd oceanbase-ce-3.1.0-1.el7.x86_64.rpm to local mirrorname: oceanbase-ce-libsversion: 3.1.0release:1.el7arch: x86_64md5: b70d3839280f145a86af26811bbfcdfaeb645509add oceanbase-ce-libs-3.1.0-1.el7.x86_64.rpm to local mirror
4. yaml配置文件准备[oceanbase用户]
4.1 yaml说明
yaml是批量安装调用的内容,当前OceanBase提供3种类型配置文件,分别为mini-local-example.yaml、mini-single-example.yaml、mini-distributed-example.yaml。
本次采用本地安装,即中控机器和目标机器是同一台机器,下载本地安装配置文件:
进入页面,copy并下载mini-local-example.yaml(准备环节章节“0.3 yaml配置文件清单”已经下载,4.1章节不需要操作)
https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml
单机安装配置文件(本次未使用),下载页面:
https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-single-example.yaml
分布式安装配置文件(本次未使用),下载页面:
https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-distributed-example.yaml
4.2 修改配置文件
默认root用户安装可不做修改,本次将安装目录home_path由/root/observer更改为/ob/observer。
因以oceanbase用户安装,确保/ob目录存在,属主、属组均为oceanbase,observer安装目录不需要创建。
[oceanbase@oceanbase ~]$ vim soft/mini-local-example.yamloceanbase-ce:servers:# Please don't use hostname, only IP can be supported- 127.0.0.1global:home_path: /ob/observer# 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: lomysql_port: 2881rpc_port: 2882zone: zone1cluster_id: 1# please set memory limit to a suitable value which is matching resource.memory_limit: 8Gsystem_memory: 4Gstack_size: 512Kcpu_count: 16cache_wash_threshold: 1G__min_full_resource_pool_memory: 268435456workers_per_cpu_quota: 10schema_history_expire_time: 1d# The value of net_thread_count had better be same as cpu's core number.net_thread_count: 4sys_bkgd_migration_retry_num: 3minor_freeze_times: 10enable_separate_sys_clog: 0enable_merge_by_turn: FALSEdatafile_disk_percentage: 20syslog_level: INFOenable_syslog_recycle: truemax_syslog_file_count: 4
5. 安装部署oceanbase集群[oceanbase用户]
5.1 部署集群
obd cluster deploy <deploy_name> -c <deploy_config_path>
如:
在oceanbase用户下,部署名为rundba集群,使用配置文件/soft/mini-local-example.yaml
[oceanbase@oceanbase ~]$ obd cluster deploy rundba -c soft/mini-local-example.yamlUpdate OceanBase-community-stable-el7 x[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xmlUpdate OceanBase-development-kit-el7 x[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xmlPackage oceanbase-ce-3.1.0 is availableinstall oceanbase-ce-3.1.0 for local ok+-------------------------------------------------------------------+| Packages |+--------------+---------+------------------------------------------+| Repository | Version | Md5 |+--------------+---------+------------------------------------------+| oceanbase-ce | 3.1.0 | 56f57e9843e719d830ec03c206d914f4b3adc82b |+--------------+---------+------------------------------------------+Open ssh connection okRemote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install okRemote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check !![WARN] 127.0.0.1 oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b require: libmariadb.so.3Try to get lib-repositoryUpdate OceanBase-community-stable-el7 x[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xmlUpdate OceanBase-development-kit-el7 x[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-community-stable-el7/repomd.xml[ERROR] Failed to download http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64///repodata/repomd.xml to /home/oceanbase/.obd/mirror/remote/OceanBase-development-kit-el7/repomd.xmlPackage oceanbase-ce-libs-3.1.0 is availableinstall oceanbase-ce-libs-3.1.0 for local okUse oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 for oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82bRemote oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 repository install okRemote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok127.0.0.1 initializes cluster work homerundba deployed
说明:obd安装首先默认使用remote官方的镜像进行安装,当前主机未联网,故报上述ERROR,不能下载repomd.xml文件,然后OBD会尝试使用local镜像,当前部署集群成功。
建议官方添加参数,增加obd mirror delete选项,删除remote镜像路径,或者增加disable选项,禁用remote镜像路径,或者增加其它参数,优先使用本地mirror。
5.2 启动集群
obd cluster start <deploy_name>
如:
[oceanbase@oceanbase ~]$ obd cluster start rundbaGet local repositories and plugins ok[WARN] (127.0.0.1) not enough memoryStart observer okobserver program health check okConnect to observer okInitialize clusterCluster bootstrap okWait for observer init ok+---------------------------------------------+| observer |+-----------+---------+------+-------+--------+| ip | version | port | zone | status |+-----------+---------+------+-------+--------+| 127.0.0.1 | 3.1.0 | 2881 | zone1 | active |+-----------+---------+------+-------+--------+rundba running
注:WARN是当前主机仅8G内存,低于建议的最低配置16G,测试环境不影响使用。
5.3 OBD其它命令参考
#查看帮助obd -h#重新部署obd cluster redeploy rundba#销毁obd cluster destroy rundba#查看obd管理的集群列表obd cluster list#查看集群状态obd cluster display rundba
5.4 安装报错分析
如果安装报错,到安装目录(home_path配置的路径)的日志目录/ob/observer/log目录中查看各日志进一步分析。
6. 连接OceanBase数据库[oceanbase用户]
6.1 安装OceanBase数据库客户端 OBClient
1) 在线安装-本次不使用
如您的机器已添加OceanBase官方YUM源作为软件源,使用以下命令直接安装:
sudo yum install -y obclient
2) 离线安装-本次使用
前述已经下载了客户端离线包,分别安装OBClient库文件和软件包,采用本地安装:
[oceanbase@oceanbase ~]$ sudo yum -y install /soft/libobclient-2.0.0-1.el7.x86_64.rpm[oceanbase@oceanbase ~]$ sudo yum -y install /soft/obclient-2.0.0-1.el7.x86_64.rpm
6.2 连接数据库
运行以下命令,使用 OBClient 客户端连接 OceanBase 数据库:
obclient -h<your_ip> -P<observer_mysql_port> -uroot
如
[oceanbase@oceanbase ~]$ obclient -h192.168.80.20 -P2881 -urootWelcome to the OceanBase. Commands end with ; or \g.Your MySQL connection id is 3221488165Server version: 5.7.25 OceanBase 3.1.0 (r-) (Built May 30 2021 11:21:29)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)]>
6.3 查看数据库
ob命令兼容部分mysql,查看数据库:
MySQL [(none)]> show databases;+--------------------+| Database |+--------------------+| oceanbase || information_schema || mysql || SYS || LBACSYS || ORAAUDITOR || test |+--------------------+7 rows in set (0.006 sec)
7. 官方参考
https://open.oceanbase.com/quickStart




