【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)

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

创建用户和用户组

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

  • 用户组:dbgrp

[root@node0 ~]# groupadd dbgrp
  • 用户:omm

[root@node0 ~]# useradd -g dbgrp omm
[root@node0 ~]#
[root@node0 ~]# echo 'omm!666' | passwd --stdin omm
Changing password for user omm.
passwd: all authentication tokens updated successfully.
[root@node0 ~]#
[root@node0 ~]# id omm
uid=1001(omm) gid=1001(dbgrp) groups=1001(dbgrp)

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

创建目录

以root用户登录待安装openGauss的主机,并按规划创建存放安装包的目录。
不建议把安装包的存放目录规划到openGauss用户的根目录或其子目录下,可能导致权限问题。
openGauss用户须具有/opt/software/openGauss目录的读写权限。

[root@node0 ~]# mkdir -p /opt/software/openGauss
[root@node0 ~]# chmod 755 -R /opt/software

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

上传安装包

将安装包openGauss-5.0.0-openEuler-64bit-all.tar.gz上传至所创建的/opt/software/openGauss目录中

[root@node0 openGauss]# pwd
/opt/software/openGauss
[root@node0 openGauss]# ll
total 129824
-rw-r--r-- 1 root root 132936681 Jul 20 22:56 openGauss-5.0.0-openEuler-64bit-all.tar.gz
[root@node0 openGauss]#

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

解压安装包

[root@node0 openGauss]# tar -zxvf openGauss-5.0.0-openEuler-64bit-all.tar.gz
openGauss-5.0.0-openEuler-64bit-cm.tar.gz
openGauss-5.0.0-openEuler-64bit-om.tar.gz
openGauss-5.0.0-openEuler-64bit.tar.bz2
openGauss-5.0.0-openEuler-64bit-cm.sha256
openGauss-5.0.0-openEuler-64bit-om.sha256
openGauss-5.0.0-openEuler-64bit.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256
[root@node0 openGauss]#
[root@node0 openGauss]# tar -zxvf openGauss-5.0.0-openEuler-64bit-om.tar.gz
./lib/
./lib/_cffi_backend.so
./lib/six.py
./lib/paramiko/
./lib/paramiko/proxy.py
./lib/paramiko/pipe.py
......

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

创建xml文件

  • 单节点配置文件

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
        <!-- 数据库名称 -->
        <PARAM name="clusterName" value="dbCluster" />
        <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="node0" />
        <!-- 数据库安装目录-->
        <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.192.129"/>
    </CLUSTER>
    <!-- 每台服务器上的节点部署信息 -->
    <DEVICELIST>
        <!-- 节点1上的部署信息 -->
        <DEVICE sn="node1_hostname">
            <!-- 节点1的主机名称 -->
            <PARAM name="name" value="node0"/>
            <!-- 节点1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.192.129"/>
            <PARAM name="sshIp1" value="192.168.192.129"/>

            <!--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>

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

执行安装

采用交互模式执行预安装脚本

  • 进入script目录

[root@node0 openGauss]# cd /opt/software/openGauss/script
  • 执行初始化安装

[root@node0 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
  • 打印信息

/opt/software/openGauss/script/domain_utils/sql_handler/../../../lib/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
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 node0 --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.

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

警告信息处理

查看详情

[root@node0 script]# /opt/software/openGauss/script/gs_checkos -i A -h node0 --detail

A6警告信息

A6. [ System control parameters status ] : Warning

# 操作系统参数设置
[root@node0 ~]# echo net.ipv4.tcp_retries1 = 5 >>/etc/sysctl.conf
[root@node0 ~]# echo net.ipv4.tcp_syn_retries = 5 >>/etc/sysctl.conf

# 使参数生效
[root@node0 ~]# sysctl -p
kernel.sysrq = 0
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_syncookies = 1
kernel.dmesg_restrict = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries2 = 12
net.ipv4.ip_local_reserved_ports = 15400-15407,20050-20057
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
kernel.sem = 250 6400000 1000 25600
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
vm.min_free_kbytes = 172879
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.somaxconn = 65535
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

A7警告信息

A7. [ File system configuration status ] : Warning

[root@node0 script]# ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 13365
max locked memory           (kbytes, -l) 65536
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1000000
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 13365
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

[root@node0 script]# echo "* soft nofile 1000000" >>/etc/security/limits.conf
[root@node0 script]# echo "* hard nofile 1000000" >>/etc/security/limits.conf

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

重新打开一个会话窗口

[root@node0 ~]# ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 13365
max locked memory           (kbytes, -l) 65536
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1000000
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) unlimited
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

A11警告信息

A11.[ Network card configuration status ] : Warning

[root@node0 ~]# cd /etc/sysconfig/network-scripts/
[root@node0 network-scripts]# vi ifcfg-ens33

在文末追加 MTU=“8192”,重启生效。

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=3d97d676-8b1d-4639-b5b9-1094c543fc37
DEVICE=ens33
ONBOOT=yes

