版本选取

 # 下载opengauss安装介质,截止2023年7月份最新版本长期支持版(LTS:Long Term Support)是5.0.0版本;此外,还有预览版3.1.1;这里建议安装openGauss 5.0.0 (LTS)。
 企业版:更像是生产版、极简版:更像开发版本;轻量版:在企业版的基础上去掉了OM、CM等组件。
 https://opengauss.org/zh/download/
 # 这里以CentOS7.6+openGauss_5.0.0 企业版作为验证安装环境;
操作系统CentOS7.6最小化安装
CPU4核心(opengauss建议:8核心+,如单实例部署建议16核心+)
内存4GB(opengauss建议:32GB+,如单实例部署建议128GB+)
磁盘50GB:只做了boot分区、根分区(不用做swap分区:opengauss要求禁用swap)
网卡单网卡(opengauss建议:双网卡做bond)

初始化安装环境

 # 安装依赖包
 yum -y install bzip2 python3 libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel net-tools
 ​
 # 升级pip工具
 pip3 install --upgrade pip
 ​
 # 关闭SELinux和防火墙
 vi /etc/selinux/config 
 #SELINUX=enforcing
 SELINUX=disabled
 systemctl disable firewalld.service
 systemctl stop firewalld.service
 ​
 # 关闭swap
 swapoff -a
 vi /etc/fstab 
 #/dev/mapper/centos_opengauss5--212-swap swap                    swap    defaults        0 0
 ​
 # 关闭logind的RemoveIPC
 vi /etc/systemd/logind.conf
 RemoveIPC=no
 ​
 # 创建安装介质目录,解压安装介质
 mkdir -p /opt/software/openGauss
 chmod 755 -R /opt/software
 mv openGauss-5.0.0-CentOS-64bit-all.tar.gz /opt/software/openGauss
 mv /home/omm/cluster_config.xml /opt/software/openGauss
 cd /opt/software/openGauss
 tar zxvf openGauss-5.0.0-CentOS-64bit-all.tar.gz 
 tar zxvf openGauss-5.0.0-CentOS-64bit-om.tar.gz 
 ​
 # 最好手动配一下hosts,不配也可以,安装脚本会自动安装
 vi /etc/hosts
 192.168.14.212 opengauss5-212
 ​
 # 可以不手动创建omm用户和dbgrp用户组,安装脚本会自动安装;
 groupadd dbgrp
 useradd omm -g dbgrp
 ​
 # 如下python3的模块必须要装,使用普通用户不会有WARNING,使用root也可以。
 su - omm
 $ pip3 install psutil
 $ pip3 install netifaces
 $ pip3 install cffi
 $ pip3 install pycparser
 $ pip3 install cryptography
 $ pip3 install pynacl
 $ pip3 install bcrypt
 $ pip3 install paramiko
 ​
 # 禁用transparent_hugepage
 vi /etc/default/grub 
 #GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos_opengauss5-212/root rd.lvm.lv=centos_opengauss5-212/swap rhgb quiet"
 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos_opengauss5-212/root rd.lvm.lv=centos_opengauss5-212/swap rhgb quiet transparent_hugepage=never"
 grub2-mkconfig -o /boot/grub2/grub.cfg
 ​
 # 调整内核参数
 vi /etc/sysctl.d/99-sysctl.conf 
 net.ipv4.tcp_retries1=5
 net.ipv4.tcp_syn_retries=5
 ​
 # 调整limit限制参数
 vi /etc/security/limits.conf 
 root       soft    nproc  unlimited
 omm       soft    nproc  unlimited
 root       hard    nproc  unlimited
 omm       hard    nproc  unlimited
 ​
 root     soft nofile   1000000
 omm      soft nofile   1000000
 root     hard nofile   1000000
 omm     hard nofile   1000000
 ​
 # 调整网卡参数
 vi /etc/sysconfig/network-scripts/ifcfg-ens160 
 MTU="8192"
 TX="4096"
 RX="4096"
 ​
 # 重启令 selinux等配置生效
 reboot
 ​
 # 执行验证环境是否准备好:没有Abnormal状态即可;Warning状态的可以处理可以不处理。
 /opt/software/openGauss/script/gs_checkos -i A -h opengauss5-212 --detail
 Checking items:
     A1. [ OS version status ]                                   : Normal     
         [opengauss5-212]
         centos_7.6.1810_64bit
     
     A2. [ Kernel version status ]                               : Normal     
         The names about all kernel versions are same. The value is "3.10.0-957.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 ]                    : Normal     
         All values about system control  parameters are correct.
     A7. [ File system configuration status ]                    : Normal     
         Both soft nofile and hard nofile are correct.      
     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.     
     A11.[ Network card configuration status ]                   : Warning    
         [opengauss5-212]
 BondMode Null
         Warning reason: network 'ens160' 'rx' RealValue '4032' ExpectValue '4096'.
 ​
     A12.[ Time consistency status ]                             : Warning    
         [opengauss5-212]
         The NTPD not detected on machine and local time is "2023-07-06 21:06:59".
 ​
     A13.[ Firewall service status ]                             : Normal     
         The firewall service is stopped.                   
     A14.[ THP service status ]                                  : Normal     
         The THP service is stopped.                        
 Total numbers:13. Abnormal numbers:0. Warning numbers:2.
 ​

