检查内存和安装目录

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 执行以下命令,检查内存是否在 64G及以上。

    1. free -g
    1. 检查磁盘,确认 /data/1、/data/log1、/home这3个目录已完成挂载。

    注意

    推荐 /data/1 和 /data/log1 目录为空。

    命令及执行结果如下所示。

    1. #df -lhT
    2. 文件系统 类型 容量 已用 可用 已用% 挂载点
    3. /dev/mapper/rhel-home ext4 103G 5.2G 92G 6% /home
    4. /dev/mapper/rhel-data ext4 99G 92G 1.8G 99% /data/1
    5. /dev/mapper/rhel-log ext4 296G 706M 280G 1% /data/log1

    安装依赖软件包

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 在 4 台物理机上安装 jdk,版本要求为 jdk-8u及以上版本。

    如果需要下载Oracle JDK,请单击下载 Oracle JDK

    1. 在 4 台物理机上安装以下依赖软件:
    • lsof.x86_64

    • mariadb.x86_64

    • mariadb-libs.x86_64

    • mariadb-devel.x86_64

    • net-tools.x86_64

    • ntp.x86_64

    • ntpdate.x86_64

    • python.x86_64:python2.7及以上版本

    • python-devel.x86_64

    • python-setuptools-0.9.8-4.el7.noarch

    • rsync.x86_64

    1. 再执行命令,依次确认4 台物理机是否已安装好如下所示版本的依赖包,如果未安装则需要进行安装。
    • expat-2.1.0-8.el7.x86_64

    • expect-5.45-14.el7_1.x86_64

    • gcc-4.8.5-4.el7.x86_64

    • gcc-c++-4.8.5-4.el7.x86_64

    • glibc-2.17-105.el7.x86_64

    • libgcc-4.8.5-4.el7.x86_64

    • libaio-0.3.107-10.el6.x86_64

    • libcurl-7.29.0-25.el7.centos.x86_64

    • openssl-libs-1.0.1e-42.el7.9.x86_64

    • openldap-2.4.40-8.el7.x86_64

    检查依赖包是否已安装的命令示例如下:

    1. rpm -qa | grep libaio

    检查网卡名称和 IP

    在启动 OBServer 服务时,需要通过 -i 参数指定网卡,由于服务器有可能有多个网卡以及多个IP,且OBServer 之间通信依赖指定的网卡和 IP,故在启动 OBServer 服务前,需要查看网卡名称,确保存在有效的网卡。

    1. 以 root 用户登录 OceanBase 服务器。

    2. 在服务器上安装 net-tools 依赖包。

    3. 执行ifconfig 命令查看网卡名称。

    以RedHat7 为例,RedHat7系统的检查结果如下所示。

    1. #ifconfig
    2. em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    3. inet 10.244.0.114 netmask 255.255.255.0 broadcast 10.244.0.255
    4. inet6 fe80::92b1:1cff:fe54:175b prefixlen 64 scopeid 0x20<link>
    5. ether 90:b1:1c:54:17:5b txqueuelen 1000 (Ethernet)
    6. RX packets 67497815 bytes 49457045875 (46.0 GiB)
    7. RX errors 0 dropped 0 overruns 0 frame 0
    8. TX packets 50226795 bytes 22163777758 (20.6 GiB)
    9. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    10. device interrupt 55
    11. ……

    以CentOS7 为例,CentOS7系统的检查结果如下所示。

    1. # ifconfig
    2. eno1:flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    3. inet 10.244.13.174 netmask 255.255.252.0 broadcast 10.244.15.255
    4. inet6 fe80::da9d:67ff:fe25:c8d4 prefixlen 64scopeid 0x20<link>
    5. ether d8:9d:67:25:c8:d4 txqueuelen 1000 (Ethernet)
    6. RX packets 544798343 bytes 130031250102 (121.1 GiB)
    7. RX errors 0 dropped 0overruns 0 frame 0
    8. TX packets 919939555 bytes 201056795407 (187.2 GiB)
    9. TX errors 0 dropped 0 overruns 0 carrier 0collisions 0
    10. device interrupt 51
    11. ……

    配置 sysctl.conf 文件

    为保证 OceanBase 的正常运行,请在安装 OceanBase 前修改所有物理机的 sysctl.conf 配置,以便提高 Linux 的系统性能。

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 使用 vi 编辑器,在 /etc/sysctl.conf 文件的末尾添加以下内容。

    1. # for oceanbase
    2. net.core.somaxconn = 2048
    3. net.core.netdev_max_backlog = 10000
    4. net.core.rmem_default = 16777216
    5. net.core.wmem_default = 16777216
    6. net.core.rmem_max = 16777216
    7. net.core.wmem_max = 16777216
    8. net.ipv4.ip_local_port_range = 3500 65535
    9. net.ipv4.ip_forward = 0
    10. net.ipv4.conf.default.rp_filter = 1
    11. net.ipv4.conf.default.accept_source_route = 0
    12. net.ipv4.tcp_syncookies = 0
    13. net.ipv4.tcp_rmem = 4096 87380 16777216
    14. net.ipv4.tcp_wmem = 4096 65536 16777216
    15. net.ipv4.tcp_max_syn_backlog = 16384
    16. net.ipv4.tcp_fin_timeout = 15
    17. net.ipv4.tcp_max_syn_backlog = 16384
    18. net.ipv4.tcp_tw_reuse = 1
    19. net.ipv4.tcp_tw_recycle = 1
    20. net.ipv4.tcp_slow_start_after_idle=0
    21. vm.swappiness = 0
    22. kernel.core_pattern = /data/1/core-%e-%p-%t
    23. vm.min_free_kbytes = 2097152
    1. 执行以下命令,使配置生效。
    1. /sbin/sysctl -p /etc/sysctl.conf

    配置 /etc/security/limits.conf 文件

    ulimit 主要用于限制 shell 启动进程所占用的资源。当前有两种方法可以修改资源限制:

    • 一种是通过启动时由 session 级别指定

    • 一种是通过修改 /etc/security/limits.conf 配置文件,全局生效

    OBServer 进程涉及的几个限制主要包括线程最大栈空间大小(stack)、最大文件句柄数(open files)和core文件大小(core file size)。

    如下在启动 OBServer 进程时,session 级别设置最大栈空间大小为 unlimited,最大文件句柄数为 655350,core文件大小为 unlimited。

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 使用 vi 编辑器,在/etc/security/limits.conf 文件末尾添加以下内容。

    1. $vi /etc/security/limits.conf 添加
    2. *  soft  nofile  655350
    3. *  hard  nofile  655350
    4. *  soft  stack 20480
    5. *  hard  stack 20480
    6. * soft nproc 655360
    7. * hard nproc 655360
    8. *  soft  core unlimited
    9. *  hard  core unlimited
    1. 退出当前 session,重新登录。

    2. 检查配置是否生效。

    1. ulimit -a # 执行该命令,资源限制详情如下
    2. core file size (blocks, -c) 0
    3. data seg size (kbytes, -d)
    4. unlimitedscheduling priority (-e) 0
    5. file size (blocks, -f) unlimited
    6. pending signals (-i) 772861
    7. max locked memory (kbytes, -l) 64
    8. max memory size (kbytes, -m) unlimited
    9. open files (-n) 1024
    10. pipe size (512 bytes, -p) 8
    11. POSIX message queues (bytes, -q) 819200
    12. real-time priority (-r) 0
    13. stack size (kbytes, -s) 8192
    14. cpu time (seconds, -t) unlimited
    15. max user processes (-u) 655360
    16. virtual memory (kbytes, -v) unlimited
    17. file locks (-x) unlimited

    修改内核异步 I/O 限制

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 执行以下命令,修改内核异步 I/O 限制。

    1. echo 65536 > /proc/sys/fs/aio-max-nr

    关闭防火墙和 SELinux

    1. 以 root 用户登录 OCP 和各 OceanBase 服务器。

    2. 依次执行以下命令,关闭 firewalld。

    1. systemctl disable firewalld
    2. systemctl stop firewalld
    3. systemctl status firewalld
    1. 修改 /etc/selinux/config 配置文件,将 SELINUX=enforcing 修改为 SELINUX=disabled
    1. vi /etc/selinux/config
    1. 执行以下命令,关闭 SELinux 。
    1. setenforce 0

    验证NTP时钟同步

    OceanBase集群中各服务器的时间需保持一致,否则会导致OceanBase集群无法启动,运行时也会出现故障。

    说明

    说明:若NTP时钟已经处于同步状态,请跳过本小节。

    1. 检查NTP时钟是否同步。

    物理机与时钟服务器的误差在 50ms 以下则可认为时钟是同步状态。

    1. #ntpq -4p
    2. remote refid st t when poll reach delay offset jitter
    3. ==============================================================================
    4. *time6.aliyun.co 10.137.38.86 2 u 712 1024 377 21.951 4.253 4.208
    1. 开启 NTP Server 服务。

    如果已经存在 NTP Server 服务器,则可跳过本小节。否则,请选择一台待部署 OCP 的物理机,本文档中以 IP 为10.244.0.114 的机器作为 NTP Server 服务器为例,开启 NTP Server服务。

    开启NTP Server服务操作步骤如下:

    1. 以 root 用户登录 NTP Server 服务器。

    2. 使用 vi 编辑器,修改 /etc/ntp.conf 文件, 内容格式如下所示。

    1. server 127.127.1.0

    c. 执行以下命令,重启 NTPServer 服务。

    1. service ntpd restart

    d. 执行以下命令,查看是否成功启动 NTPServer 服务。

    1. ps -ef |grep -i ntpd

    e. 执行以下命令,设置 NTP 服务开机自启动。

    1. chkconfig ntpd on
    1. 开启 NTP Client 服务。NTP Server服务启动后,请等待 5分钟再开启 NTP Client 服务,否则会提示“no server suitable for synchronization found”的错误。

    以 NTP Server 服务器 IP 为 10.244.0.114为例,所有 OceanBase 服务器开启 NTP Client 服务操作步骤如下:

    1. 以 root 用户登录 OceanBase 服务器。

    2. 执行以下命令,停止 NTP 服务。

    1. service ntpd stop

    c. 执行以下命令,即时同步 NTP Server 时间。

    1. ntpdate 10.244.0.114

    d. 使用vi编辑器,修改 /etc/ntp.conf 文件,修改结果如下所示。

    1. server 10.244.0.114

    e. 执行以下命令,启动 NTP 服务。

    1. /etc/init.d/ntpd start

    创建安装用户

    1. 执行以下命令,创建 OceanBase 的安装用户 admin。
    1. groupadd admin
    2. useradd -d /home/admin -s /bin/bash -m admin
    3. sudo chown -R admin:admin /home/admin
    1. 设置密码。
    1. passwd admin
    1. (可选)将 admin 用户的权限打通。若通过 OCP 运维平台部署 OceanBase 集群,则本步骤可忽略。

    以 admin 用户登录并在主控机上执行如下命令:

    1. ssh-keygen -t rsa # 在主控机执行该命令,多次回车即可
    2. cat id_rsa.pub >> ~/.ssh/authorized_keys
    3. chmod 644 authorized_keys
    4. scp -r ~/.ssh dest_ip:~/ # dest_ip依次为其他3台物理机
    1. (可选)目录权限设置与检查。若通过 OCP 运维平台部署 OceanBase 集群,则本步骤可忽略。检查admin 用户对 /data/1、 /data/log1目录是否有写权限。
    1. #ls –al
    2. drwxr-xr-x 2 admin admin 4096 2 9 18:43 1
    3. drwxr-xr-x 2 admin admin 4096 2 9 18:43 log1

    若 admin 用户无权限,则以 root 用户登录机器并执行以下命令:

    1. chown -R admin:admin /data/1
    2. chown -R admin:admin /data/log1