Location>code7788 >text

Most Detailed CentOS7.6 Install openGauss5.0.3 Tutorial

Popularity:258 ℃/2024-10-14 18:04:18

I. Environmental preparation

1.1 Host information

sports event element
operating system CentOS7.6
IP 192.168.4.201
hostname (of a networked computer) opgs201
CPU 8core
random access memory (RAM) 16GB
Disk 1 100GB

1.2 Operating system preparation

Creating a Virtual Machine

Installation of the operating system, select the installation with GUI

image

1.3 Preparing the installation environment

Installing python3

Install python3, because this new centos 7.6 does not come with python3, here I suggest installing python3.6 is enough!

Mount the CD-ROM iso first

## Mount the virtual machine's CD-ROM
mount /dev/cdrom /mnt
## Backup the original yum file
cd /etc/
mkdir bk
mv *.repo bk/
## Create a repo
echo "[EL]" >> /etc//
echo "name =" >> /etc//
echo "baseurl=file:///mnt" >> /etc//
echo "gpgcheck=0" >> /etc//
echo "enabled=1" >> /etc//

You can refer to this article of mine

Checking software dependencies

Once installed, install the following dependencies needed by openGauss (some were installed during the python3 installation above)

yum install -y lksctp*
yum install -y java-1.8.0-openjdk* 
yum install -y psmisc 
yum install -y bzip2 
yum install -y libaio-devel 
yum install -y flex  bison ncurses-devel glibc-devel  patch  readline-devel  redhat-lsb-core libnsl

Configuring hosts

echo "192.168.4.201 opgs201" >> /etc/hosts

Turn off firewalls and other configurations

systemctl disable 
systemctl stop 

sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
cat /etc/selinux/config|grep SELINUX=

Modifying Character Set Parameters

echo "export LANG=en_US.UTF-8" >> /etc/profile

source /etc/profile

Setting up remote login for the root user

This can be done quickly using a script

sed -i '/PermitRootLogin/s/^/#/' /etc/ssh/sshd_config
sed -i '/Banner/s/^/#/' /etc/ssh/sshd_config
echo -e "\n" >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "Banner none " >> /etc/ssh/sshd_config
systemctl restart 

Setting the time zone and time

In production environments you can use NTP or chrony to synchronize the server's time

rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Turn off swap (optional)

Turning off swap improves performance

sed -i '/swap/s/^/#/' /etc/fstab
cat /etc/fstab
swapoff -a

Modify system kernel parameters

cat >> /etc/ << EOF
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_fin_timeout = 60
EOF

sysctl -p

Close Transparent Page

Temporary closure of transparent pages

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

Write it to the startup file to make it permanent

cat >> /etc// <<EOF
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
EOF
##go into effect
chmod +x /etc//

Modify the startup level

This step is optional

systemctl set-default 

All configured at once

yum install -y lksctp*
yum install -y java-1.8.0-openjdk*
yum install -y psmisc
yum install -y bzip2
yum install -y libaio-devel
yum install -y flex bison ncurses-devel glibc-devel patch readline-devel redhat-lsb-core libnsl
echo "192.168.4.201 opgs201" >> /etc/hosts
systemctl disable
systemctl stop
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
echo "export LANG=en_US.UTF-8" >> /etc/profile
source /etc/profile
sed -i '/PermitRootLogin/s/^/#/' /etc/ssh/sshd_config
sed -i '/Banner/s/^/#/' /etc/ssh/sshd_config
echo -e "\n" >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "Banner none " >> /etc/ssh/sshd_config
systemctl restart
rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sed -i '/swap/s/^/#/' /etc/fstab
swapoff -a
cat >> /etc/ << EOF
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_fin_timeout = 60
EOF
sysctl -p
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

cat >> /etc// <<EOF
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
EOF
##go into effect
chmod +x /etc//
systemctl set-default
echo -e "\n"

reopen

reboot

Second, the installation of openGauss5.0 database

2.1 Pre-installation preparation

Create relevant directories and users

Here we start by creating users and groups manually

groupadd dbgrp
useradd -g dbgrp omm
### The password Gauss@1234 requires a certain level of sophistication.
echo Gauss@1234 | passwd --stdin omm

Create a catalog

## Place the package directory
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software/openGauss

## openGauss database directory, note that you need to keep the directory empty, otherwise the installation will be wrong
##
mkdir -p /openGauss/
chmod -R 755 /openGauss
chown -R omm:dbgrp /openGauss/

Upload and unzip the installation package

Upload the installation package to the /opt/software/openGauss/ directory and unzip it.

/opt/software/openGauss/
tar -zxvf openGauss-5.0.
tar -zxvf openGauss-5.0.

Example:

[root@opgs201 ~]# cd /opt/software/openGauss/
[root@opgs201 openGauss]# tar -zxvf openGauss-5.0.
openGauss-5.0.
openGauss-5.0.
openGauss-5.0..bz2
openGauss-5.0.3-CentOS-64bit-cm.sha256
openGauss-5.0.3-CentOS-64bit-om.sha256
openGauss-5.0.3-CentOS-64bit.sha256
upgrade_sql.
upgrade_sql.sha256

Unzipped, there are these files

[root@opgs201 soft]# ls -l
total 264712
-rw-r--r-- 1 root root 134969411 Oct  9 23:42 openGauss-5.0.
-rw-r--r-- 1 root root       105 Jul 31 21:15 openGauss-5.0.3-CentOS-64bit-cm.sha256
-rw-r--r-- 1 root root  22528084 Jul 31 21:15 openGauss-5.0.
-rw-r--r-- 1 root root        65 Jul 31 21:14 openGauss-5.0.3-CentOS-64bit-om.sha256
-rw-r--r-- 1 root root  11973852 Jul 31 21:14 openGauss-5.0.
-rw-r--r-- 1 root root        65 Jul 31 21:15 openGauss-5.0.3-CentOS-64bit.sha256
-rw-r--r-- 1 root root 101064032 Jul 31 21:15 openGauss-5.0..bz2
-rw------- 1 root root        65 Jul 31 21:13 upgrade_sql.sha256
-rw------- 1 root root    502230 Jul 31 21:13 upgrade_sql.

