关注

opengauss_6.0.0数据库企业版安装

目录

前言:

1、整体安装流程

1.1、安装流程图

2、获取安装包

2.1、下载安装包

2.2、检查安装包 

3、准备软硬件安装环境 

3.1、软硬件环境要求

4、修改操作系统配置

4.1、关闭防火墙及selinux

4.2、(可选)关闭swap交换内存

4.3、关闭RemoveIPC

5、配置用户及用户组

6、安装openGauss

6.1、创建XML配置文件

6.2、初始化安装环境

6.3、执行安装

6.4、安装验证

6.5、创建数据库

总结:


前言:

        openGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。opengauss企业版安装的主要使用主体为企业或对数据库性能要求较高的个人,安装流程比较复杂,功能更全。本文基于openeluer22.03操作系统进行opengauss数据库单实例的安装。安装过程中均以root用户操作,root用户已配置ssh远程登录。

1、整体安装流程

1.1、安装流程图

        openGauss的安装流程如图1所示。

图1 

        接下来的章节按照流程图上的步骤进程安装操作。

2、获取安装包

2.1、下载安装包

        从openGauss开源社区下载对应平台的安装包。

2.1.1、登录openGauss开源社区openGauss软件 | openGauss下载 | openGauss软件包 | openGauss社区

选择对应平台的企业版安装包,单击“立即下载”,下载到本地电脑如图2所示。之后上传到linux服务器的/opt/software/openGauss/目录下

 图2

2.2、检查安装包 

        解压安装包,检查安装目录及文件是否齐全。在安装包所在目录执行以下命令:

  tar -zxvf openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz

[root@gaussdb openGauss]# tar -zxvf openGauss-All-6.0.0-openEuler22.03-x86_64.tar.gz 
openGauss-CM-6.0.0-openEuler22.03-x86_64.tar.gz
openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz
openGauss-Server-6.0.0-openEuler22.03-x86_64.tar.bz2
openGauss-CM-6.0.0-openEuler22.03-x86_64.sha256
openGauss-OM-6.0.0-openEuler22.03-x86_64.sha256
openGauss-Server-6.0.0-openEuler22.03-x86_64.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256

         执行ls -lb命令,显示类似如下信息,显示了openGauss安装包解压后所有安装的文件内容。

[root@gaussdb openGauss]# ls -lh
total 150M
-rw-r-----. 1 root root    0 Sep 29 19:31 openGauss-CM-6.0.0-openEuler22.03-x86_64.sha256
-rw-r-----. 1 root root  22M Sep 29 19:31 openGauss-CM-6.0.0-openEuler22.03-x86_64.tar.gz
-rw-r-----. 1 root root   65 Sep 29 19:29 openGauss-OM-6.0.0-openEuler22.03-x86_64.sha256
-rw-r-----. 1 root root  23M Sep 29 19:29 openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz
-rw-r-----. 1 root root   65 Sep 29 19:31 openGauss-Server-6.0.0-openEuler22.03-x86_64.sha256
-rw-r-----. 1 root root 105M Sep 29 19:31 openGauss-Server-6.0.0-openEuler22.03-x86_64.tar.bz2
-rw-------. 1 root root   65 Sep 29 19:28 upgrade_sql.sha256
-rw-------. 1 root root 552K Sep 29 19:28 upgrade_sql.tar.gz

3、准备软硬件安装环境 

3.1、软硬件环境要求

        本文是在个人电脑VMware Workstation虚拟机上的操作系统安装opengauss数据库,所以配置较低,如在生产环境安装,请参见官方链接。准备软硬件安装环境 企业版 | openGauss文档 | openGauss社区中的详细配置说明。

3.1.1、硬件环境要求

项目配置描述
内存4G
CPU4核
硬盘30G
网络网卡配置IP并桥接配置VMwareWorkstation主机

3.1.2、软件环境要求 

软件类型配置描述
Linux操作系统openEuler 22.03
Linux文件系统剩余inode个数 > 15亿(推荐)
工具bzip2
PythonopenEuler:支持>=Python 3.6.X且<=Python 3.10.X

        注意在安装 openEuler 22.03操作系统的过程中,运行至选择软件包的界面,其中基本环境选择Server,附加软件包选择openGaussServer。这样系统会自动安装openGauss数据库所需软件。如图3所示:

图3 

3.1.3、软件依赖要求

