一、参考链接

阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区

oceanbase镜像-oceanbase下载地址-oceanbase装置教程-阿里巴巴开源镜像站

OceanBase 社区版

obdeploy: A deployer and package manager for OceanBase open-source software

二、OceanBase介绍

OceanBase是由蚂蚁团体齐全自主研发的金融级分布式关系数据库,始创于2010年。OceanBase具备数据强统一、高可用、高性能、在线扩大、高度兼容SQL规范和支流关系数据库、低成本等特点。

OceanBase 社区版是一款开源分布式 HTAP(Hybrid Transactional/Analytical Processing)数据库管理系统,具备原生分布式架构,反对金融级高可用、通明程度扩大、分布式事务、多租户和语法兼容等企业级个性。OceanBase 内核通过大规模商用场景的考验,已服务泛滥行业客户,现面向未来继续构建内核技术竞争力。

三、OceanBase安装操作

本试验基于CentOS 7.9零碎进行演示操作

[root@oceanbase ~]# cat /etc/redhat-releaseCentOS Linux release 7.9.2009 (Core)

装置后期筹备

本试验采纳<font color=red>单机模式</font> 的部署形式,在同一台机器上装置服务端和客户端进行测试。

须要内存大小<font color=red>8GB </font>以上;(本试验内存大小 10 GB)

磁盘空间大小<font color=red>65GB</font>以上;(本试验磁盘大小 95 GB)

参考链接

【PostgreSQL】基于CentOS零碎装置PostgreSQL数据库_xyb的博客-CSDN博客

OceanBase 社区版

1、通过 YUM 软件源下载并装置 OBD

执行以下三种命令。

# yum install -y yum-utils# yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo# yum install -y ob-deploy
[root@obd ~]# yum install -y yum-utilsLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfilePackage yum-utils-1.1.31-54.el7_8.noarch already installed and latest versionNothing to do[root@obd ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repoLoaded plugins: fastestmirroradding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repograbbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.reporepo saved to /etc/yum.repos.d/OceanBase.repo[root@obd ~]# yum install -y ob-deployLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfilePackage ob-deploy-1.2.1-9.el7.x86_64 already installed and latest versionNothing to do[root@obd ~]#

或者

离线装置 OBD1. 下载 OBD 离线 RPM 安装包。2. 运行以下命令装置 OBD。# yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm# source /etc/profile.d/obd.sh

2、下载 OceanBase 数据库配置文件模板

从 Github 上下载对应的配置文件模板。本试验采纳的是<font color=red>mini-local-example.yaml</font> 配置文件

Gitee下载链接:

example/mini-local-example.yaml · OceanBase/obdeploy - Gitee.com

oceanbase-ce:  servers:    # Please don't use hostname, only IP can be supported    - 127.0.0.1  global:    #  The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.    home_path: /xyb/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    # 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: lo    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.    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: 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    sys_bkgd_migration_retry_num: 3    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.    # root_password: # root user password, can be empty

3、部署 OceanBase 数据库

运行以下命令部署集群
obd cluster deploy <deploy_name> -c <deploy_config_file> -A
[root@obs ~]# obd cluster deploy xybobs -c mini-local-example.yamlUpdate OceanBase-community-stable-el7 okUpdate OceanBase-development-kit-el7 okDownload oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm (46.45 M): 100% [##############] Time: 0:00:08   5.74 MB/sPackage oceanbase-ce-3.1.2 is available.install oceanbase-ce-3.1.2 for local ok+-------------------------------------------------------------------------------------------+|                                          Packages                                         |+--------------+---------+-----------------------+------------------------------------------+| Repository   | Version | Release               | Md5                                      |+--------------+---------+-----------------------+------------------------------------------+| oceanbase-ce | 3.1.2   | 10000392021123010.el7 | 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed |+--------------+---------+-----------------------+------------------------------------------+Repository integrity check okParameter check okOpen ssh connection okRemote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository install okRemote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository lib check !![WARN] 127.0.0.1 oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed require: libmariadb.so.3Try to get lib-repositoryDownload oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm (155.22 K): 100% [########] Time: 0:00:00   6.76 MB/sPackage oceanbase-ce-libs-3.1.2 is available.install oceanbase-ce-libs-3.1.2 for local okUse oceanbase-ce-libs-3.1.2-94fff0ab31de053051dba66039e3185fa390cad5 for oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aedRemote oceanbase-ce-libs-3.1.2-94fff0ab31de053051dba66039e3185fa390cad5 repository install okRemote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository lib check okCluster status check okInitializes observer work home okxybobs deployed[root@obs ~]# 

4、启动 OceanBase 数据库

[root@obs ~]# obd cluster start xybobsGet local repositories and plugins okOpen ssh connection okLoad cluster param plugin okCheck before start observer ok[WARN] (127.0.0.1) clog and data use the same disk (/)Start 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.2   | 2881 | zone1 | active |+-----------+---------+------+-------+--------+xybobs running[root@obs ~]#

5、连贯OceanBase数据库