Unzip this inside again

[root@opgs201 openGauss]# tar -zxvf openGauss-5.0.

Preparing XML files

I have a single node in this, so prepare the single node xml, where is this file paired?

In the software directory

cd /opt/software/openGauss/
vi cluster_config.xml

Or just cat

cat >> /opt/software/openGauss/cluster_config.xml << EOF
<?xml version="1.0" encoding="UTF-8"? EOF <;xml version="1.0" encoding="UTF-8"?
<ROOT>.
    <CLUSTER>.
        <PARAM name="clusterName" value="dbCluster" />!
        <! -- Enter your own hostname here -->
        <;PARAM name="nodeNames" value="opgs201" />
        <! -- Database installation directory -->
        <;PARAM name="gaussdbAppPath" value="/openGauss/app" />
        <! -- log directory -- >
        <PARAM name="gaussdbLogPath" value="/openGauss/log/omm" />!
        <! -- Temporary file directory ->
        < PARAM name="tmpMppdbPath" value="/openGauss/tmp" />
        <! -- database tools directory -- >
        < PARAM name="gaussdbToolPath" value="/openGauss/om" />
        <! -- Database core file directory -->
        <PARAM name="corePath" value="/openGauss/corefile" />;
        <! -- Node IPs, corresponding to the list of database node names -->
        <PARAM name="backIp1s" value="192.168.4.201" />
    </CLUSTER>
    <! -- Node deployment information on each server -->.
    <DEVICELIST>.
        <! -- Deployment information on node 1 --> <!
        <DEVICE sn="node1_hostname">;
            <! -- Hostname of node1 --> <!
            <PARAM name="name" value="opgs201"/>;
            <! -- AZ and AZ priority where node 1 is located -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <! -- IP of node 1, if the server has only one NIC available, configure backIP1 and sshIP1 as the same IP -->!
            <PARAM name="backIp1" value="192.168.4.201"/>
            <PARAM name="sshIp1" value="192.168.4.201"/>

<! --dbnode-->
<PARAM name="dataNum" value="1"/>
< PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/openGauss/data/dn"/> <PARAM name="dataNode1" value="/openGauss/data/dn"/>
            <PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>
    </DEVICELIST>
</ROOT>.
EOF

Look at this.

2.2 Installation of the openGauss database

Execute preinstall

Go to the script directory

There's a lot of scripts in there.

[root@opgs201 soft]# cd script/
[root@opgs201 script]# ./gs
gs_backup         gs_checkperf      gs_expansion      gs_postuninstall  gs_sdr            gs_uninstall
gs_check          gs_collector      gs_install        gs_preinstall     gs_ssh            gs_upgradectl
gs_checkos        gs_dropnode       gs_om             gspylib/          gs_sshexkey
[root@opgs201 script]# ls
base_diff     gs_check      gs_expansion      gspylib       gs_upgradectl  os_platform   ssh-agent
base_utils    gs_checkos    gs_install        gs_sdr        impl           py_pstree.py  ssh-copy-id
config        gs_checkperf  gs_om             gs_ssh        __init__.py    scp           ssh-keygen
domain_utils  gs_collector  gs_postuninstall  gs_sshexkey   killall        ssh           
gs_backup     gs_dropnode   gs_preinstall     gs_uninstall  local          ssh-add

Execute one of the gs_preinstall check scripts

[root@opgs201 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 opgs201 --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.
[root@opgs201 script]#

Perform the installation with the om user

Now that you have an om user, the program writes to the environment variable

[root@opgs201 script]# su - omm
Last login: Sun Oct 13 08:45:28 CST 2024
[omm@opgs201 ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export GPHOME=/openGauss/om
export PATH=$GPHOME/script/gspylib/pssh/bin:$GPHOME/script:$PATH
export LD_LIBRARY_PATH=$GPHOME/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$GPHOME/lib
export GAUSSHOME=/openGauss/app
export PATH=$GAUSSHOME/bin:$PATH
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export S3_CLIENT_CRT_FILE=$GAUSSHOME/lib/
export GAUSS_VERSION=5.0.3
export PGHOST=/openGauss/tmp
export GAUSSLOG=/openGauss/log/omm/omm
umask 077
export GAUSS_ENV=1

Installation with the om user

[omm@opgs201 ~]$ 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 /openGauss/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..

2.3 Post-installation inspection

echo "export PGDATABASE=postgres" >> ~/.bashrc、
echo "export PGDATA=/openGauss/data/dn" >> ~/.bashrc
echo "export PGPORT=15400" >> ~/.bashrc
echo "alias gsql='gsql -r'" >> ~/.bashrc
echo "alias dba='gsql -d postgres -p 15400'" >> ~/.bashrc

source ~/.bash_profile

Execute the gsql command and you're in.

[omm@opgs201 ~]$ dba
gsql ((openGauss 5.0.3 build 89d144c2) compiled at 2024-07-31 20:59:31 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# select version();
                                                                       version

---------------------------------------------------------------------------------------------------------------------------------------
---------------
 (openGauss 5.0.3 build 89d144c2) compiled at 2024-07-31 20:59:31 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC)
 7.3.0, 64-bit
(1 row)

2.4 Simple management of the database

Start-Stop Database

cessation

[omm@opgs201 ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.