所需软件建议版本
libaio-devel建议版本:0.3.109-13
readline-devel建议版本:7.0-13
expect--

        安装软件依赖命令:yum install libaio-devel readline-devel expect -y,安装完成后查看软件包版本符合要求 。

[root@gaussdb openGauss]# rpm -qa egrep 'libaio-devel|readline-devel|expect'
libaio-devel-0.3.113-9.oe2409.x86_64
readline-devel-8.2-2.oe2409.x86_64
expect-5.45.4-8.oe2409.x86_64

4、修改操作系统配置

4.1、关闭防火墙及selinux

4.1.1、关闭防火墙并禁止开机重启

        执行命令:

        systemctl disable firewalld.service
        systemctl stop firewalld.service

4.1.2、修改/etc/selinux/config文件中的“SELINUX”值为“disabled”

        a. 使用VIM打开config文件

            vim /etc/selinux/config
        b. 修改“SELINUX”的值“disabled”,执行:wq!保存并退出修改。  

             SELINUX=disabled

4.1.3、重启系统

        完成4.1.1和4.1.2的步骤以后,执行命令shutdown -r now重启操作系统完成配置

4.2、(可选)关闭swap交换内存

        说明:关闭swap交换内存是为了保障数据库的访问性能,避免把数据库的缓冲区内存淘汰到磁盘上。 如果服务器内存比较小,内存过载时,可打开swap交换内存保障正常运行。

        使用swapoff -a命令将交换内存关闭。

4.3、关闭RemoveIPC

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

       a. 使用VIM打开logind.conf文件。

        vim /etc/systemd/logind.conf

        b. 修改“RemoveIPC”值为“no”。

        RemoveIPC=no

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

        a. 使用VIM打开systemd-logind.service文件。

        vim /usr/lib/systemd/system/systemd-logind.service

        b. 修改“RemoveIPC”值为“no”。

        RemoveIPC=no

4.3.3、重新加载配置参数。

        systemctl daemon-reload
        systemctl restart systemd-logind

4.3.4、执行以下命令检查修改是否生效。

        loginctl show-session | grep RemoveIPC
        systemctl show systemd-logind | grep RemoveIPC

[root@gaussdb openGauss]# loginctl show-session | grep RemoveIPC
RemoveIPC=no
[root@gaussdb openGauss]# systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no

5、配置用户及用户组

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

用户/组名所属类型规划建议
dbgrp操作系统

建议规划单独的用户组,例如    dbgrp。    初始化安装环境时,由-G参数所指定的安装用户所属的用户组。该用户组如果不存在,则会自动创建,也可提前创建好用户组。在执行gs_preinstall脚本时会检查权限。gs_preinstall脚本会自动赋予此组中的用户对安装目录、数据目录的访问和执行权限。    创建dbgrp用户组命令:

groupadd dbgrp

omm操作系统建议规划用户用于运行和维护    openGauss,例如omm。初始化安装环境时,由-U参数所指定和自动创建的操作系统用户,如果已经存在该用户,请清理该用户或更换初始化用户。从安全性考虑,对此用户的所属组规划如下:    所属组:dbgrp

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

6、安装openGauss

6.1、创建XML配置文件

        安装openGauss前需要创建instance_config.xml文件。instance_config.xml文件包含部署openGauss的服务器信息、安装路径、IP地址以及端口号等。用于告知openGauss如何部署。用户需根据不同场景配置对应的XML文件。创建配置文件示例:

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="gaussdb" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="localhost" />
        <!-- 数据库安装目录-->
        <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.100.191"/> 
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的部署信息 -->
        <DEVICE sn="localhost">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="localhost"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <!-- 用ipv6安装部署时 换上ipv6地址即可,后面xml文件示例也是同样操作 -->
            <PARAM name="backIp1" value="192.168.100.191"/>
            <PARAM name="sshIp1" value="192.168.100.191"/>
               
	    <!--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>

6.2、初始化安装环境