装置OceanBase数据库客户端 OBClient
# yum install -y obclient
[root@obs ~]# yum install -y obclientLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package obclient.x86_64 0:2.0.0-2.el7 will be installed--> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.0-2.el7.x86_64--> Running transaction check---> Package libobclient.x86_64 0:2.0.0-2.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved====================================================================================================================================== Package                      Arch                    Version                       Repository                                   Size======================================================================================================================================Installing: obclient                     x86_64                  2.0.0-2.el7                   oceanbase.community.stable                   40 MInstalling for dependencies: libobclient                  x86_64                  2.0.0-2.el7                   oceanbase.community.stable                  643 kTransaction Summary======================================================================================================================================Install  1 Package (+1 Dependent package)Total download size: 41 MInstalled size: 188 MDownloading packages:(1/2): libobclient-2.0.0-2.el7.x86_64.rpm                                                                      | 643 kB  00:00:00(2/2): obclient-2.0.0-2.el7.x86_64.rpm                                                                         |  40 MB  00:00:06--------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                 6.6 MB/s |  41 MB  00:00:06Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : libobclient-2.0.0-2.el7.x86_64                                                                                     1/2  Installing : obclient-2.0.0-2.el7.x86_64                                                                                        2/2  Verifying  : libobclient-2.0.0-2.el7.x86_64                                                                                     1/2  Verifying  : obclient-2.0.0-2.el7.x86_64                                                                                        2/2Installed:  obclient.x86_64 0:2.0.0-2.el7Dependency Installed:  libobclient.x86_64 0:2.0.0-2.el7Complete![root@obs ~]#
应用Root用户登录 OceanBase 数据库
[root@obs ~]# obclient -h192.168.200.88 -P2881 -urootWelcome to the OceanBase.  Commands end with ; or \g.Your MySQL connection id is 3221487658Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47: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)]> show databases;+--------------------+| Database           |+--------------------+| oceanbase          || information_schema || mysql              || SYS                || LBACSYS            || ORAAUDITOR         || test               |+--------------------+7 rows in set (0.007 sec)MySQL [(none)]> exitBye
切换应用obs用户登录 OceanBase 数据库
[root@obs ~]# su obs[obs@obs root]$ obclient -h192.168.200.88 -P2881 -urootWelcome to the OceanBase.  Commands end with ; or \g.Your MySQL connection id is 3221487837Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47: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)]> show databases;+--------------------+| Database           |+--------------------+| oceanbase          || information_schema || mysql              || SYS                || LBACSYS            || ORAAUDITOR         || test               |+--------------------+7 rows in set (0.002 sec)MySQL [(none)]>

6、OceanBase 数据库 常用命令

# obs帮忙命令[root@obs ~]# obd -hUsage: 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治理的集群列表[root@obs ~]# obd cluster list+------------------------------------------------------+|                     Cluster List                     |+--------+---------------------------+-----------------+| Name   | Configuration Path        | Status (Cached) |+--------+---------------------------+-----------------+| xybobs | /root/.obd/cluster/xybobs | running         |+--------+---------------------------+-----------------+# 查看集群状态[root@obs ~]# obd cluster display xybobsGet local repositories and plugins okOpen ssh connection okCluster status check okConnect to observer okWait for observer init ok+---------------------------------------------+|                   observer                  |+-----------+---------+------+-------+--------+| ip        | version | port | zone  | status |+-----------+---------+------+-------+--------+| 127.0.0.1 | 3.1.2   | 2881 | zone1 | active |+-----------+---------+------+-------+--------+

四、装置过程中的报错信息

磁盘空间有余,至多所需65G磁盘空间大小。
[root@obs ~]# vim mini-local-example.yaml [root@obs ~]# obd cluster autodeploy xyb -c mini-local-example.yamlUpdate OceanBase-community-stable-el7 okUpdate OceanBase-development-kit-el7 okDownload oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm (46.45 M): 100% [####] Time: 0:00:06   7.88 MB/sPackage oceanbase-ce-3.1.2 is available.install oceanbase-ce-3.1.2 for local okCluster param config check okOpen ssh connection okGenerate observer configuration x[ERROR] (127.0.0.1) / not enough disk space. (Avail: 14.9G, Need: 64.1G). Use `redo_dir` to set other disk for clog
网卡名称谬误❌,本机装置应用的IP是127.0.0.1,对应的网络名称是lo。销毁集群后重新部署。
[root@obs ~]# obd cluster start xybobsGet local repositories and plugins okOpen ssh connection okLoad cluster param plugin okCheck before start observer x[WARN] (127.0.0.1) clog and data use the same disk (/)[ERROR] 127.0.0.1 ens32 fail to ping 127.0.0.1. Please check configuration `devname`[root@obs ~]#
提醒所需的零碎内存不足,须要晋升内存大小。(举荐内存大小在16GB以上)
[root@obs ~]# obd cluster start xybobsGet local repositories and plugins okOpen ssh connection okLoad cluster param plugin okCheck before start observer x[ERROR] (127.0.0.1) not enough memory. (Free: 7.3G, Need: 8.0G)[WARN] (127.0.0.1) clog and data use the same disk (/)[root@obs ~]#