暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

0060.O OceanBase社区版3.1低配置本地离线安装-工程系统实现

rundba 2021-06-28
2790

        对于一款软件而言,除了基础理论认知外,还需要进行工程实践,而安装不亚于万里长征的第一步,成功的安装,就初步摆脱了ppt层面,进入实战环节。

        在使用oceanbase时,经常需要使用较少资源,快速搭建一个开发测试环境,本文以2C、8G虚拟机的较低配置,安装部署OceanBase社区版3.1。安装使用了rpm包,采用本地离线方式安装,即先将介质下载到本地,在无联网情况下进行安装,且中控机器(OBD)和目标机器(OceanBase-ce)是同一台机器。OceanBase安装运行以oceanbase用户执行、维护,安装目录/ob。

0. ENV

0.1 部署环境

使用vmware workstation虚拟机一台,安装CentOS7.7。

序号项目内容官方建议
1CPU2CCPU数量不低于2
2MEMOERY8G内存不低于16G
3DISK200G(/ob) N/A
4IP192.168.80.20 可单机、分布式多种方式部署
5OSCentOS7.7CentOS7.2/8.3
6oceanbase社区版3.1N/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 0
      getenforce

      #开机不启动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 << HOST
            192.168.80.20 oceanbase
            HOST

            #查看主机名信息
            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: ALL
              oceanbase 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 /ob
                  Filesystem Type Size Used Avail Use% Mounted on
                  /dev/mapper/vgob-lvob xfs 200G 33M 200G 1% ob

                  #/ob属主、属组均为oceanbase
                  [root@oceanbase ~]# ls -ld ob
                  drwxr-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 655350
                      LIMIT

                      #退出当前会话,重新登录,使配置生效。

                      #检查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.rpm
                          ob-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 *.rpm
                                name: libobclient
                                version: 2.0.0
                                release:1.el7
                                arch: x86_64
                                md5: e452cd99c900847967982004ea4cc916e6f26013
                                add libobclient-2.0.0-1.el7.x86_64.rpm to local mirror
                                name: ob-deploy
                                version: 1.0.0
                                release:1.el7
                                arch: x86_64
                                md5: 3cf38c88852f09d81cb0a1e8add3feaac32edb0a
                                add ob-deploy-1.0.0-1.el7.x86_64.rpm to local mirror
                                name: obproxy
                                version: 3.1.0
                                release:1.el7
                                arch: x86_64
                                md5: 0b17cf0459a3b53c5a2febb6572894d183154c64
                                add obproxy-3.1.0-1.el7.x86_64.rpm to local mirror
                                name: oceanbase-ce
                                version: 3.1.0
                                release:1.el7
                                arch: x86_64
                                md5: 56f57e9843e719d830ec03c206d914f4b3adc82b
                                add oceanbase-ce-3.1.0-1.el7.x86_64.rpm to local mirror
                                name: oceanbase-ce-libs
                                version: 3.1.0
                                release:1.el7
                                arch: x86_64
                                md5: b70d3839280f145a86af26811bbfcdfaeb645509
                                add 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.yaml
                                  oceanbase-ce:
                                  servers:
                                  # Please don't use hostname, only IP can be supported
                                  - 127.0.0.1
                                  global:
                                  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: lo
                                  mysql_port: 2881
                                  rpc_port: 2882
                                  zone: zone1
                                  cluster_id: 1
                                  # please set memory limit to a suitable value which is matching resource.
                                  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
                                  # 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
                                  syslog_level: INFO
                                  enable_syslog_recycle: true
                                  max_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.yaml
                                      Update 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.xml

                                      Update 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.xml
                                      Package oceanbase-ce-3.1.0 is available
                                      install oceanbase-ce-3.1.0 for local ok
                                      +-------------------------------------------------------------------+
                                      | Packages |
                                      +--------------+---------+------------------------------------------+
                                      | Repository | Version | Md5 |
                                      +--------------+---------+------------------------------------------+
                                      | oceanbase-ce | 3.1.0 | 56f57e9843e719d830ec03c206d914f4b3adc82b |
                                      +--------------+---------+------------------------------------------+
                                      Open ssh connection ok
                                      Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository install ok
                                      Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check !!
                                      [WARN] 127.0.0.1 oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b require: libmariadb.so.3

                                      Try to get lib-repository
                                      Update 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.xml


                                      Update 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.xml
                                      Package oceanbase-ce-libs-3.1.0 is available
                                      install oceanbase-ce-libs-3.1.0 for local ok
                                      Use oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 for oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b
                                      Remote oceanbase-ce-libs-3.1.0-b70d3839280f145a86af26811bbfcdfaeb645509 repository install ok
                                      Remote oceanbase-ce-3.1.0-56f57e9843e719d830ec03c206d914f4b3adc82b repository lib check ok
                                      127.0.0.1 initializes cluster work home
                                      rundba 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 rundba
                                          Get local repositories and plugins ok
                                          [WARN] (127.0.0.1) not enough memory
                                          Start observer ok
                                          observer program health check ok
                                          Connect to observer ok
                                          Initialize cluster
                                          Cluster bootstrap ok
                                          Wait 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 -uroot
                                                    Welcome to the OceanBase. Commands end with ; or \g.
                                                    Your MySQL connection id is 3221488165
                                                    Server 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


                                                      文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                                      评论