VastbaseG100

基于openGauss内核开发的企业级关系型数据库。

Menu

安装部署

本章以安装一主两备数据库为例,向用户介绍HAS V2.0 for Vastbase G100高可用集群的部署流程,并详细指导用户完成各搭建步骤。

安装流程

1、准备安装环境:HAS V2.0 for Vastbase G100一主两备集群安装至少需要准备三台物理机或虚拟机进行安装部署,软硬件环境、系统环境配置请参见准备工作小节。

2、配置XML文件:安装前需要先创建cluster_config.xml文件。cluster_config.xml文件包含部署Vastbase集群的服务器信息、安装路径、IP地址以及端口号等配置信息。用户需要根据实际场景配置对应的XML文件。

3、上传文件:根据准备安装集群的CPU和操作系统平台,下载对应的Vastbase G100安装包和HAS V2.0安装包,将安装包和XML文件上传放在任意一台用于部署集群的节点上。

4、解压安装包:以root用户执行tar命令解压Vastbase G100和HAS V2.0安装包。

5、执行预安装脚本:以root用户执行gs_preinstall预安装脚本,为下一步安装准备好需要的环境和用户。

6、执行安装脚本:切换到预安装时创建的集群安装用户,使用gs_install脚本安装数据库集群。

文档中出现的节点名、IP和集群名以实际为准,本文档内的图片仅供操作参考。

配置XML文件

创建cluster_config.xml文件,根据部署环境进行配置,包含Vastbase集群的服务器信息、安装路径、IP地址以及端口号等部署信息。

vi cluster_config.xml
  • 配置文件模板和参数详见配置说明

  • cluster_config.xml配置示例以一主两备的部署方案为例,说明如何创建XML配置文件。

  • 可以参考XML文件模板进行配置。XML文件模板位置:软件解压目录下的/script/gspylib/etc/conf/cluster_config_template.xml(如按本文示例解压后的路径为/opt/software/script/gspylib/etc/conf/cluster_config_template.xml)。

上传文件

步骤1 将license文件分别放入数据库各节点的/etc/vastbase/.license。

  • 需确保上传license的文件的属主为数据库安装用户。若无,则执行如下命令(以数据库安装用户为vastbase为例):

    chown vastbase:vastbase -R /etc/vastbase
    
  • license文件也可自定义路径,但需要确保vastbase用户对license文件目录有读权限,步骤如下:

1、将license文件上传到自定义路径。

2、将license路径写入postgresql.conf配置文件,以确定能获取到license文件的位置(license文件路径为绝对路径,且需要指定到文件名级别)。

步骤2 使用root用户登录待部署集群中的任意主机节点,如在Vastbase1节点。

步骤3 创建/opt/software目录,上传G100安装包、HAS V2.0安装包、xml配置文件。

mkdir -p /opt/software/

解压安装包

解压Vastbase G100安装包

步骤1 切换至安装包目录。

cd /opt/software/

步骤2 使用root用户解压VastbaseG100的安装包,得到vastbase-installer文件夹后再次解压文件夹内的压缩包(以下命令中的安装包名称以实际为准)。

tar -zxvf Vastbase-G100-installer-xxx-xx-xx.tar.gz
tar -zxvf vastbase-installer/Vastbase-G100-2.2-Buildxxx-xxx-xx.tar.gz

步骤3 删除解压得到的om压缩包(因为HAS V2.0 for Vastbase G100集群安装使用的om工具是HAS V2.0包内的om工具压缩包,所以需要执行本步骤清理)。

rm -rf  Vastbase-G100-2.2_Buildxxx-xxx-om.tar.gz 
rm -rf  Vastbase-G100-2.2_Buildxxx-xxx-om.sha256

解压HAS V2.0安装包

步骤1 使用root用户对HAS V2.0安装包及其解压后得到的包进行解压,得到om和cm压缩包。(本步骤以centos7安装包为例)

tar -zxvf HAS_2.0@rxxx_centos7_x86-64_20230111.tar.gz
tar -zxvf Vastbase-HAS-2.0.x-centos7.6_x86_64bit.tar.gz

步骤2 将om和cm压缩包名修改为与Vastbase G100相同命名格式。

mv  Vastbase-HAS-2.0.x-xxx-om.tar.gz  Vastbase-G100-2.2_Buildxxx-xxx-om.tar.gz
mv  Vastbase-HAS-2.0.x-cm.tar.gz     Vastbase-G100-2.2_Buildxxx-xxx-cm.tar.gz

解压改名后示例如下图:

解压om安装脚本

解压改名后的om压缩包,会在当前目录下生成script子目录。

tar -zxvf Vastbase-G100-2.2_Buildxxx-xxx-om.tar.gz

执行预安装脚本

执行预安装脚本gs_preinstall可以协助自动完成如下的安装环境准备工作:

1、自动设置Linux内核参数以达到提高服务器负载能力的目的。这些参数直接影响数据库系统的运行状态,请仅在确认必要时调整。

2、自动将XML配置文件、安装包拷贝到其他主机的相同目录下,安装用户和用户组不存在时,自动创建安装用户以及用户组。

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

步骤1 以root用户进入script工具脚本目录。

cd /opt/software/script

步骤2 执行gs_preinstall预安装脚本。

./gs_preinstall -U vastbase -G dbgrp -X /opt/software/cluster_config.xml
  • vastbase为数据库管理员(也是运行Vastbase的操作系统用户),dbgrp为操作系统用户的群组名称。系统用户可以在预安装时指定创建。
  • -X指定的是XML配置文件的路径,配置文件详细信息参见配置文件
  • 在执行过程中,用户根据提示选择是否创建互信,并输入操作系统root用户和vastbase用户的密码。
  • 用户需要检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。

  • xml文件中各主机的名称与IP映射应配置正确。

  • 只能使用root用户执行gs_preinstall命令。

