目录
安装前准备
这里要准备三个部分,服务器(OS已安装好)+数据库安装包+依赖的软件。
服务器
首先找小伙伴申请了华为云服务器安装好了OS,这里使用的是x86_64+openEuler 20.03LTS。你要是没有这么给力的小伙伴就自己亲力亲为吧~ 华为云服务器现在可是很划算呢,安装也很方便。
[root@pekphisprb70593 ~]# cat /etc/os-release
NAME="openEuler"
VERSION="20.03 (LTS)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS)"
ANSI_COLOR="0;31"
数据库安装包
1、1.通过https://opengauss.org/zh/download.html登录openGauss开源社区,选择3.0.0版本对应平台企业版安装包。
下载后这样的 :
2、先上传到服务器/opt目录下。
[root@pekphisprb70596 ~]# cd /opt/
[root@pekphisprb70596 opt]# ll
total 112M
drwxr-xr-x 4 root root 4.0K May 12 2019 eops_agent_update
-rw------- 1 root root 112M May 6 11:21 openGauss-3.0.0-openEuler-64bit-all.tar.gz
drwxr-xr-x. 4 root root 4.0K Apr 10 2020 patch_workspace
3、新建个openGauss文件夹,再把安装包给他挪进去。
[root@pekphisprb70596 opt]# mkdir openGauss
[root@pekphisprb70596 opt]# mv openGauss-3.0.0-openEuler-64bit-all.tar.gz openGauss
[root@pekphisprb70596 opt]# ll
total 12K
drwxr-xr-x 4 root root 4.0K May 12 2019 eops_agent_update
drwx------ 2 root root 4.0K May 6 11:24 openGauss
drwxr-xr-x. 4 root root 4.0K Apr 10 2020 patch_workspace
[root@pekphisprb70596 opt]# cd openGauss/
[root@pekphisprb70596 openGauss]# ll
total 112M
-rw------- 1 root root 112M May 6 11:21 openGauss-3.0.0-openEuler-64bit-all.tar.gz
4、解压数据库安装包,检查安装目录及文件是否齐全。另外设置下系统超时时间,不要断连。
[root@pekphisprb70596 openGauss]# tar -zxvf openGauss-3.0.0-openEuler-64bit-all.tar.gz
openGauss-3.0.0-openEuler-64bit-cm.tar.gz
openGauss-3.0.0-openEuler-64bit-om.tar.gz
openGauss-3.0.0-openEuler-64bit.tar.bz2
openGauss-3.0.0-openEuler-64bit-cm.sha256
openGauss-3.0.0-openEuler-64bit-om.sha256
openGauss-3.0.0-openEuler-64bit.sha256
upgrade_sql.tar.gz
upgrade_sql.sha256
[root@pekphisprb70596 openGauss]# ls -lb
total 230068
-rw------- 1 root root 117337040 May 6 11:21 openGauss-3.0.0-openEuler-64bit-all.tar.gz
-rw------- 1 root root 108 Apr 1 18:25 openGauss-3.0.0-openEuler-64bit-cm.sha256
-rw------- 1 root root 6246780 Apr 1 18:25 openGauss-3.0.0-openEuler-64bit-cm.tar.gz
-rw------- 1 root root 65 Apr 1 18:24 openGauss-3.0.0-openEuler-64bit-om.sha256
-rw------- 1 root root 14243915 Apr 1 18:24 openGauss-3.0.0-openEuler-64bit-om.tar.gz
-rw------- 1 root root 65 Apr 1 18:25 openGauss-3.0.0-openEuler-64bit.sha256
-rw------- 1 root root 97338206 Apr 1 18:25 openGauss-3.0.0-openEuler-64bit.tar.bz2
-rw------- 1 root root 65 Apr 1 18:23 upgrade_sql.sha256
-rw------- 1 root root 385605 Apr 1 18:23 upgrade_sql.tar.gz
[root@pekphisprb70596 openGauss]# set TMOUT=0
依赖的软件
1、按照官方文档进行软件的检查。跟我相同OS的就可以跳过该检查,直接下一步。
[root@pekphisprb70596 openGauss]# rpm -qa | grep flex
flex-2.6.1-13.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep libaio
libaio-0.3.111-5.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep bison
bison-3.5-2.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep ncurses
ncurses-libs-6.1-14.oe1.x86_64
ncurses-base-6.1-14.oe1.noarch
ncurses-6.1-14.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep glibc-devel
glibc-devel-2.28-36.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep patch
patchutils-0.3.4-13.oe1.x86_64
patch-2.7.6-12.oe1.x86_64
kpatch-2.0-3.1.26.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep redhat
[root@pekphisprb70596 openGauss]# rpm -qa | grep readline
readline-7.0-13.oe1.x86_64
[root@pekphisprb70596 openGauss]# rpm -qa | grep libnsl
libnsl2-1.2.0-4.oe1.x86_64
[root@pekphisprb70596 openGauss]#
表1 软件依赖要求
所需软件 | 建议版本 | 是否满足需求 |
---|---|---|
libaio-devel | 0.3.109-13及以上 | Y |
flex | 2.5.31 以上 | Y |
bison | 2.7-4及以上 | Y |
ncurses-devel | 5.9-13.20130511及以上 | Y |
glibc-devel | 2.17-111及以上 | Y |
patch | 2.7.1-10及以上 | Y |
redhat-lsb-core | 4.1及以上 | N |
readline-devel | 7.0-13及以上 | Y |
libnsl(openEuler+x86环境中) | 2.28-36及以上 | N |
有的软件不存在。
openEuler没有的软件就自己安装下:libnsl 和expect(这个虽然没有在官方文档表格里,但是我执行预安装的时候报错了,又重新装了下,所以在这加上 )。
[root@pekphisprb70596 openGauss]# yum install -y libnsl
Last metadata expiration check: 1:00:07 ago on Fri 06 May 2022 01:19:23 PM CST.
Dependencies resolved.
=================================================================================================================================================================================
Package Architecture Version Repository Size
=================================================================================================================================================================================
Installing:
libnsl x86_64 2.28-36.oe1 openEuler-everything 45 k
Transaction Summary
=================================================================================================================================================================================
Install 1 Package
Total download size: 45 k
Installed size: 94 k
Downloading Packages:
libnsl-2.28-36.oe1.x86_64.rpm 377 kB/s | 45 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 374 kB/s | 45 kB 00:00
warning: /var/cache/dnf/openEuler-everything-700adfe3849a3adc/packages/libnsl-2.28-36.oe1.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID b25e7f66: NOKEY
openEuler-everything 35 kB/s | 2.1 kB 00:00
Importing GPG key 0xB25E7F66:
Userid : "private OBS (key without passphrase) <defaultkey@localobs>"
Fingerprint: 12EA 74AC 9DF4 8D46 C69C A0BE D557 065E B25E 7F66
From : http://mirrors.tools.huawei.com/openeuler/openEuler-20.03-LTS/everything/x86_64/RPM-GPG-KEY-openEuler
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libnsl-2.28-36.oe1.x86_64 1/1
Running scriptlet: libnsl-2.28-36.oe1.x86_64 1/1
Verifying : libnsl-2.28-36.oe1.x86_64 1/1
Installed:
libnsl-2.28-36.oe1.x86_64
Complete!
[root@pekphisprb70596 openGauss]# rpm -qa | grep libnsl
libnsl-2.28-36.oe1.x86_64
libnsl2-1.2.0-4.oe1.x86_64
[root@pekphisprb70596 openGauss]#
[root@opengauss1 script]# yum install -y except
Last metadata expiration check: 0:16:59 ago on Fri 06 May 2022 05:13:31 PM CST.
No match for argument: except
Error: Unable to find a match: except
[root@opengauss1 script]# yum install -y expect
Last metadata expiration check: 0:17:13 ago on Fri 06 May 2022 05:13:31 PM CST.
Dependencies resolved.
=================================================================================================================================================================================
Package Architecture Version Repository Size
=================================================================================================================================================================================
Installing:
expect x86_64 1:5.45.4-3.oe1 openEuler-os 237 k
Transaction Summary
=================================================================================================================================================================================
Install 1 Package
Total download size: 237 k
Installed size: 648 k
Downloading Packages:
expect-5.45.4-3.oe1.x86_64.rpm 1.4 MB/s | 237 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.3 MB/s | 237 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : expect-1:5.45.4-3.oe1.x86_64 1/1
Running scriptlet: expect-1:5.45.4-3.oe1.x86_64 1/1
Verifying : expect-1:5.45.4-3.oe1.x86_64 1/1
Installed:
expect-1:5.45.4-3.oe1.x86_64
Complete!
redhat-lsb-core安装失败,openEuler没有这个,跳过。暂时没发现有啥影响。
修改操作系统配置
目前仅支持在防火墙关闭的状态下进行安装。
修改操作系统配置
1、修改/etc/selinux/config文件中的“SELINUX”值为“disabled”。openEuler操作系统默认为关闭,可以跳过该步骤。
使用VIM打开config文件。
vi /etc/selinux/config
查看“SELINUX”的值是否为“disabled”。是的话直接下一步。不是的话修改“SELINUX”的值“disabled”,执行:wq保存并退出修改,然后reboot重启。
2、检查防火墙是否关闭。若防火墙状态显示为inactive (dead),直接下一步。openEuler操作系统默认为关闭,可以跳过该步骤。
systemctl status firewalld
若防火墙状态显示为active (running),则表示防火墙未关闭,请关闭防火墙。
systemctl disable firewalld.service
systemctl stop firewalld.service
3、将各数据库节点的字符集设置为相同的字符集,可以在/etc/profile文件中添加“export LANG=en_US.UTF-8”(也可以设置成GBK,看你习惯用啥)。
4、在各数据库节点上,使用swapoff -a命令将交换内存关闭。
swapoff -a
5、修改/etc/systemd/logind.conf的“RemoveIPC”的值“no”,前面的#也删掉。
6、重新加载参数并检查。
[root@pekphisprb70594 ~]# systemctl daemon-reload
[root@pekphisprb70594 ~]# systemctl restart systemd-logind
[root@pekphisprb70594 ~]# loginctl show-session | grep RemoveIPC
RemoveIPC=no
[root@pekphisprb70594 ~]# systemctl show systemd-logind | grep RemoveIPC
RemoveIPC=no
7、执行ifconfig命令查询服务器的网卡名称。openEuler操作系统可以跳过该步骤。
如下图所示,如果服务器IP为10.244.53.173,则该服务器的网卡名称为eth0。对于X86,MTU值推荐1500;对于ARM,MTU值推荐8192。
8、在其他主机上重复上面步骤。
9、确保各服务器时间和时区一致。
[root@pekphisprb70596 openGauss]# date
Fri May 6 14:38:38 CST 2022
1.vim打开配置文件/etc/ssh/sshd_config。
2.查看PermitRootLogin配置是否为yes,表示允许用户远程登录。
3.在Banner XXX 前面加 #,注释掉欢迎语。
4.重启sshd服务。
[root@pekphisprb70596 openGauss]# systemctl restart sshd.service
5.在其他服务器上执行上面的步骤。
配置文件准备
从安装文档示例中,把主机名和IP换成自己实际使用的值。
后来我看到了我的服务器名字是一串奇怪的字符,决定给他换个名字。当然你也可以直接用原来的主机名字。
vi /etc/hostname
修改成想要的主机名字,然后重启下服务器
reboot
下面是修改后的内容。注意编码格式,我用notepad++ 可以看到编码格式为UTF-8。
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<PARAM name="clusterName" value="openGauss" />
<PARAM name="nodeNames" value="opengauss1,opengauss2" />
<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" />
<PARAM name="corePath" value="/opt/huawei/corefile"/>
<PARAM name="backIp1s" value="10.247.xxx.14,10.247.xxx.82"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- node1上的节点部署信息 -->
<DEVICE sn="opengauss1">
<PARAM name="name" value="opengauss1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="10.247.xxx.14"/>
<PARAM name="sshIp1" value="10.247.xxx.14"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn,opengauss2,/opt/huawei/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- node2上的节点部署信息,其中“name”的值配置为主机名称 -->
<DEVICE sn="opengauss2">
<PARAM name="name" value="opengauss2"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="10.247.xxx.82"/>
<PARAM name="sshIp1" value="10.247.xxx.82"/>
</DEVICE>
</DEVICELIST>
</ROOT>
预安装
1.以root用户登录待安装openGauss的任意主机,并按规划创建存放安装包的目录。
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software
2.将安装包“openGauss-3.0.0-openEuler-64bit-all.tar.gz”和配置文“cluster_config.xml”都上传至上一步所创建的/opt/software/openGauss目录中。
3.解压安装包。
cd /opt/software/openGauss
tar -zxvf openGauss-3.0.0-openEuler-64bit-all.tar.gz
tar -zxvf openGauss-3.0.0-openEuler-64bit-om.tar.gz
4.如果是openEuler的操作系统,执行如下命令打开performance.sh文件,用#注释sysctl -w vm.min_free_kbytes=112640 &> /dev/null。
vi /etc/profile.d/performance.sh
5.进入script执行预安装命令。我采用的是交互式,所以需要在中间提示的时候输入密码。安装时长大概三五分钟。
[root@opengauss1 openGauss]# cd script/
[root@opengauss1 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.
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[omm] and create trust for it (yes/no)? y
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
Generate cluster user password files successfully.
Successfully created [omm] user on all nodes.
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 [omm] user.
Please enter password for current user[omm].
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 [omm] 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/openGauss/script/gs_checkos -i A -h opengauss1,opengauss2 --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.
如果这里报错提示你“You need to install software:expect”,就按照前面安装前准备那里装一下依赖的软件expect,重新执行该命令即可。
安装及验证
基本都在预安装脚本里面设置好了,不需要再手动调整了。
1.先切换到omm用户。
su - omm
2.使用gs_install安装openGauss。中间根据提示输入数据库密码,大概两三分钟的样子。
[omm@opengauss1 ~]$ 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.
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.
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.
end deploy..
[omm@opengauss1 ~]$
3.检查下数据库状态,state都是Normal就很OK。
[omm@opengauss1 dn]$ 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 opengauss1 10.247.xxx.14 15400 6001 /opt/huawei/install/data/dn P Primary Normal
2 opengauss2 10.247.xxx.82 15400 6002 /opt/huawei/install/data/dn S Standby Normal
4.现在试一下连接。
[omm@opengauss1 om]$ gsql -d postgres -p 15400
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:19 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
CREATE DATABASE
openGauss=#
openGauss=# \q
openGauss企业版一主一备安装到此结束。