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

OpenGauss 2.0企业级数据库部署与深度解析

IT那活儿 2024-07-25
185

点击上方“IT那活儿”公众号--专注于企业全栈运维技术分享,不管IT什么活儿,干就完了!!!


openguass安装流程


环境要求

软件环境要求及依赖要求:

环境准备:

系统版本
Centos7.6
og软件版本
2.0企业版
IP
192.168.100.50
omm_passwd
omm123
db_passwd
Huawei@123
om工具


系统参数检查

3.1 检查CPU核心数

[root@openguass01 ~]# cat /proc/cpuinfo | grep processor
processor : 0
processor : 1

3.2 检查内存大小

[root@openguass01 ~]#free -h
total used free shared buff/cache available
Mem: 3.7G 882M 1.9G 27M 956M 2.6G
Swap: 5.0G 0B 5.0G

3.3 检查系统版本

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

3.4 数据库版本下载

  • opengauss3.0.0企业版:openGauss-3.0.0-CentOS-64bit-all.tar.gz

    下载地址:https://opengauss.org/zh/download.html


初始化系统参数配置

4.1 修改hostsname 、hosts

[root@localhost ~]# hostnamectl set-hostname 1ge53
[root@localhost ~]# hostname 1ge53

[root@1ge53 ~]# echo "192.168.100.53 1ge53" >> /etc/hosts
cat /etc/hosts | grep 100

4.2 修改SELINUX

[root@1ge53 ~]# vim /etc/selinux/config
SELINUX=disabled
getenforce

精简。
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX=disabled
setenforce 0
getenforce

4.3 关闭防火墙

systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service

4.4 设置字符集参数

*要求英文系统
cat>> /etc/profile<<EOF
export LANG=en_US.UTF-8
EOF
source /etc/profile
cat /etc/profile | grep LANG
echo $LANG

4.5 设置时区和时间

将硬件时钟调整为与目前的系统时钟一致;
hwclock --systohc

4.6 关闭REmoveIPC(openEuler环境)

注:如果是openEuler环境在个数据库节点上关闭RemoveIPC。Centos默认关闭,可以跳过此步骤。
cat /usr/lib/systemd/system/systemd-logind.service
sed -i '/^RemoveIPC/d' /usr/lib/systemd/system/systemd-logind.service
echo "RemoveIPC=no" >> /etc/systemd/logind.conf
echo "RemoveIPC=no" >> /usr/lib/systemd/system/systemd-logind.service
systemctl daemon-reload
systemctl restart systemd-logind

检查是否生效:
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC

4.7 设置网卡MTU相同大小

步骤一:查看
ifconfig
步骤二:设置
  • 对于X86 千兆网卡MTU默认值是1500(推荐) ARM MTU值和万兆网卡推荐8192;
  • ifconfig 网卡名称 mtu 值。

4.8 设置root用户远程登陆

配置SSH服务(允许root登录,关闭Banner)。
修改Banner配置,去掉连接到系统时,系统提示的欢迎信息会干扰安装时远程操作的返回结果,影响安装正常执行。
允许root登录,关闭登录Banner,配置文件需要重启生效:
sed -i '/Banner/s/^/#/' /etc/ssh/sshd_config
sed -i '/PermitRootLogin/s/^/#/' /etc/ssh/sshd_config
echo -e "\n" >> /etc/ssh/sshd_config
echo "Banner none " >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

使用如下命令使设置生效:
systemctl restart sshd.service
检查:
cat /etc/ssh/sshd_config |grep -v ^#|grep -E 'PermitRootLogin|Banner'
结果:
Banner none
PermitRootLogin yes

4.9 设置操作系统参数

如果安装om工具会自动添加,否则手动添加:
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries2 = 12
net.ipv4.ip_local_reserved_ports = 15400-15407,20050-20057
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.sctp.sctp_mem = 94500000 915000000 927000000
net.sctp.sctp_rmem = 8192 250000 16777216
net.sctp.sctp_wmem = 8192 250000 16777216
kernel.sem = 250 6400000 1000 25600
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 193064
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.ipv4.tcp_fin_timeout = 60
EOF

4.10 performance

如果是openEuler的操作系统,执行如下命令打开performance.sh文件:
vi /etc/profile.d/performance.sh
用#注释sysctl -w vm.min_free_kbytes=112640 &> /dev/null,键入“ESC”键进入指令模式,执行**:wq**,保存并退出修改。

4.11 设置系统资源限制

