openGauss 企业版安装 教程
1.下载安装包
在华为云上租一台服务器,操作系统选:openEuler 20.03 64bit (64-bit)
获取openGauss Server安装包,企业版:软件包链接
使用xshell连接服务器,准备软硬件安装环境(该装的依赖记得装好)。准备软硬件安装环境 教程
下载Data Studio_5.0.0:软件包(在openGauss Tools一栏)
2.服务器安装 - 单节点安装
①创建cluster_config.xml文件
可以用hostname和cat /etc/hostname指令查看主机名。
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="dbCluster" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="ecs-7094" />
<!-- 数据库安装目录-->
<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="139.9.249.211"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="node1_hostname">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="ecs-7094"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="192.168.0.203"/>
<PARAM name="sshIp1" value="139.9.249.211"/>
<!--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用户登录待安装openGauss的任意主机,并按规划创建存放安装包的目录
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software
# 解压安装包和安装包下的OM子安装包
cd /opt/software/openGauss
tar -zxvf openGauss-5.0.0-openEuler-64bit-all.tar.gz
tar -zxvf openGauss-5.0.0-openEuler-64bit-om.tar.gz
将openGauss安装包和cluster_config.xml配置文件上传至上一步所创建的目录中。(可使用xftp)
采用交互模式执行前置,并在执行过程中自动创建操作系统root用户互信和omm用户互信。
omm为数据库管理员(也是运行openGauss的操作系统用户),dbgrp为运行openGauss的操作系统用户的群组名。 具体查看:了解安装用户及用户组
cd /opt/software/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
报错
执行指令/opt/software/openGauss/script/gs_checkos -i A -h ecs-7094 --detail查看具体的错误
解决第一个warning
A6. [ System control parameters status ] : Warning
[ecs-7094]
Warning reason: variable 'net.ipv4.tcp_retries1' RealValue '3' ExpectedValue '5'.
Warning reason: variable 'net.ipv4.tcp_syn_retries' RealValue '6' ExpectedValue '5'.
Check_SysCtl_Parameter warning.
vi /etc/sysctl.conf
# 在文件后面追加下面两句
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
# 使修改的参数生效
sysctl -p
解决第二个warning
A7. [ File system configuration status ] : Warning
[ecs-7094]
Warning reason: variable 'open files' RealValue '65535' ExpectedValue '1000000'
Warning reason: variable 'max user processes' RealValue '13115' ExpectedValue 'unlimited'
ulimit -a # 显示系统资源的设置
ulimit -n 1000000 //设置open files为1000000
ulimit -u unlimited //设置max user processes为unlimited
解决Abnormal
The THP service status RealValue 'enabled' ExpectedValue 'disabled'.
vim /etc/rc.d/rc.local
# 添加以下内容
if test -f /sys/kernel/mm/transparent_hugepage/enabled;
then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag;
then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
# 保存退出,赋予rc.local文件执行权限
chmod +x /etc/rc.d/rc.local
# 重启系统,检查THP是否被禁用
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
# 再次执行指令检查
/opt/software/openGauss/script/gs_checkos -i A -h ecs-7094 --detail
cd /opt/software/openGauss/script
./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
又报错
Setting Cgroup.
Error: Failed to set Cgroup.
[GAUSS-50201] : The libaio.so or libaio.so.* does not exist.
yum install -y libaio-devel
③执行安装
# 切换到omm用户
su - omm
# 使用gs_install安装openGauss
gs_install -X /opt/software/openGauss/cluster_config.xml
报错
2023-06-23 18:56:00.858 64957a40.1 [unknown] 140348495986624 [unknown] 0 dn_6001 42809 0 [BACKEND] FATAL: could not create shared memory segment: Cannot allocate memory
2023-06-23 18:56:00.858 64957a40.1 [unknown] 140348495986624 [unknown] 0 dn_6001 42809 0 [BACKEND] DETAIL: Failed system call was shmget(key=15400001, size=3422169416, 03600).
2023-06-23 18:56:00.858 64957a40.1 [unknown] 140348495986624 [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 3422169416 bytes), reduce openGauss's shared memory usage, perhaps by reducing shared_buffers.
修改postgresql.conf配置文件中的shared_buffers,改小一点,比如原来的1/4。
vi postgresql.conf
④安装验证
以omm用户身份登录服务器。
# 检查数据库状态是否正常
gs_om -t status
# 连接数据库, 其中postgres为需要连接的数据库名称,15400为数据库主节点的端口号,即XML配置文件中的dataPortBase的值。
gsql -d postgres -p 15400