6.2.1、准备安装用户及环境

        创建完openGauss配置文件后,在执行安装前,为了后续能以最小权限进行安装及openGauss管理操作,保证系统安全性,需要运行安装前置脚本gs_preinstall准备好安装用户及环境。

        安装前置脚本gs_preinstall可以协助用户自动完成如下的安装环境准备工作:

        a、自动设置Linux内核参数以达到提高服务器负载能力的目的。这些参数直接影响数据库系统的运行状态,请仅在确认必要时调整。openGauss所设置的Linux内核参数取值请参见配置操作系统参数初始化安装环境 | openGauss文档 | openGauss社区

       b、自动将openGauss配置文件、安装包拷贝到openGauss主机的相同目录下。

       c、openGauss安装用户、用户组不存在时,自动创建安装用户以及用户组。

       d、读取openGauss配置文件中的目录信息并创建,将目录权限授予安装用户。

6.2.2、操作步骤

       a、切换到2.2步骤中解压安装包后文件所在目录/opt/software/openGauss,安装包解压后,会有OM安装包和Server安装包。继续解压OM安装包即openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz,会在/opt/software/openGauss路径下自动生成script子目录,并且在script目录下生成gs_preinstall等各种OM工具脚本。

        tar -zxvf openGauss-OM-6.0.0-openEuler22.03-x86_64.tar.gz

        b、修改安装包目录权限

        chmod 755 -R /opt/software

        c、进入到工具脚本存放目录下,其中在步骤6.1中创建的instance_config.xml文件也放在了这个目录下,方便执行

        cd /opt/software/openGauss/script

        d、为确保成功安装,检查hostname与/etc/hostname是否一致。预安装过程中,会对hostname进行检查。

        e、使用gs_preinstall准备好安装环境。若为共用环境需加入--sep-env-file=ENVFILE参数分离环境变量,避免与其他用户相互影响,ENVFILE为用户自行指定的环境变量分离文件的路径,可以为一个空文件。执行命令:

        ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/instance_config.xml