echo "* soft stack 3072" >> /etc/security/limits.conf
echo "* hard stack 3072" >> /etc/security/limits.conf
echo "* soft nofile 1000000" >> /etc/security/limits.conf
echo "* hard nofile 1000000" >> /etc/security/limits.conf
echo "* soft nproc unlimited" >> /etc/security/limits.d/90-nproc.conf
tail -n 4 /etc/security/limits.conf
tail -n 1 /etc/security/limits.d/90-nproc.conf

4.12 关闭swap分区

临时关闭swap:
swapoff -a
free -h

4.13 关闭透明页

步骤一:查看是否关闭透明巨页
cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

如果输出结果为[always]表示透明巨页启用了。[never]表示透明巨页禁用。
grep -i HugePages_Total /proc/meminfo
如果HugePages_Total,返回0,也意味着透明巨页禁用了。
步骤二:永久关闭
sed -i 's/.*rhgb.*quiet/& numa=off transparent_hugepage=never/g' /etc/default/grub
cat /etc/default/grub | grep GRUB_CMDLINE_LINUX
生效
grub2-mkconfig -o /boot/grub2/grub.cfg

步骤三:临时关闭透明页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

4.14 依赖包安装

检查软件依赖的包:
rpm -qa libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel bzip2 python3  java-1.8.0-openjdk*
如果少,则安装或者全部安装:
yum install -y lksctp*
yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
yum install libaio-devel flex bison ncurses-devel glibc-devel patch   readline-devel redhat-lsb-core libnsl

再次检查:
rpm -qa libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel bzip2 python3  java-1.8.0-openjdk* libnsl

4.15 创建软件包目录

mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software

4.16 上传安装包到指定位置

本次介质openGauss-2.0.0-CentOS-64bit-all.tar.gz。

4.17 创建用户

安装om工具会自动创建,否则手动添加:
groupadd dbgrp
useradd -g dbgrp -d /home/omm -m -s /bin/bash omm

4.18 重启

有条件可以重启下。


安装过程

5.1 解压缩

在安装包所在的目录下,解压安装包openGauss-x.x.x-openEuler-64bit-all.tar.gz。
装包解压后,会有OM安装包和Server安装包。继续解压OM安装包,会在/opt/software/openGauss路径下自动生成script子目录,并且在script目录下生成gs_preinstall等各种OM工具脚本。
步骤一:先解压all.tar.gz
tar -zxvf openGauss-2.0.0-CentOS-64bit-all.tar.gz
[root@1ge53 openGauss]# ll
total 198980
-rw-r--r--. 1 root root 101382908 Nov  3 17:39 openGauss-2.0.0-CentOS-64bit-all.tar.gz
-rw-r--r--. 1 root root        65 Mar 31 2021 openGauss-2.0.0-CentOS-64bit-om.sha256
-rw-r--r--. 1 root root  12646330 Mar 31 2021 openGauss-2.0.0-CentOS-64bit-om.tar.gz
-rw-r--r--. 1 root root        65 Mar 31 2021 openGauss-2.0.0-CentOS-64bit.sha256
-rw-r--r--. 1 root root  89573052 Mar 31 2021 openGauss-2.0.0-CentOS-64bit.tar.bz2
-rw-------. 1 root root        65 Mar 31 2021 upgrade_sql.sha256
-rw-------. 1 root root    133704 Mar 31 2021 upgrade_sql.tar.gz

步骤二:再解压om.tar.gz
tar -zxvf openGauss-2.0.0-CentOS-64bit-om.tar.gz

5.2 创建 XML 配置文件

相当于Oracle的静默安装,模板文件是script/gspylib/etc/conf/cluster_config_template.xml

单实例配置文件参考:

vi /opt/software/openGauss/cluster_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="1geCluster" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="1ge53" />
        <!-- 数据库安装目录-->
        <PARAM name="gaussdbAppPath" value="/opt/app/install/app" />
        <!-- 日志目录-->
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <!-- 临时文件目录-->
        <PARAM name="tmpMppdbPath" value="/opt/app/tmp" />
        <!-- 数据库工具目录-->
        <PARAM name="gaussdbToolPath" value="/opt/app/install/om" />
        <!-- 数据库core文件目录-->
        <PARAM name="corePath" value="/opt/app/corefile" />
        <!-- 节点IP,与数据库节点名称列表一一对应 -->
        <PARAM name="backIp1s" value="192.168.100.50"/> 
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的部署信息 -->
        <DEVICE sn="1000001">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="1ge53"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.100.50"/>
            <PARAM name="sshIp1" value="192.168.100.50"/>
               
      <!--dbnode-->
      <PARAM name="dataNum" value="1"/>
        <!–DBnode端口号–>
      <PARAM name="dataPortBase" value="15400"/>
        <!–DBnode主节点上数据目录,及备机数据目录–>
      <PARAM name="dataNode1" value="/opt/app/install/data/dn01"/>
