Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

openGauss 是一款高性能、高安全、高可靠的国产企业级开源关系型数据库,本文将在 openEuler 操作系统上部署安装并使用 openGauss 数据库。在本次实验中将以单节点形式部署(主要是多节点部署实在是占用资源啊等服务器空闲下来再说多节点部署罢)。

基础环境

服务端

  • openEuler 20.03 LTS SP3
    • 内核版本:4.19.90-2311.5.0.0228.oe1.x86_64
    • IP地址:192.168.142.130
    • 主机名:lxnchan-gausstester-node1.local
    • 安装配置文件:Minimal
    • 性能配置:4c8g200G
    • 启动方式:UEFI
  • openGauss 5.0.0 64bit
    • 操作系统分支:openEuler 20.03 LTS
    • 架构:x86_64
    • 版本:企业版

客户端

  • Windows 10 ProWorkstation
    • 版本:10.0.19045.2965
  • DBeaver
    • 版本:23.1.2.202307091549
    • 分支:Community

系统准备

因为我是本身就采用了openEuler 20.03版本的操作系统,所以本身不需要额外的准备,只需要安装官方手册中要求的依赖即可,其他操作系统还需要关注Python及相关组件的问题。

安装必要依赖:

1
2
dnf install libaio-devel flex bison ncurses-devel \
glibc-devel patch readline-devel libnsl -y