准备XML配置文件:cluster_config.xml

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

执行安装

 # root下执行预安装
 cd /opt/software/openGauss/script
 ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
 ……
 Preinstallation succeeded.   #--- 表示预安装成功
 ​
 # omm用户下执行安装
 su - omm
 $ gs_install -X /opt/software/openGauss/cluster_config.xml
 Parsing the configuration file.
 Check preinstall on every node.
 Successfully checked preinstall on every node.
 Creating the backup directory.
 Last time end with Start cluster.
 Continue this step.
 Successfully created the backup directory.
 begin deploy..
 The cluster status is Normal.
 Successfully started cluster.
 Successfully installed application.
 end deploy..

 # 验证是否安装成功:cluster_state   : Normal
 $ gs_om -t status
 -----------------------------------------------------------------------
 ​
 cluster_name    : single
 cluster_state   : Normal
 redistributing  : No
 ​
 -----------------------------------------------------------------------
 ​
 # 访问
 $ gsql -d postgres -p 15400
 gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:07:56 commit 0 last mr  )
 Non-SSL connection (SSL connection is recommended when requiring high-security)
 Type "help" for help.
 ​
 openGauss=#

FAQ

 #问题:执行pip3 install安装python模块失败
 Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ap19dhuq/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-_g6qbyqx-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ap19dhuq/psutil/
 #解决:
 pip3 install --upgrade pip
 ​
 #问题:执行pip3 install 输出告警
 WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
 WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
 #解决:
 使用普通用户执行pip3 install
 ​
 #问题:执行gs_install安装命令报错
 Traceback (most recent call last):
   File "/opt/huawei/install/om/script/local/Install.py", line 812, in <module>
     functionDict[g_opts.action]()
   File "/opt/huawei/install/om/script/local/Install.py", line 743, in startCluster
     dn.start(self.time_out)
   File "/opt/huawei/install/om/script/local/../gspylib/component/Kernel/Kernel.py", line 106, in start
     "failure details." + "\n" + output)
 Exception: [GAUSS-51607] : Failed to start instance. Error: Please check the gs_ctl log for failure details.
 [2023-07-06 21:15:37.786][10670][][gs_ctl]: gs_ctl started,datadir is /opt/huawei/install/data/dn 
 [2023-07-06 21:15:37.894][10670][][gs_ctl]: waiting for server to start...
 ……
 2023-07-06 21:15:38.181 64a6be79.1 [unknown] 139985881190656 [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 (3543 Mbytes) is larger.
 2023-07-06 21:15:38.181 64a6be79.1 [unknown] 139985881190656 [unknown] 0 dn_6001 42809  0 [BACKEND] FATAL:  could not create shared memory segment: Cannot allocate memory
 2023-07-06 21:15:38.181 64a6be79.1 [unknown] 139985881190656 [unknown] 0 dn_6001 42809  0 [BACKEND] DETAIL:  Failed system call was shmget(key=15400001, size=3715893576, 03600).
 2023-07-06 21:15:38.181 64a6be79.1 [unknown] 139985881190656 [unknown] 0 dn_6001 42809  0 [BACKEND] HINT:  This error usually means that openGauss's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMALL.  To reduce the request size (currently 3715893576 bytes), reduce openGauss's shared memory usage, perhaps by reducing shared_buffers.
         The openGauss documentation contains more information about shared memory configuration.
 2023-07-06 21:15:38.185 64a6be79.1 [unknown] 139985881190656 [unknown] 0 dn_6001 00000  0 [BACKEND] LOG:  FiniNuma allocIndex: 0.
 [2023-07-06 21:15:38.895][10670][][gs_ctl]: waitpid 10673 failed, exitstatus is 256, ret is 2
 ​
 [2023-07-06 21:15:38.896][10670][][gs_ctl]: stopped waiting
 [2023-07-06 21:15:38.896][10670][][gs_ctl]: could not start server
 Examine the log output.
 ​
 解决:主要是因为小马拉大车的原因
 1、根据服务器内存配置适当的kernel.shmall和kernel.shmmax
 2、$ vi /opt/huawei/install/data/dn/postgresql.conf
 #max_process_memory = 2GB   
 max_process_memory = 3GB
 ​
 #shared_buffers = 720MB                 # min 128kB
 shared_buffers = 128MB                  # min 128kB
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