OP-openGauss01-基于OpenEuler22.03 (LTS-SP4)部署

环境规划系统环境配置

友情提示

 主机名以及网卡配置文件修改

下述中我们在网卡配置文件中添加了一段内容为“MTU=0”,这是因为openGauss在部署时建议MTU值为8192,否则在部署过程中会出现警告

[root@openguass-node1 ~]# hostnamectl  set-hostname opengauss-node1 && bash


Welcome to 5.10.0-216.0.0.115.oe2203sp4.x86_64

System information as of time: 	Sun Sep  8 06:17:05 PM CST 2024

System load: 	0.00
Memory used: 	9.3%
Swap used: 	0.0%
Usage On: 	11%
IP address: 	192.168.18.137
Users online: 	2


[root@opengauss-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 
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=a57fa1ff-ddc0-48d8-aec5-e209e10611de
DEVICE=ens33
ONBOOT=yes
MTU="8192"
[root@opengauss-node1 ~]# 

用户与用户组创建

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

防火墙与SELINUX关闭

[root@opengauss-node1 ~]# systemctl  disable --now firewalld.service
[root@opengauss-node1 ~]# systemctl  status firewalld.service
○ 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@opengauss-node1 ~]# 

 setenforce 0命令的作用为临时关闭我们的SELINUX,如果我们只修改配置文件只会在重启之后生效,执行此命令后则可以在部署过程中无需重启

[root@opengauss-node1 ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@opengauss-node1 ~]# setenforce 0
setenforce: SELinux is disabled

系统优化

关闭swap交换内存

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

[root@opengauss-node1 ~]# swapoff -a 
[root@opengauss-node1 ~]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           7.2Gi       2.5Gi       3.3Gi       771Mi       3.3Gi       4.7Gi
Swap:             0B          0B          0B
[root@opengauss-node1 ~]# 

设置操作系统字符集

[root@opengauss-node1 ~]# cat /etc/profile
# /etc/profile
....................................

# Source global bash config, when interactive but not posix or sh mode
if test "$BASH" &&\
   test -z "$POSIXLY_CORRECT" &&\
   test "${0#-}" != sh &&\
   test -r /etc/bashrc
then
   # Bash login shells run only /etc/profile
   # Bash non-login shells run only /etc/bashrc
   # Check for double sourcing is done in /etc/bashrc.
   . /etc/bashrc
fi

export LANG=en_US.UTF-8
[root@opengauss-node1 ~]# 

操作系统参数设置

[root@opengauss-node1 ~]# echo net.ipv4.tcp_retries1 = 5 >>/etc/sysctl.conf
[root@opengauss-node1 ~]# 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
[root@node0 script]# echo "* soft nofile 1000000" >>/etc/security/limits.conf
[root@node0 script]# echo "* hard nofile 1000000" >>/etc/security/limits.conf
[root@opengauss-node1 ~]# 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) 29481
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
[root@opengauss-node1 ~]# 

软件安装

基础软件包安装

[root@opengauss-node1 ~]# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel readline-devel libnsl libaio-devel vim net-tools  ntp
 
[root@opengauss-node1 ~]# systemctl enable --now ntpd 
Created symlink /etc/systemd/system/multi-user.target.wants/ntpd.service → /usr/lib/systemd/system/ntpd.service.
 
[root@opengauss-node1 ~]# timedatectl set-timezone Asia/Shanghai
[root@opengauss-node1 ~]# timedatectl set-ntp yes
[root@opengauss-node1 ~]# timedatectl  status 
               Local time: Sun 2024-09-08 18:37:55 CST
           Universal time: Sun 2024-09-08 10:37:55 UTC
                 RTC time: Sun 2024-09-08 10:37:56
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
[root@opengauss-node1 ~]# hwclock --systohc
[root@opengauss-node1 ~]# hwclock 
2024-09-08 18:38:26.994386+08:00

opengauss安装

创建目录上传安装包

此处我采用的是XSHELL配套软件XFTP工具上传的,如不知道如何操作,可自行百度上传文件到LINUX教程

[root@opengauss-node1 ~]# mkdir  -p /opt/software/opengauss/ && chmod -R 755 /opt/software/opengauss/

[root@opengauss-node1 ~]# ls -al /opt/software/opengauss/
total 470208
drwxr-xr-x  5 omm  dbgrp      4096 Sep  8 17:35 .
-rwx------  1 omm  dbgrp 151532247 Sep  8 17:12 openGauss-6.0.0-RC1-openEuler-64bit-all.tar.gz

解压安装包

[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
...........

创建XML文件

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

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

初始化操作

正常来说,我们前面的操作对我们的系统进行了一些列的初始化与优化操作,此时可以正常的进行数据库安装初始化;但是天有不测风云,如果此步出现警告,请通过/opt/software/openGauss/script/gs_checkos -i A -h 此处填节点名字 --detail查询报错原因,自行百度解决

[root@node0 openGauss]# cd /opt/software/openGauss/script
[root@node0 script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/opengauss/cluster_config.xml

执行安装

# 切换至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:  2024年 09月 08日 星期四 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.18.137
Users online:   3
To run a command as administrator(user "root"),use "sudo <command>".
[root@node0 openGauss]$ 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..

安装完成验证

[root@node0 openGauss]$ 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.18.137
[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=#
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值