逐行执行一下下面的命令看看是否都能返回RemoveIPC=no不能是已注释状态(即返回的不能是#RemoveIPC=no):

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

然后确认一下SELinux和Firewalld是不是都关了:

1
2
3
4
5
6
7
[root@lxnchan-gausstester-node1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@lxnchan-gausstester-node1 ~]# getenforce
Disabled

到这里openEuler操作系统的准备基本就结束了,接下来就可以去官网下载安装包了,如果是RHEL(CentOS)的话还需要额外安装一些包,详情参见官方文档。

服务端安装

注意:本节中除非特殊提到否则所有命令使用root账户执行!并且所有目录结构与官方完全相同。

准备阶段

本节写了好多官方文档没写的坑!华为我×你仙人

  1. 改主机名
    1
    hostnamectl set-hostname lxnchan-gausstester-node1.local
    然后ping一下你设置的主机名,一般来说这个时候是ping不通的,改一下hosts:
    1
    2
    3
    127.0.0.1   localhost lxnchan-gausstester-node1.local localhost4 localhost4.localdomain4
    # 这里我IPv6的部分注释掉了,因为我发现开启IPv6好像有点问题
    #::1 localhost lxnchan-gausstester-node1.local localhost6 localhost6.localdomain6
    这个时候再ping应该就可以通了。
    然后再看一下/etc/hostname里面的回显是不是刚才设置的主机名:
    1
    2
    [root@lxnchan-gausstester-node1 ~]# cat /etc/hostname
    lxnchan-gausstester-node1.local
  2. 新建文件夹:
    1
    2
    3
    4
    5
    mkdir -p /var/log/omm
    mkdir -p /opt/huawei/tmp
    mkdir -p /opt/huawei/corefile
    mkdir -p /opt/software/openGauss
    chmod 755 -R /opt/software
  3. 把下载的安装包复制到/opt/software/openGauss
  4. 创建配置模板/opt/software/openGauss/cluster_config.xml,根据备注修改内容
    这里的示例模板是单节点配置文件,如需多节点部署请到官方文档获取。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
    <!-- 数据库名称,随便写 -->
    <PARAM name="clusterName" value="lxnchan-gauss" />
    <!-- 数据库节点名称(hostname) -->
    <PARAM name="nodeNames" value="lxnchan-gausstester-node1.local" />
    <!-- 数据库安装目录-->
    <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.142.130"/>
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
    <!-- 节点1上的部署信息 -->
    <DEVICE sn="lxnchan-gausstester-node1.local">
    <!-- 节点1的主机名称 -->
    <PARAM name="name" value="lxnchan-gausstester-node1.local"/>
    <!-- 节点1所在的AZ及AZ优先级 -->
    <PARAM name="azName" value="AZ1"/>
    <PARAM name="azPriority" value="1"/>
    <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
    <PARAM name="backIp1" value="192.168.142.130"/>
    <PARAM name="sshIp1" value="192.168.142.130"/>

    <!--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>
  5. 看一下你的libreadline在哪:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [root@lxnchan-gausstester-node1 lib64]# ldconfig -p | grep readline
    libreadline.so.8 (libc6,x86-64) => /lib64/libreadline.so.8
    libreadline.so (libc6,x86-64) => /lib64/libreadline.so
    libguilereadline-v-18.so.18 (libc6,x86-64) => /lib64/libguilereadline-v-18.so.18
    libguilereadline-v-18.so (libc6,x86-64) => /lib64/libguilereadline-v-18.so
    [root@lxnchan-gausstester-node1 lib64]# ls -la /lib64/ | grep readline
    lrwxrwxrwx. 1 root root 31 Jan 1 2022 libguilereadline-v-18.so -> libguilereadline-v-18.so.18.0.0
    lrwxrwxrwx. 1 root root 31 Jan 1 2022 libguilereadline-v-18.so.18 -> libguilereadline-v-18.so.18.0.0
    -rwxr-xr-x. 1 root root 51784 Jan 1 2022 libguilereadline-v-18.so.18.0.0
    -rw-r--r-- 1 root root 588194 Jan 1 2022 libreadline.a
    lrwxrwxrwx 1 root root 16 Jan 1 2022 libreadline.so -> libreadline.so.8
    lrwxrwxrwx. 1 root root 18 Jan 1 2022 libreadline.so.8 -> libreadline.so.8.0
    -rwxr-xr-x. 1 root root 326680 Jan 1 2022 libreadline.so.8.0
    然后做一下链接,不然在预安装阶段创建用户那块会报错
    1
    ln -s libreadline.so.8 libreadline.so.7
    然后再看一下有了就可以了
    1
    2
    [root@lxnchan-gausstester-node1 lib64]# ls -la /lib64/ | grep libreadline.so.7
    lrwxrwxrwx 1 root root 16 Dec 2 20:55 libreadline.so.7 -> libreadline.so.8
  6. 关闭大页(THP)
    首先查看THP状态:
    1
    2
    3
    4
    [root@lxnchan-gausstester-node1 script]# cat /sys/kernel/mm/transparent_hugepage/defrag
    always defer defer+madvise [madvise] never
    [root@lxnchan-gausstester-node1 script]# cat /sys/kernel/mm/transparent_hugepage/enabled
    [always] madvise never
    []框住的代表当前值,此处需要两个都是never
    /etc/rc.d/rc.local末尾加入如下命令:
    1
    2
    3
    4
    5
    6
    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
    /etc/rc.d/rc.local赋予可执行权限:
    1
    chmod +x /etc/rc.d/rc.local
    重载:
    1
    2
    systemctl daemon-reload
    systemctl restart rc-local.service
    再看一下THP状态:
    1
    2
    3
    4
    [root@lxnchan-gausstester-node1 script]# cat /sys/kernel/mm/transparent_hugepage/defrag
    always defer defer+madvise madvise [never]
    [root@lxnchan-gausstester-node1 script]# cat /sys/kernel/mm/transparent_hugepage/enabled
    always madvise [never]
    都是[never]就行了。

    这个地方应该是需要重启,如果这个地方回显被框住的不是never就手动执行一下上面rc.local追加命令的第2行和第4行即可。

  7. 检查一下安装环境
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    [root@lxnchan-gausstester-node1 script]# /opt/software/openGauss/script/gs_checkos -i A -h lxnchan-gausstester-node1.local --detail
    Checking items:
    A1. [ OS version status ] : Normal
    [lxnchan-gausstester-node1.local]
    openEuler_20.03_64bit
    A2. [ Kernel version status ] : Normal
    The names about all kernel versions are same. The value is "4.19.90-2311.5.0.0228.oe1.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 ] : Warning
    [lxnchan-gausstester-node1.local]
    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.
    A7. [ File system configuration status ] : Warning
    [lxnchan-gausstester-node1.local]
    Warning reason: variable 'open files' RealValue '1024' ExpectedValue '1000000'
    Warning reason: variable 'max user processes' RealValue '29501' ExpectedValue 'unlimited'
    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.
    BondMode Null
    A11.[ Network card configuration status ] : Warning
    [lxnchan-gausstester-node1.local]
    BondMode Null
    Warning reason: Failed to obtain the network card speed value. Commands for obtain the network card speed: /sbin/ethtool lo | grep 'Speed:'. Error:
    A12.[ Time consistency status ] : Warning
    [lxnchan-gausstester-node1.local]
    The NTPD not detected on machine and local time is "2023-12-02 21:14:57".
    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:4.
    可以有Warning但不能有Abnormal,如上Abnormal numbers为0即为通过。

锦上添花

也不能说叫锦上添花吧,这块主要是修一下上面Warning部分,测试环境不修也行,但是生产环境会有性能问题。

  1. A6-修改文件/etc/sysctl.conf
    1
    2
    3
    4
    5
    6
    7
    8
    9
    net.ipv4.tcp_retries1 = 5
    net.ipv4.tcp_syn_retries = 5
    net.ipv4.tcp_synack_retries = 5
    net.ipv4.ip_local_port_range = 26000-65535
    net.ipv4.tcp_fin_timeout = 60
    net.ipv4.tcp_sack = 1
    net.ipv4.tcp_timestamps = 1
    vm.extfrag_threshold = 500
    vm.overcommit_ratio = 90
  2. A7-文件系统配置
    不需要手动修复,预安装阶段会自动应用相关设置
  3. A11-获取不到网卡MTU
    这个无所谓。
  4. A12-找不到本地NTP服务器
    单节点部署不需要关注这个问题。

预安装阶段

  1. 进入到工具脚本目录下
    1
    cd /opt/software/openGauss/script
  2. 执行预安装脚本
    1
    ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
    回显:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    [root@lxnchan-gausstester-node1 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_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
    Preparing SSH service.
    Successfully prepared SSH service.
    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/openGauss/script/gs_checkos -i A -h lxnchan-gausstester-node1.local --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.
    最后出现Preinstallation succeeded.即意味着预安装阶段结束。

安装阶段

  1. 切换到omm用户,这个omm用户是刚才预安装阶段-U参数创建的用户,密码刚才创建的时候设置过,如果预安装阶段修改了这个用户名此处也要联动修改。
    1
    su - omm
  2. 执行安装命令:
    1
    gs_install -X /opt/software/openGauss/cluster_config.xml
    回显:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    [omm@lxnchan-gausstester-node1 ~]$ 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.
    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..
    最后返回Successfully即可,安装阶段结束。

验证与交付阶段

  1. 切换到omm用户
    1
    su - omm
  2. 查看运行状态:
    1
    gs_om -t status
    回显:
    1
    2
    3
    cluster_name    : lxnchan_openGauss
    cluster_state : Normal
    redistributing : No
    状态为Normal即意味着数据库正常。
  3. 数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。
    其中postgres为需要连接的数据库名称,15400为数据库主节点的端口号,即XML配置文件中的dataPortBase的值。请根据实际情况替换。
    1
    2
    3
    4
    5
    6
    [omm@lxnchan-gausstester-node1 ~]$ gsql -d postgres -p 15400
    gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:09:38 commit 0 last mr )
    Non-SSL connection (SSL connection is recommended when requiring high-security)
    Type "help" for help.

    openGauss=#
    输入\q退出。

交付内容

示例参数备注
IP地址192.168.142.130
端口号15400
用户omm密码
数据库密码

客户端连接

敬请期待。

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

中国互联网违法和不良信息举报中心

架构版本号:8.1.5 | 本站已全面支持IPv6

本站由又拍云提供CDN加速服务和存储服务

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

Copyright 2024 LingXuanNing, All rights reserved.