<!–DBnode节点上设定同步模式的节点数–>
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>
    </DEVICELIST>
</ROOT>

5.3 安装前交互(OM工具)

创建完openGauss配置文件后,在执行安装前,为了后续能以最小权限进行安装及openGauss管理操作,保证系统安全性,需要运行安装前置脚本gs_preinstall准备好安装用户及环境。
安装前置脚本gs_preinstall可以协助用户自动完成如下的安装环境准备工作:
  • 自动设置Linux内核参数以达到提高服务器负载能力的目的。这些参数直接影响数据库系统的运行状态,请仅在确认必要时调整。
  • 自动将openGauss配置文件、安装包拷贝到openGauss主机的相同目录下。
  • openGauss安装用户、用户组不存在时,自动创建安装用户以及用户组。
  • 读取openGauss配置文件中的目录信息并创建,将目录权限授予安装用户。

1)前提条件

已完成1.5安装准备的所有任务。

2)注意事项

  • 用户需要检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。
  • xml文件中各主机的名称与IP映射配置正确。
  • 只能使用root用户执行gs_preinstall命令。

3)执行gs_preinstall

[root@1ge53 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Setting pssh path
Successfully set core path.
您确定要创建用户[omm]并为其创建信任吗
Are you sure you want to create the user[omm] and create trust for it (yes/no)? y
Please enter password for cluster user.
Password:omm123
Please enter password for cluster user again.
Password:omm123
Successfully created [omm] user on all nodes.
Preparing SSH service.
Successfully prepared SSH service.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Setting SCTP service.
Successfully set SCTP service.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opt/software/openGauss/script/gs_checkos -i A -h 1ge53 --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.

4)detail检查信息

[root@1ge53 script]# ./gs_checkos -i A -h 1ge53 --detail
Checking items:
    A1. [ OS version status ] : Normal
        [1ge53]
        centos_7.6.1810_64bit

    A2. [ Kernel version status ] : Normal
        The names about all kernel versions are same. The value is "3.10.0-1160.el7.x86_64".
    A3. [ Unicode status ] : Normal
        The values of all unicode are same. The value is "LANG=en_US.UTF-8".
    A4. [ Time zone status ] : Normal
        The informations about all timezones are same. The value is "+0800".
    A5. [ Swap memory status ] : Normal
        The value about swap memory is correct.
    A6. [ System control parameters status ] : Warning
        [1ge53]
        Warning reason: variable 'net.ipv4.tcp_retries1' RealValue '3' ExpectedValue '5'.
        Warning reason: variable 'net.ipv4.tcp_syn_retries' RealValue '6' ExpectedValue '5'.
        Warning reason: variable 'net.sctp.path_max_retrans' RealValue '5' ExpectedValue '10'.
        Warning reason: variable 'net.sctp.max_init_retransmits' RealValue '8' ExpectedValue '10'.
        Check_SysCtl_Parameter warning.

    A7. [ File system configuration status ] : Warning
        [1ge53]
        Warning reason: variable 'max user processes' RealValue '14950' ExpectedValue 'unlimited'

    A8. [ Disk configuration status ] : Normal
        The value about XFS mount parameters is correct.
    A9. [ Pre-read block size status ] : Normal
        The value about Logical block size is correct.
    A10.[ IO scheduler status ] : Normal
        The value of IO scheduler is correct.
    A11.[ Network card configuration status ] : Warning
        [1ge53]
BondMode Null
        Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192'

    A12.[ Time consistency status ] : Warning
        [1ge53]
        The NTPD not detected on machine and local time is "2022-11-03 22:54:03".

    A13.[ Firewall service status ] : Normal
        The firewall service is stopped.
    A14.[ THP service status ] : Normal
        The THP service is stopped.
Total numbers:14. Abnormal numbers:0. Warning numbers:4.

5)根据报告手动添加sysctl.conf修改值

cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.sctp.path_max_retrans = 10
net.sctp.max_init_retransmits = 10
net.ipv4.tcp_fin_timeout = 60
EOF
sysctl -p

5.4 执行安装

前提条件:
  • 已成功执行前置脚本gs_preinstall ;
  • 服务器操作系统和网络均正常运行。