MTU="8192"

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

A12警告信息

A12.[ Time consistency status ] : Warning

  • 查看ntp状态,发现ntp没有启动

[root@node0 script]# systemctl status ntpd
○ ntpd.service - Network Time Service
     Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
     Active: inactive (dead)
  • 启动ntp服务

[root@node0 script]# systemctl start ntpd
[root@node0 script]#

# 查看ntp状态
[root@node0 script]# systemctl status ntpd
● ntpd.service - Network Time Service
     Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
     Active: active (running) since Thu 2023-07-20 23:39:09 CST; 9s ago
    Process: 2269 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 2271 (ntpd)
      Tasks: 2 (limit: 21384)
     Memory: 1.7M
     CGroup: /system.slice/ntpd.service
             └─ 2271 /usr/sbin/ntpd -u ntp:ntp -g

Jul 20 23:39:09 node0 ntpd[2271]: Listen and drop on 0 v6wildcard [::]:123
Jul 20 23:39:09 node0 ntpd[2271]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jul 20 23:39:09 node0 ntpd[2271]: Listen normally on 2 lo 127.0.0.1:123
Jul 20 23:39:09 node0 ntpd[2271]: Listen normally on 3 ens33 192.168.192.129:123
Jul 20 23:39:09 node0 ntpd[2271]: Listen normally on 4 lo [::1]:123
Jul 20 23:39:09 node0 ntpd[2271]: Listen normally on 5 ens33 [fe80::20c:29ff:fe0f:5e3f%2]:123
Jul 20 23:39:09 node0 ntpd[2271]: Listening on routing socket on fd #22 for interface updates
Jul 20 23:39:09 node0 ntpd[2271]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Jul 20 23:39:09 node0 ntpd[2271]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Jul 20 23:39:09 node0 systemd[1]: Started Network Time Service.
  • 查看ntp状态,如果发现ntp没有安装

       ○  安装ntp服务

       ○  启动ntp服务

重新执行初始化安装

  • 进入script目录

[root@node0 openGauss]# cd /opt/software/openGauss/script
  • 执行初始化安装

[root@node0 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.
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.

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

无警告信息

执行安装

# 切换至omm用户
[root@node0 script]# su - omm
Last login: Thu Jul 20 23:45:39 CST 2023


Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64

System information as of time:  2023年 07月 20日 星期四 23:47:15 CST

System load:    0.09
Processes:      176
Memory used:    6.6%
Swap used:      0.0%
Usage On:       6%
IP address:     192.168.192.129
Users online:   3
To run a command as administrator(user "root"),use "sudo <command>".
[omm@node0 ~]$

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

# 执行安装
# gs_install -X /opt/software/openGauss/cluster_config.xml --gsinit-parameter="--locale=en_US.utf8"
# 此处密码设置为:openGauss!666

[omm@node0 ~]$ gs_install -X /opt/software/openGauss/cluster_config.xml --gsinit-parameter="--locale=en_US.utf8"
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..

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

安装验证

查看数据库启动状态

通过openGauss提供的gs_om工具可以完成数据库状态检查
以omm用户身份登录服务器
检查数据库状态是否正常

[omm@node0 ~]$ gs_om -t status --detail
[   Cluster State   ]

cluster_state   : Normal
redistributing  : No
current_az      : AZ_ALL

[  Datanode State   ]

    node node_ip         port      instance                            state
--------------------------------------------------------------------------------------------
1  node0 192.168.192.129 15400      6001 /opt/huawei/install/data/dn   P Primary Normal
  • 服务器IP地址:192.168.192.129
  • 数据库的端口号:15400
  • 数据库数据路径:/opt/huawei/install/data/dn
  • P:安装时指定的角色为Primary
  • Primary:实例为主实例
  • Normal:openGauss可用

【我和openGauss的故事】记录在openEuler-22.03中安装openGauss_5.0.0企业版(下篇)-鸿蒙开发者社区

登录数据库

数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。

[omm@node0 ~]$ gsql -d postgres -p 15400
gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:37:13 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# \l
                             List of databases
   Name    | Owner | Encoding |  Collate   |   Ctype    | Access privileges
-----------+-------+----------+------------+------------+-------------------
 postgres  | omm   | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | omm   | UTF8     | en_US.utf8 | en_US.utf8 | =c/omm           +
           |       |          |            |            | omm=CTc/omm
 template1 | omm   | UTF8     | en_US.utf8 | en_US.utf8 | =c/omm           +
           |       |          |            |            | omm=CTc/omm
(3 rows)

openGauss=# select sysdate;
       sysdate
---------------------
 2023-07-20 23:57:28
(1 row)

openGauss=#
  • postgres:openGauss安装完成后默认生成的数据库。初始可以连接到此数据库进行新数据库的创建。
  • 15400:数据库主节点的端口号





文章转载自公众号:openGauss

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