【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装

老老老JR老北
发布于 2023-9-12 11:11
浏览
0收藏

背景

众所周知,openGauss从2020年6月30日正式开源。openGauss 5.0.0是openGauss发布的第三个LTS版本,版本生命周期为3年。openGauss 5.0.0版本与之前的版本功能特性保持兼容,在内核能力、工具链、兼容性方面全面增强。

1.openGauss安装包准备

下载openGauss 5.0.0企业版安装包。下载CPU架构是X86,操作系统是Centos7.6。请根据安装操作系统下载对应数据库安装包。

官网下载:https://opengauss.org/zh/download/

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

2.安装软件环境准备

 环境:

        操作系统:centos7.9

        CPU架构:x86

        机器配置:8c16G

1.关闭防火墙和SELINUX 

为确保openGauss的正常使用。用户需要将同openGauss相关的服务、协议、IP以及端口添加到openGauss各主机的防火墙白名单中,或关闭防火墙(关闭防火墙和防火墙白名单方式选择其中一种即可)。

首先禁用SELINUX,修改/etc/selinux/config文件中的“SELINUX”值为“disabled”。

vi /etc/selinux/config

修改“SELINUX”的值“disabled”

SELINUX=disabled

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

如果防火墙不关闭,但需开放openGauss端口,本次主备库均使用5432端口。

firewall-cmd --zone=public --permanent --add-port=5432/tcp
firewall-cmd –reload
firewall-cmd –list-ports

2.关闭RemoveIPC

在各数据库节点上,关闭RemoveIPC。

修改/etc/systemd/logind.conf文件中的“RemoveIPC”值为“no”。

[root@ps-vbdb-test2 ~]# vi /etc/systemd/logind.conf
RemoveIPC=no

修改/usr/lib/systemd/system/systemd-logind.service文件中的“RemoveIPC”值为“no”。

[root@db01 ~]# vi /usr/lib/systemd/system/systemd-logind.service
RemoveIPC=no

 重新加载参数。

[root@ps-vbdb-test2 ~]# systemctl daemon-reload
[root@ps-vbdb-test2 ~]# systemctl restart systemd-logind

3.设置时区和时间
将各数据库节点的时区设置为相同时区,可以将/usr/share/zoneinfo/目录下的时区文件拷贝为/etc/localtime文件。($地区和$时区为需要设置时区的信息,如Asia/Shanghai)。可以通过date -R命令查询确认时区。

cp /usr/share/zoneinfo/$地区/时区 /etc/localtime

注:$地区/时区 执行上面命令时候,一定要修改成对应的时区。

 确认数据库节点时区,执行命令如下,最后+0800表示东8区,即北京时间。

[root@ps-vbdb-test2 ~]#date -R
Tue, 23 Jul 2023 12:28:25 +0800

使用data -s命令将数据库节点的时间设置相同,举例如下。

[root@ps-vbdb-test2 ~]#date -s "2023-07-23 14:15:00"
[root@ps-vbdb-test2 ~]#hwclock --systohc  #同步系统时间至硬件时间

如果要保证数据库节点的时间和指定的ntp服务器的时钟服务器一致,就需要配置ntp服务来同步时间,首先需要安装ntp服务操作如下:

[root@db01 ~]#yum install -y ntpdate   #安装ntp服务

在root用户下通过添加crontab自动任务,保证数据库节点和数据库服务器一致。

[root@ps-vbdb-test2 ~]# crontab -e
*/1 * * * * /usr/sbin/ntpdate -u xx.xx.xx.xx > /var/log/ntp.log

4.设置网卡MTU值

确保各数据库节点的网卡MTU值设置为相同大小。对于x86,MTU值推荐1500;对于ARM,MTU值推荐8192。(注意各数据库节点网卡MTU值保持一致即可,调整MTU值后需要验证网络传输状态,避免出现网络故障)

临时调整:

ifconfig 网卡编号 mtu 值
例如
Ifconfig team0 mtu 8192

永久调整:

echo “MTU=8192” >> /etc/sysconfig/network-scripts/ifcfg-eth0  #eth0是网卡名,通过ifconfig查看
service network restart

5.设置root允许远程登录

在安装openGauss时需要root帐户远程登录访问权限, 修改PermitRootLogin配置,允许用户远程登录。

打开sshd_config文件
vi /etc/ssh/sshd_config
修改权限配置,可以使用以下两种方式实现:
注释掉“PermitRootLogin no”
#PermitRootLogin no
或将“PermitRootLogin”改为“yes”
PermitRootLogin yes
执行:wq保存并退出编辑页面

重启ssh使命令生效

service sshd restart

6.数据库用户和用户组

为了实现安装过程中安装帐户权限最小化,及安装后openGauss的系统运行安全性,安装脚本在安装过程中会自动按照用户指定内容创建安装用户,并将此用户作为后续运行和维护openGauss的管理员帐户。

在安装openGauss过程中运行“gs_preinstall”时,会创建与安装用户同名的数据库用户,即数据库用户omm。此用户具备数据库的最高操作权限,此用户初始密码由用户指定。

7.Core_Pattern设置

为记录数据库异常宕机信息,设定core_pattern路径为数据库用户可写的路径。创建core目录尽量找剩余空间较大的磁盘存放。

[root@ps-vbdb-test2 ~]#cat /proc/sys/kernel/core_pattern 
echo "/home/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
[root@ps-vbdb-test2 ~]#mkdir -p /home/core;chmod 777 /data/core

3.安装openGauss准备

首先,创建软件表目录,上传第一步下载的openGauss5.0.0企业版安装包。创建安装放置目录。通过windows和linux交互上传工具,将openGauss-5.0.0-CentOS-64bit-all.tar.gz上传到/opt/software/openGauss/

mkdir /opt/software/openGauss/

解压:tar -xf openGauss-5.0.0-CentOS-64bit-all.tar.gz

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

解压:tar -zxvf openGauss-5.0.0-CentOS-64bit-om.tar.gz

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

安装数据库服务器依赖包之前,需要挂在linux镜像源才能保证yum正常执行。

yum groupinstall -y "Development tools"
yum install -y bison flex readline-devel zlib-devel openssl-devel bzip2-devel python-
devel libdbi* haproxy watchdog libnfnetlink gdbm-devel sqlite-
devel *bsddb* ibevent-devel libxml2 mlocate

安装python环境,需要到python官网下载3.6版本的源码包。python官网:https://www.python.org/

./configure --prefix=/usr/local/python3.6 --enable-shared
make
make install
ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3
export PYTHON_HOME=/usr/local/python3.6
export PATH=$PYTHON_HOME/bin:$PATH
source /etc/profile

注意:安装python3.6检测系统配置./configure必须增加--enable-shared参数,否则执行gs_preinstall报错如下:

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

执行如下图命令验证python3安装成功。

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

或者通过yum源安装:yum install -y python3

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

4.安装openGauss数据库

在root用户下执行预安装gs_preinstall将安装包发送到各个节点,进入/opt/software/openGauss/scripts执行gs_preinstall。命令:./gs_preinstall -U opengauss -G dbgrp -X /opt/software/openGauss/dj.xml

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

切换到数据库安装用户openGauss用户,切换命令:su - opengauss,执行gs_install安装数据库。命令:./gs_nstall -X /opt/software/openGauss/dj.xml

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

登录数据库验证安装成功。

gsql -d postgres -p  数据库端口

【我和openGauss的故事】openGauss 5.0.0企业版x86单机安装-鸿蒙开发者社区

总结

通过此次安装过程,更加熟悉了解openGauss安装前后的故事。为下一步熟悉openGauss5.0.0特性打下基础。同时给那些新来的小伙伴了解熟悉安装步骤,快速安装上手。




文章转载自公众号:openGauss


分类
标签
已于2023-9-12 11:11:41修改
收藏
回复
举报
回复
    相关推荐