1)使用root执行如下命令

修改文件权限:
cd /opt/software/openGauss/script
chmod -R 775 /opt/software/openGauss/script
chown -R omm:dbgrp /opt/software/openGauss/script

2)使用omm用户安装openGauss DBMS和创建openGauss数据库

su - omm
cd /opt/software/openGauss/script

3)执行

在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。
设置的密码要符合复杂度要求:
  • 最少包含8个字符。
  • 不能和用户名、当前密码(ALTER)、或当前密码反序相同。
  • 至少包含大写字母(A-Z),小写字母(a-z),数字,非字母数字字符(限定为~!@#$%^&*()-_=+\|[{}];:,<.>/?)四类字符中的三类字符。
安装过程中会生成ssl证书,证书存放路径为{gaussdbAppPath}/share/sslcert/om,其中{gaussdbAppPath}为openGauss配置文件中指定的程序安装目录。
日志文件路径下会生成两个日志文件:“gs_install-YYYY-MMDD_HHMMSS.log”和“gs_local-YYYY-MM-DD_HHMMSS.log”
 说明:
openGauss支持字符集的多种写法:gbk/GBK、UTF-8/UTF8/utf8/utf-8和Latine1/latine1。
安装时若不指定字符集,默认字符集为SQL_ASCII,为简化和统一区域loacle默认设置为C,若想指定其他字符集和区域,请在安装时使用参数–gsinit-parameter=“–locale=LOCALE”来指定,LOCALE为新数据库设置缺省的区域。
例如用户要将数据库编码格式初始化为UTF-8,可以采用如下步骤:
用locale -a |grep utf8命令查看系统支持UTF-8编码的区域,如下:
  • 安装方式一:

根据需要选择区域,如en_US.utf8,初始化数据库时加入–locale=en_US.utf8选项进行安装,示例如下:
gs_install -X /opt/software/openGauss/cluster_config.xml --gsinit-parameter="--locale=en_US.utf8"
示例:
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:huawei@1234
Please repeat for database:huawei@1234
begin to create CA cert files
The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.
end deploy..

  • 安装方式二:

gs_install -X /opt/software/openGauss/script/clusterconfig.xml \
--gsinit-parameter="--encoding=UTF8" \
--dn-guc="max_connections=1000" \
--dn-guc="max_process_memory=3GB" \
--dn-guc="shared_buffers=128MB" \
--dn-guc="bulk_write_ring_size=128MB" \
--dn-guc="cstore_buffers=16MB"


首次登陆
[omm@1ge53 ~]$ gsql -d postgres -p 15400 -r
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#

【说明】-r 具有编辑功能,例如键盘的上下箭头。


安装报错处理

6.1 预检查时GAUSS-51900 不支持7.9

处理一:

下载7.6内核https://vault.centos.org/7.6.1810/os/x86_64/Packages/centos-release-7-6.1810.2.el7.centos.x86_64.rpm
强制安装:
rpm -ivh centos-release-7-6.1810.2.el7.centos.x86_64.rpm --force
查看:
[root@1ge53 script]# rpm -qa | grep -i centos-release
centos-release-7-9.2009.0.el7.centos.x86_64
centos-release-7-6.1810.2.el7.centos.x86_64

卸载7.9:
[root@1ge53 script]# rpm -ev centos-release-7-9.2009.0.el7.centos.x86_64
Preparing packages...
centos-release-7-9.2009.0.el7.centos.x86_64

再次查看:
[root@1ge53 script]# rpm -qa | grep -i centos-release
centos-release-7-6.1810.2.el7.centos.x86_64

处理二:

7.9修改为7.6:
[root@localhost ~]#cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

6.2 安装数据库时GAUSS-51400

查看状态:
[omm@1ge53 script]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : 1geCluster
cluster_state : Unavailable
redistributing : No
-----------------------------------------------------------------------

重新启动:
gs_om -t stop&&gs_om -t start
[omm@1ge53 script]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.

[omm@1ge53 script]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] 1ge53
2022-11-04 11:42:03.705 63648a0b.1 [unknown] 140177987811072 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-11-04 11:42:03.707 63648a0b.1 [unknown] 140177987811072 [unknown] 0 dn_6001 01000  0 [BACKEND] WARNING: Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes)or shared memory (3310 Mbytes) is larger. ##正常告警
=========================================
Successfully started.


END


本文作者:刘忠一(上海新炬中北团队)

本文来源:“IT那活儿”公众号

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

评论