预安装过程如下所示:

Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Are you sure you want to create trust for root (yes/no)?yes
Please enter password for root
Password:
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
Distributing package.
Begin to distribute package to tool path.
Successfully distribute package to tool path.
Begin to distribute package to package path.
Successfully distribute package to package path.
Successfully distributed package.
Are you sure you want to create the user[vastbase] and create trust for it (yes/no)? yes
Preparing SSH service.
Successfully prepared SSH service.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [vastbase] user.
Please enter password for current user[vastbase].
Password:
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [vastbase] user.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
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/script/gs_checkos -i A -h Vastbase1,Vastbase2,Vastbase3 --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.

执行安装脚本

预安装脚本执行成功后,所有服务器操作系统和网络均正常运行,用户需确保各主机上locale保持一致后准备执行安装部署脚本。

步骤1 切换到vastbase用户,执行gs_install安装脚本,进行集群部署安装。

su - vastbase
gs_install -X /opt/software/cluster_config.xml --dn-guc="max_process_memory=10GB"
  • 执行安装脚本必须切换到vastbase用户(该用户为预安装脚本gs_preinstall中-U参数指定的用户)。
  • -X指定的是XML配置文件的路径,配置文件详细信息参见配置文件
  • 为保证数据库正常启动,max_process_memory参数必须配置为合适大小,OM工具安装完成默认数据库内核至少需要7G内存;也可以通过修改其他内存相关GUC参数,以减小内核所需max_process_memory大小。

步骤2 在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。

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

    • 最少包含8个字符。
    • 不能和用户名、当前密码(ALTER)、或当前密码反序相同。
    • 至少包含大写字母(A-Z)、小写字母(a-z)、数字、非字母数字字符(限定为~!@#$%^&*()-_=+\|[{}];:,<.>/?)四类字符中的三类字符。
  • 安装过程中会生成ssl证书,证书存放路径为:{gaussdbAppPath}/share/sslcert/om,其中{gaussdbAppPath}为配置文件中指定的程序安装目录。

安装过程如下所示:

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 ciper 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/gaussdb/cluster/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 DN nodes.
Successful check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Successfully started cluster.
Successfully installed application.

root用户互信可能会存在安全隐患,因此建议用户在执行完安装后,立即删除各主机上root用户的互信:

rm -rf ~/.ssh

配置示例

vi cluster_config.xml

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!--整体信息 -->
    <CLUSTER>
        <PARAM name="clusterName" value="Cluster_template" />
        <PARAM name="nodeNames" value="Vastbase1,Vastbase2,Vastbase3" />
        <PARAM name="gaussdbAppPath" value="/opt/vastbase/install/app" />
        <PARAM name="gaussdbLogPath" value="/var/log/omm" />
        <PARAM name="tmpMppdbPath" value="/opt/vastbase/tmp"/>
        <PARAM name="gaussdbToolPath" value="/opt/vastbase/install/om" />
        <PARAM name="corePath" value="/opt/vastbase/corefile"/>
        <PARAM name="backIp1s" value="172.16.105.54,172.16.105.58,172.16.105.60"/>

    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- node1上的节点部署信息 -->
        <DEVICE sn="Vastbase1">
            <PARAM name="name" value="Vastbase1"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="172.16.105.54"/>
            <PARAM name="sshIp1" value="172.16.105.54"/>
            <!--CM节点部署信息-->
            <PARAM name="cmsNum" value="1"/>
            <PARAM name="cmServerPortBase" value="15000"/>
            <PARAM name="cmServerListenIp1" value="172.16.105.54,172.16.105.58,172.16.105.60"/>
            <PARAM name="cmServerHaIp1" value="172.16.105.54,172.16.105.58,172.16.105.60"/>
            <PARAM name="cmServerlevel" value="1"/>
            <PARAM name="cmServerRelation" value="Vastbase1,Vastbase2,Vastbase3"/>
            <PARAM name="cmDir" value="/opt/vastbase/data/cmserver"/>
            <!--dn-->
            <PARAM name="dataNum" value="1"/>
                        <PARAM name="dataPortBase" value="15400"/>
                        <PARAM name="dataNode1" value="/opt/vastbase/install/data/dn,Vastbase2,/opt/vastbase/install/data/dn,Vastbase3,/opt/vastbase/install/data/dn"/>
            <PARAM name="dataNode1_syncNum" value="1"/>
        </DEVICE>

        <!-- node2上的节点部署信息,其中“name”的值配置为主机名称 -->
        <DEVICE sn="Vastbase2">
            <PARAM name="name" value="Vastbase2"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="172.16.105.58"/>
            <PARAM name="sshIp1" value="172.16.105.58"/>
            <!-- cm -->
            <PARAM name="cmServerPortStandby" value="15000"/>
            <PARAM name="cmDir" value="/opt/vastbase/data/cmserver"/>
        </DEVICE>

        <!-- node3上的节点部署信息,其中“name”的值配置为主机名称 -->
        <DEVICE sn="Vastbase3">
            <PARAM name="name" value="Vastbase3"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="172.16.105.60"/>
            <PARAM name="sshIp1" value="172.16.105.60"/>
            <!-- cm -->
            <PARAM name="cmServerPortStandby" value="15000"/>
            <PARAM name="cmDir" value="/opt/vastbase/data/cmserver"/>
        </DEVICE>
    </DEVICELIST>
</ROOT>