[root@gaussdb script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/instance_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 host ip env
Successfully set host ip env.
Are you sure you want to create the user[omm] (yes/no)? yes
Please enter password for cluster user.
Password: 
Please enter password for cluster user again.
Password: 
Generate cluster user password files successfully.
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.
Checking cpu instructions.
Successfully checked cpu instructions.
Creating cluster's path.
Successfully created cluster's path.
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 gaussdb -X /opt/software/openGauss/instance_config.xml --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.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.

        看到出现警告,Warning: Installation environment contains some warning messages.执行命令/opt/software/openGauss/script/gs_checkos -i A -h gaussdb -X /opt/software/openGauss/instance_config.xml --detail查看:

[root@gaussdb script]# /opt/software/openGauss/script/gs_checkos -i A -h gaussdb -X /opt/software/openGauss/instance_config.xml --detail
Checking items:
    A1. [ OS version status ]                                   : Normal     
        [gaussdb]
        openEuler_22.03_64bit
           
    A2. [ Kernel version status ]                               : Normal     
        The names about all kernel versions are same. The value is "5.10.0-216.0.0.115.oe2203sp4.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.     
    A10.[ IO scheduler status ]                                 : Normal     
        The value of IO scheduler is correct.              
    A11.[ Network card configuration status ]                   : Warning    
        [gaussdb]
BondMode Null
        Warning reason: network 'ens33' 'mtu' RealValue '1500' ExpectedValue '8192'

    A12.[ Time consistency status ]                             : Normal     
        The ntpd or chronyd service is started, local time is "2025-01-14 08:56:12".
    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:1.

        可以看到警告内容为网卡未做绑定,MTU(最大传输单元)值较小,因为是测试环境安装所以此处不做处理,如果是生产环境,需要配置多个网卡进行绑定增加MTU值。 

6.2.3、配置操作系统参数

        openGauss要求各主机上的操作系统参数设置成一定的值,以满足系统运行的性能要求等。这些参数有些会在openGauss安装环境准备阶段完成设置,且这些参数将直接影响openGauss的运行状态,请仅在确认必要时进行手动调整。方法如下:

        a、执行命令:vim /etc/sysctl.conf

        b、经测试可增加如下配置信息,其它所有操作系统参数配置详细信息及说明请参见初始化安装环境 | openGauss文档 | openGauss社区,其中大部分参数系统默认已设置符合要求的值,如果参数不存在,请根据实际情况进行添加。

net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
vm.overcommit_memory = 0
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90

       c、命令使修改配置生效

        sysctl -p 

6.2.4、修改文件系统参数

        a、执行命令:vim /etc/security/limits.conf

        增加如下内容后保存,之后重启操作系统使之生效

        * soft nofile 1000000

        * hard nofile 1000000

        b、确认系统支持的最大进程数为unlimited

        执行命令:more /etc/security/limits.d/90-nofile.conf,查看结果nproc数值为unlimited,如果是其它值需要进行修改并重启操作系统

[root@gaussdb limits.d]# more /etc/security/limits.d/90-nofile.conf
root       soft    nofile  1000000
omm       soft    nofile  1000000
root       hard    nofile  1000000
omm       hard    nofile  1000000
root       soft    nproc  unlimited
omm       soft    nproc  unlimited
root       hard    nproc  unlimited
omm       hard    nproc  unlimited

6.3、执行安装

        执行前置脚本准备好openGauss安装环境之后,按照启动安装过程部署openGauss。

6.3.1、切换到前置脚本gs_preinstall中-U参数指定的omm用户

        su - omm

6.3.2、使用gs_install安装openGauss

        执行命令:gs_install -X /opt/software/openGauss/instance_config.xml

        其中/opt/software/openGauss/instance_config.xml配置文件的路径。在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。

        设置的密码要符合复杂度要求:

        a、最少包含8个字符,最多包含16个字符。

        b、不能和用户名、当前密码(ALTER)、或当前密码反序相同。

        c、至少包含大写字母(A-Z)、小写字母(a-z)、数字、非字母数字字符(限定为~!@#$%^&*()-_=+\|[{}];:,<.>/?)四类字符中的三类字符。

        安装过程中会生成ssl证书,证书存放路径为{gaussdbAppPath}/share/sslcert/om,其中{gaussdbAppPath}为openGauss配置文件中指定的程序安装目录。

        日志文件路径下会生成两个日志文件:“gs_install-YYYY-MMDD_HHMMSS.log”和“gs_local-YYYY-MM-DD_HHMMSS.log”。

[omm@gaussdb script]$ gs_install -X /opt/software/openGauss/instance_config.xml
Parsing the configuration file.
Successfully checked gs_uninstall on every node.
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:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om
NO cm_server instance, no need to create CA for CM.
Non-dss_ssl_enable, no need to create CA for DSS
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.
The cluster status is Normal.
Successfully started cluster.
Successfully installed application.
end deploy..

        查看执行过程及结果,显示安装成功。安装后的目录及各目录下的文件说明请参见执行安装 | openGauss文档 | openGauss社区

6.3.3、错误排查

        如果安装失败请根据openGauss日志目录下的“gs_install-YYYY-MM-DD_HHMMSS.log”和“gs_local-YYYY-MM-DD_HHMMSS.log”中的日志信息排查错误。

6.4、安装验证

        通过openGauss提供的gs_om工具可以完成数据库状态检查。

6.4.1、以omm用户身份登录服务器。

        su - omm

6.4.2、执行状态检查

        执行如下命令检查数据库状态是否正常,“cluster_state ”显示“Normal”表示数据库可正常使用。

        gs_om -t status

[omm@gaussdb script]$ gs_om -t status
-----------------------------------------------------------------------

cluster_name    : gaussdbins
cluster_state   : Normal
redistributing  : No

-----------------------------------------------------------------------

6.4.2、执行连接检查 

        数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。其中postgres为需要连接的数据库名称,15400为数据库主节点的端口号,即XML配置文件中的dataPortBase的值。可根据实际情况替换。

        执行如下命令:gsql -d postgres -p 15400

        连接成功后,系统显示类似如下信息表示数据库连接成功。

[omm@gaussdb script]$ gsql -d postgres -p 15400
gsql ((openGauss 6.0.0 build aee4abd5) compiled at 2024-09-29 19:14:27 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

6.5、创建数据库

        使用SQL语句创建数据库,指定数据库的字符集为GBK。

6.5.1、执行创建语句

        执行6.4.2中的步骤后,连接成功登录到数据库后执行:

        gsql -d postgres -p 26000;

        之后执行语句:CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;

openGauss-# gsql -d postgres -p 26000
openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
CREATE DATABASE

         显示信息:CREATE DATABASE完成安装。

总结:

        以上为opengauss数据库单实例安装过程,安装完成后可进行建表或迁移等操作。群集及分布式安装方法会在之后的博客篇章中体现。

转载自CSDN-专业IT技术社区

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/pengdott/article/details/145033892

评论

赞0

评论列表

微信小程序
QQ小程序

关于作者

点赞数:0
关注数:0
粉丝:0
文章:0
关注标签:0
加入于:--