一.安装准备
1.修改/etc/selinux/config文件中的“SELINUX”值为“disabled”。
a. 使用VIM打开config文件。
vim /etc/selinux/config
b. 修改“SELINUX”的值“disabled”,执行:wq保存并退出修改。
SELINUX=disabled
2.重新启动操作系统。
reboot
3.检查防火墙是否关闭。
systemctl status firewalld
若防火墙状态显示为active (running),则表示防火墙未关闭,请执行步骤4;
若防火墙状态显示为inactive (dead),则无需再关闭防火墙。
4.关闭防火墙并禁止开机重启。
systemctl disable firewalld.service
systemctl stop firewalld.service
5.关闭交换内存
swapoff -a
6.设置主机名
hostnamectl set-hostname node1 # 对第一个节点,第二个节点改为 node2
[root@node1 software]# cat /etc/hostname
node1
7.设置解析主机名和 IP 地址
vi /etc/hosts
添加以下内容
172.16.104.234 node1
172.16.104.236 node2
示例(假设 IP 地址是 172.16.104.234 和 172.16.104.236)
8.安装相关依赖包
yum install -y libaio-devel* flex* bison* ncurses-devel* glibc-devel* patch* readline-devel* expect* ntp*
9.创建单独的用户组,例如dbgrp
groupadd dbgrp
10.创建存放安装包的目录
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software
在其他主机上重复步骤1到步骤10。
二.创建一主一备XML配置文件
在node1节点创建,将openGauss.xml放到/opt/software/openGauss/目录
cd /opt/software/openGauss/
vim openGauss.xml
添加:以下内容
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整体信息 -->
<CLUSTER>
<!-- 数据库名称 -->
<PARAM name="clusterName" value="Cluster_template" />
<!-- 数据库节点名称(hostname) -->
<PARAM name="nodeNames" value="node1,node2" />
<!-- 数据库安装目录-->
<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="172.16.104.234,172.16.104.236"/>
</CLUSTER>
<!-- 每台服务器上的节点部署信息 -->
<DEVICELIST>
<!-- 节点1上的部署信息 -->
<DEVICE sn="node1">
<!-- 节点1的主机名称 -->
<PARAM name="name" value="node1"/>
<!-- 节点1所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点1的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="172.16.104.234"/>
<PARAM name="sshIp1" value="172.16.104.234"/>
<!--dn-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn,node2,/opt/huawei/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<!-- 节点2上的节点部署信息,其中“name”的值配置为主机名称 -->
<DEVICE sn="node2">
<!-- 节点2的主机名称 -->
<PARAM name="name" value="node2"/>
<!-- 节点2所在的AZ及AZ优先级 -->
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 节点2的IP,如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
<PARAM name="backIp1" value="172.16.104.236"/>
<PARAM name="sshIp1" value="172.16.104.236"/>
</DEVICE>
</DEVICELIST>
</ROOT>
三.手工建立互信
手工建立信任关系,步骤如下,node1、node2是主机名:
1.在其中一个主机上,生成root用户的本机授权文件。假设在主机plat1上执行。
a. 生成密钥。
ssh-keygen -t rsa
示例如下:
node1:~ # ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
d5:35:46:33:27:22:09:f0:1e:12:a7:87:fa:33:3f:ab root@plat1
The key's randomart image is:
+--[ RSA 2048]----+
| o.o.....O .|
| * .o + * |
| + + . . |
| . + o |
| . S |
| . |
| + |
| +. |
| E.oo |
+-----------------+
b. 生成本机授权文件。
cat .ssh/id_rsa.pub >> ~/.ssh/authorized_keys
示例如下:
node1:~ # cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2.收集所有的待建互信主机的公钥,写入到本机的known_hosts文件中。此步骤需要在步骤1执行的主机上执行。需要收集node1、node2两个主机的公钥。
a. 收集node1的公钥,写入到本机known_hosts文件中。
ssh-keyscan -t rsa node1 >> ~/.ssh/known_hosts
示例如下:
node1:~ # ssh-keyscan -t rsa node1 >> ~/.ssh/known_hosts
# plat1 SSH-2.0-OpenSSH_5.1
b. 收集node2的公钥,写入到本机known_hosts文件中。
ssh-keyscan -t rsa node2 >> ~/.ssh/known_hosts
示例如下:
node1:~ # ssh-keyscan -t rsa node2 >> ~/.ssh/known_hosts
# node2 SSH-2.0-OpenSSH_5.1
3.将互信文件分发到其它所有主机上。在本例中,需要将node1上的互信文件分发到node2上。
a. 将互信文件分发到node2上。Password输入拷贝目标主机的密码。
scp -r ~/.ssh node2:~
示例如下:
node1:~ # scp -r ~/.ssh node2:~
Password:
authorized_keys 100% 796 0.8KB/s 00:00
id_rsa 100% 1675 1.6KB/s 00:00
id_rsa.pub 100% 398 0.4KB/s 00:00
known_hosts 100% 1089 1.1KB/s 00:00
4.查看互信是否建成功,可以互相ssh主机名。输入exit退出。
node1:~ # ssh node2
Last login: Sat Jun 20 14:01:07 2020
node2:~ # exit
logout
Connection to node2 closed.
node1:~ #
四.初始化安装环境
1.下载openGauss-x.x.x-openEuler-64bit-all.tar.gz安装包,并放到/opt/software/openGauss目录
cd /opt/software/openGauss
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.3/arm/openGauss-5.0.3-openEuler-64bit-all.tar.gz
2…在安装包所在的目录下,解压安装包openGauss-x.x.x-openEuler-64bit-all.tar.gz。安装包解压后,会有OM安装包和Server安装包。继续解压OM安装包,会在/opt/software/openGauss路径下自动生成script子目录,并且在script目录下生成gs_preinstall等各种OM工具脚本。
cd /opt/software/openGauss
tar -zxvf openGauss-x.x.x-openEuler-64bit-all.tar.gz
tar -zxvf openGauss-x.x.x-openEuler-64bit-om.tar.gz
3.进入到工具脚本存放目录下。
cd /opt/software/openGauss/script
4.执行命令准备安装环境
node1:/opt/software/openGauss/script # ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/openGauss.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:
Creating SSH trust for the root permission user.
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.
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 the root permission user.
Setting pssh path
Successfully set core path.
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)? yes
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
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.
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.
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.
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.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
PreInstallationGuide succeeded.
五.执行安装
1.切换到omm用户
su - omm
2.使用gs_install安装openGauss
omm@node1:~>gs_install -X /opt/software/openGauss/openGauss.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 InstallationGuide environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt ciper 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/gaussdb/cluster/app/share/sslcert/om
Cluster InstallationGuide 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 DN 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.
六.安装验证
1.以omm用户身份登录服务器。
su - omm
2.执行如下命令检查数据库状态是否正常,“cluster_state ”显示“Normal”表示数据库可正常使用。
[omm@node1 ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : Cluster_template
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
[omm@node1 ~]$
3.数据库安装完成后,默认生成名称为postgres的数据库。第一次连接数据库时可以连接到此数据库。
其中postgres为需要连接的数据库名称,15400为数据库主节点的端口号,即XML配置文件中的dataPortBase的值。请根据实际情况替换。
gsql -d postgres -p 15400
连接成功后,系统显示类似如下信息表示数据库连接成功。
gsql ((openGauss x.x.x build 290d125f) compiled at 2021-03-08 02:59:43 commit 2143 last mr 131
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.