openGauss企業版安裝

語言: CN / TW / HK

目錄

安裝前準備

伺服器

資料庫安裝包

依賴的軟體

修改作業系統配置

配置檔案準備

預安裝

安裝及驗證


安裝前準備

這裡要準備三個部分,伺服器(OS已安裝好)+資料庫安裝包+依賴的軟體。

伺服器

首先找小夥伴申請了華為雲伺服器安裝好了OS,這裡使用的是x86_64+openEuler 20.03LTS。你要是沒有這麼給力的小夥伴就自己親力親為吧~ 華為雲伺服器現在可是很划算呢,安裝也很方便。

[[email protected] ~]# 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.通過http://opengauss.org/zh/download.html登入openGauss開源社群,選擇3.0.0版本對應平臺企業版安裝包。
在這裡插入圖片描述
下載後這樣的 :
在這裡插入圖片描述
2、先上傳到伺服器/opt目錄下。

[[email protected] ~]# cd /opt/ 
[[email protected] 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資料夾,再把安裝包給他挪進去。

[[email protected] opt]# mkdir openGauss 
[[email protected] opt]# mv openGauss-3.0.0-openEuler-64bit-all.tar.gz openGauss 
[[email protected] 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 
[[email protected] opt]# cd openGauss/ 
[[email protected] openGauss]# ll 
total 112M 
-rw------- 1 root root 112M May  6 11:21 openGauss-3.0.0-openEuler-64bit-all.tar.gz

4、解壓資料庫安裝包,檢查安裝目錄及檔案是否齊全。另外設定下系統超時時間,不要斷連。

[[email protected] 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 
[[email protected] 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 
[[email protected] openGauss]# set TMOUT=0 

依賴的軟體

1、按照官方文件進行軟體的檢查。跟我相同OS的就可以跳過該檢查,直接下一步。

[[email protected] openGauss]# rpm -qa | grep flex 
flex-2.6.1-13.oe1.x86_64 
[[email protected] openGauss]# rpm -qa | grep libaio 
libaio-0.3.111-5.oe1.x86_64 
[[email protected] openGauss]# rpm -qa | grep bison 
bison-3.5-2.oe1.x86_64 
[[email protected] 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 
[[email protected] openGauss]# rpm -qa | grep glibc-devel 
glibc-devel-2.28-36.oe1.x86_64 
[[email protected] 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 
[[email protected] openGauss]# rpm -qa | grep redhat 
[[email protected] openGauss]# rpm -qa | grep readline 
readline-7.0-13.oe1.x86_64 
[[email protected] openGauss]# rpm -qa | grep libnsl 
libnsl2-1.2.0-4.oe1.x86_64 
[[email protected] 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(這個雖然沒有在官方文件表格裡,但是我執行預安裝的時候報錯了,又重新裝了下,所以在這加上 )。

[[email protected] 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) <[email protected]>" 
 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! 
[[email protected] openGauss]# rpm -qa | grep libnsl 
libnsl-2.28-36.oe1.x86_64 
libnsl2-1.2.0-4.oe1.x86_64 
[[email protected] openGauss]#
[[email protected] 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 
[[email protected] 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、重新載入引數並檢查。

[[email protected] ~]# systemctl daemon-reload 
[[email protected] ~]# systemctl restart systemd-logind 
[[email protected] ~]# loginctl show-session | grep RemoveIPC 
RemoveIPC=no 
[[email protected] ~]# 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、確保各伺服器時間和時區一致。

[[email protected] openGauss]# date 
Fri May  6 14:38:38 CST 2022

設定root使用者遠端登入

1.vim開啟配置檔案/etc/ssh/sshd_config。
2.檢視PermitRootLogin配置是否為yes,表示允許使用者遠端登入。
在這裡插入圖片描述
3.在Banner XXX 前面加 #,註釋掉歡迎語。
在這裡插入圖片描述
4.重啟sshd服務。

[[email protected] 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執行預安裝命令。我採用的是互動式,所以需要在中間提示的時候輸入密碼。安裝時長大概三五分鐘。

[[email protected] openGauss]# cd script/ 
[[email protected] 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,重新執行該命令即可。

安裝及驗證

修改OS引數

基本都在預安裝腳本里面設定好了,不需要再手動調整了。

執行安裝

1.先切換到omm使用者。

su - omm

2.使用gs_install安裝openGauss。中間根據提示輸入資料庫密碼,大概兩三分鐘的樣子。

[[email protected] ~]$ 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.. 
[[email protected] ~]$ 

3.檢查下資料庫狀態,state都是Normal就很OK。

[[email protected] 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.現在試一下連線。

[[email protected] 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企業版一主一備安裝到此結束。