本節描述openGauss資料庫在虛擬機VirtualBox+openEuler上的安裝配置,
1、虛擬機VirtualBox下載及安裝
步驟 1 進入官方網站下載頁面,
網址:https://www.virtualbox.org/wiki/Downloads

點擊” window主機” 下載windows版本的VirtualBox,
步驟 2下載完成后,雙擊執行檔案進行安裝,
下載后,檔案名為:VirtualBox-6.1.14-140239-Win.exe,雙擊此執行檔案進行安裝,安裝程序中存放地址可以根據自己想法去設定下,其他所有選項都可以默認,直接按下一步就行,最后安裝成功,
具體如下:

2、openEuler-20.03-LTS鏡像檔案下載
步驟 1 進入華為開源鏡像站的下載頁面,
網址:https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/ISO/x86_64/,具體如下:

步驟 2 點擊” openEuler-20.03-LTS-x86_64-dvd.iso”,進行相應ISO鏡像檔案下載,
下載的檔案名如下:

3、VirtualBox下安裝openEuler-20.03-LTS作業系統
步驟 1 新建虛擬電腦,
打開VirtualBox軟體,

在VirtualBox的管理器上點擊”新建”,具體如下:

在此頁面,填好相應的名稱(如:openEuler)、檔案存放地址(如:d:\vmwork)、作業系統型別(如:Linux))、版本(如:Other Linux),然后點擊”下一步”,

記憶體設定為2048MB(表示整個系統只有2G記憶體),然后點擊”下一步”,

采用默認設定,直接點擊”創建”,

采用默認設定,直接點擊”下一步”,

采用默認設定,直接點擊”下一步”,

硬碟大小改為10G(10G表示硬碟自動擴展后所能達到的最大極限大小,在實際使用中可以根據自己情況來做調整),然后點擊”創建”,

步驟 2 設定虛擬電腦并安裝,
在VirtualBox的管理器上點擊”設定”,具體如下:

在設定頁面上點擊”系統”,進行系統設定,在啟動順序中把”光驅”、”硬碟”移動至第一、二啟動,”軟驅”去掉勾選,具體如下:

處理器中,CPU設定為2,具體如下:

點擊“存盤“設定項,選擇光碟并在分配光驅后面點擊加載按鈕將前面下載的openEuler-20.03-LTS-x86_64-dvd.iso檔案加載至光驅中,具體如下:


點擊“網路“設定項,這里用到二張網卡,網卡1連接方式下拉選擇為”僅主機(Host-Only)網路“,主要用于本地電腦與虛擬電腦相連,具體如下:

網卡2設定,勾選“啟用網路連接”,并且“連接方式選擇”下拉選擇為“網路地址轉換(NAT)“,主要用于虛擬電腦與互聯網相連,具體如下:

最后點擊“OK“按鈕,設定完成,設定完成頁面如下:

點擊啟動按鈕,開始進入系統安裝,

確定光驅中的ISO內容正確后,點擊“啟動“,
啟動安裝第一界面,直接按下“Enter“鍵后就會進入自檢界面,

語言選擇中文----》簡體中文(中國),然后點擊“繼續“,

在此頁面,點擊“安裝位置“先進行磁區,具體如下:

選擇“自定義“,然后點擊”完成“,

下拉選擇“標準磁區“,然后點擊”點擊這里自動創建他們“,

點擊“完成“,進入下一步設定,

點擊“接受更改“,完成磁區設定,接下來進行網路和主機名設定,
在安裝資訊摘要頁面,點擊“網路和主機名“進行網路和主機名設定,具體如下:

分別針對二張網卡進行設定,如以太網(enpOs3)網卡,先點擊“關閉“邊上的按鈕把網卡打開,

接著設定主機名(如:db1),并點擊“應用(A)”,然后點擊“配置“,
說明:設定主機名時一定要注意,如果在同一網段內有多位學員按此檔案來安裝,請盡量把主機名設成不一樣,

在配置頁中,選擇“常規“,然后勾選”可用時自動鏈接到這個網路“,接著點擊”保存“,

引數第一張網卡的設定步驟對第二張網卡進行設定,先打開網卡,接著進行配置,具體如下:

點擊“保存“,

點擊“完成“,結束網路和主機名的設定,
在安裝資訊摘要頁面,點擊“軟體選擇 “進行軟體安裝設定,具體如下:

在此頁面選擇“虛擬化主機“,并在右邊勾選”Linux的遠程管理“、”開發工具“、”安全性工具“、”系統管理工具“,然后點擊完成,

設定結束,點擊“開始安裝“,具體如下:

點擊“ROOT密碼“,給ROOT用戶設定密碼(如:openGauss@123),

點擊“創建用戶“,在此新創建一個用戶(如:用戶test,密碼openGauss@123),具體如下:


系統安裝中,等待數分鐘后會出現如下界面:

出現此界面表示,系統安裝完成,然后點擊“重啟“,但此時要調整系統從硬碟啟動,
先關閉VM運行視窗,如下:

然后設定從硬碟啟動,具體如下:

重啟后,要求輸入用戶名及密碼,這里用root用戶登錄,密碼比如:openGauss@123,具體如下:

步驟 3 確認網路
在Linux作業系統上,通過ifconfig來查看二張網卡是否都正常啟動,具體如下:
[root@db1 ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.123 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::ac2f:dc4f:edfe:1d57 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:0f:78:e3 txqueuelen 1000 (Ethernet)
RX packets 519 bytes 48509 (47.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 178 bytes 52937 (51.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255
inet6 fe80::bedc:2040:4b9:23ed prefixlen 64 scopeid 0x20<link>
ether 08:00:27:45:8d:f0 txqueuelen 1000 (Ethernet)
RX packets 72 bytes 10702 (10.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 124 bytes 11664 (11.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
……………………………..
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:05:11:90 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
通過ping baidu.com確認是否能上網,具體如下:
[root@db1 ~]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=47 time=48.1 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=47 time=46.5 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=47 time=49.2 ms
使用 ctrl+c組合鍵可以結束輸出,
4、作業系統環境準備
為了操作方便,可以使用SSH工具(比如:PuTTY等)從本地電腦通過配置enp0s3網卡的IP地址(如:192.168.56.123)來連接虛擬機,并使用ROOT用戶來登錄,

步驟 1 關閉防火墻
執行以下二個命令將防火墻關閉,
systemctl stop firewalld.service
systemctl disable firewalld.service,具體如下:
[root@db1 ~]# systemctl stop firewalld.service
[root@db1 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@db1 ~]#
步驟 2設定字符集及環境變數,
[root@db1 ~]# cat >>/etc/profile<<EOF export LANG=en_US.UTF‐8 EOF [root@db1 ~]# [root@db1 ~]# cat >>/etc/profile<<EOF export packagePath=/opt/software/openGauss EOF [root@db1 ~]# source /etc/profile [root@db1 ~]# cat >>/etc/profile<<EOF export LD_LIBRARY_PATH=$packagePath/script/gspylib/clib:$LD_LIBRARY_PATH EOF [root@db1 ~]# [root@db1 ~]# source /etc/profile
驗證變數是否生效,
[root@db1 ~]# echo $LD_LIBRARY_PATH
結果為:
/opt/software/openGauss/script/gspylib/clib:
步驟 3關閉swap交換記憶體,
[root@db1 ~]# swapoff -a
步驟 4調整系統引數值,
執行如下命令打開performance.sh檔案,用#注釋sysctl -w vm.min_free_kbytes=112640 &> /dev/null,鍵入“ESC”鍵進入指令模式,執行:wq保存并退出修改,
使用vim打開檔案“/etc/profile.d/performance.sh”
[root@db1 ~]# vi /etc/profile.d/performance.sh
輸入”i”,進入INSERT模式,用#注釋sysctl -w vm.min_free_kbytes=112640 &> /dev/null,
CPUNO=`cat /proc/cpuinfo|grep processor|wc -l`
export GOMP_CPU_AFFINITY=0-$[CPUNO - 1]
#sysctl -w vm.min_free_kbytes=112640 &> /dev/null
sysctl -w vm.dirty_ratio=60 &> /dev/null
sysctl -w kernel.sched_autogroup_enabled=0 &> /dev/null
點擊“ESC”退出INSERT模式,輸入“:wq”后回車,保存退出,
步驟 5準備yum環境,
備份原有的yum組態檔,
[root@db1 ~]# mv /etc/yum.repos.d/openEuler_x86_64.repo /etc/yum.repos.d/openEuler_x86_64.repo.bak
[root@db1 ~]#
下載可用源的repo檔案:
curl -o /etc/yum.repos.d/openEuler_x86_64.repo https://mirrors.huaweicloud.com/repository/conf/openeuler_x86_64.repo
[root@db1 ~]# curl -o /etc/yum.repos.d/openEuler_x86_64.repo https://mirrors.huaweicloud.com/repository/conf/openeuler_x86_64.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 886 0 886 0 0 3661 0 --:--:-- --:--:-- --:--:-- 3676
查看repo檔案內容是否正確,
[root@db1 ~]# cat /etc/yum.repos.d/openEuler_x86_64.repo
[openEuler-source]
name=openEuler-source
baseurl=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/source/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler
[openEuler-os]
name=openEuler-os
baseurl=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/OS/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/OS/x86_64/RPM-GPG-KEY-openEuler
[openEuler-everything]
name=openEuler-everything
baseurl=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/everything/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/everything/x86_64/RPM-GPG-KEY-openEuler
[openEuler-EPOL]
name=openEuler-epol
baseurl=https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/EPOL/x86_64/
enabled=1
gpgcheck=0
[root@db1 ~]#
步驟 6yum安裝相關包,
執行以下命令,安裝所需的包
yum install libaio* -y
yum install libnsl* -y
如下:
[root@db1 ~]# yum install libaio* -y
Last metadata expiration check: 0:00:44 ago on Thu 15 Oct 2020 10:38:26 AM CST.
Package libaio-0.3.111-5.oe1.x86_64 is already installed.
Dependencies resolved.
………………….
[root@db1 ~]# yum install libnsl* -y
Last metadata expiration check: 0:00:24 ago on Thu 07 Jan 2021 10:17:38 AM CST.
Package libnsl2-1.2.0-4.oe1.x86_64 is already installed.
Dependencies resolved.
………………….
步驟 7 設定默認Python版本為3.x,
[root@db1 ~]# cd /usr/bin
[root@db1 bin]# mv python python.bak
[root@db1 bin]# ln -s python3 /usr/bin/python
[root@db1 bin]# python -V
Python 3.6.8
步驟 8 創建存放資料庫安裝目錄,
[root@db1 ~]# mkdir -p /opt/software/openGauss
[root@db1 ~]# cd /opt/software/openGauss
[root@db1 openGauss]#
5、安裝openGauss資料庫
步驟 1 創建XML組態檔,用于資料庫安裝,
[root@db1 openGauss]# vi clusterconfig.xml
將以下內容添加進clusterconfig.xml檔案中,
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<!-- openGauss整體資訊 -->
<CLUSTER>
<PARAM name="clusterName" value="dbCluster" />
<PARAM name="nodeNames" value="db1" />
<PARAM name="backIp1s" value="10.0.3.15"/>
<PARAM name="gaussdbAppPath" value="/opt/gaussdb/app" />
<PARAM name="gaussdbLogPath" value="/var/log/gaussdb" />
<PARAM name="gaussdbToolPath" value="/opt/huawei/wisequery" />
<PARAM name="corePath" value="/opt/opengauss/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<!-- 每臺服務器上的節點部署資訊 -->
<DEVICELIST>
<!-- node1上的節點部署資訊 -->
<DEVICE sn="1000001">
<PARAM name="name" value="db1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<!-- 如果服務器只有一個網卡可用,將backIP1和sshIP1配置成同一個IP -->
<PARAM name="backIp1" value="10.0.3.15"/>
<PARAM name="sshIp1" value="10.0.3.15"/>
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="26000"/>
<PARAM name="dataNode1" value="/gaussdb/data/db1"/>
</DEVICE>
</DEVICELIST>
</ROOT>
說明:其中標紅的內容,需要根據自己實際的IP和主機名進行修改,如果其中的中文出現亂碼時可以洗掉這些行,
步驟 2 使用wget下載資料庫安裝包到安裝包目錄
切換到安裝目錄:
[root@ecs-c9bf bin]# cd /opt/software/openGauss
使用wget下載安裝包:
[root@ecs-c9bf openGauss]# wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.1.0/x86_openEuler/openGauss-1.1.0-openEuler-64bit-all.tar.gz
注:https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.1.0/x86_openEuler/openGauss-1.1.0-openEuler-64bit-all.tar.gz是資料庫安裝包下載網址,輸入時不需要進行換行,
下載成功顯示如下:
……
2020-09-14 13:57:23 (9.33 MB/s) - ‘openGauss-1.1.0-openEuler-64bit-all.tar.gz’ saved [58468915/58468915]
步驟 3在安裝包所在的目錄下,解壓安裝包,
[root@ecs-c9bf openGauss]# cd /opt/software/openGauss
解壓縮安裝包:
先解壓openGauss-1.1.0-openEuler-64bit-all.tar.gz包,
[root@ecs-c9bf openGauss]# tar -zxvf openGauss-1.1.0-openEuler-64bit-all.tar.gz
再先解壓openGauss-1.1.0-openEuler-64bit-om.tar.gz包,
[root@ecs-c9bf openGauss]# tar -zxvf openGauss-1.1.0-openEuler-64bit-om.tar.gz
解壓后如下,用ls命令查看如下:
[root@ecs-c9bf openGauss]# ls
clusterconfig.xml openGauss-Package-bak_392c0438.tar.gz
lib script
openGauss-1.1.0-openEuler-64bit-all.tar.gz simpleInstall
openGauss-1.1.0-openEuler-64bit-om.sha256 upgrade_sql.sha256
openGauss-1.1.0-openEuler-64bit-om.tar.gz upgrade_sql.tar.gz
openGauss-1.1.0-openEuler-64bit.sha256 version.cfg
openGauss-1.1.0-openEuler-64bit.tar.bz2
安裝包解壓后,會在/opt/software/openGauss路徑下自動生成script子目錄,并且在script目錄下生成gs_preinstall等各種OM工具腳本,
更改權限,
[root@db1 openGauss]# chmod 755 -R /opt/software
[root@db1 openGauss]#
步驟 4執行初始化腳本,
[root@db1 openGauss]# cd /opt/software/openGauss/script
[root@db1 script]# python gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
Parsing the configuration file.
Successfully parsed the configuration file.
Installing 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.
……………………………………..
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.
……………………………………..
Successfully set finish flag.
Preinstallation succeeded.
期間需要輸入作業系統root用戶的密碼(如密碼:openGauss@123)和創建作業系統omm用戶及設定密碼(如密碼:openGauss@123),
當回傳Preinstallation succeeded內容時,表明初始化完成,
步驟 5 初始化資料庫
用init 6 重啟下虛擬機(主要是為了釋放一些記憶體資源),
[root@db1 script]# init 6
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(ONE) at 10:51:59.
Type `help' to learn how to use Xshell prompt.
過段時間虛擬機重啟好后,再次使用SSH工具(比如:PuTTY等)從本地電腦通過配置enp0s3網卡的IP地址(如:192.168.56.123)來連接虛擬機,并使用ROOT用戶來登錄,然后接著以下操作,

先更新下權限,
[root@db1 script]# chmod 755 -R /opt/software
[root@db1 openGauss]#
然后使用omm用戶進行資料庫初始化,
注意:根據用戶實際記憶體大小設定對應的共享記憶體的大小,如果對該引數進行了設定,會在資料庫啟動時候報錯,本實驗虛擬機總記憶體大小是2G,
gs_install -X /opt/software/openGauss/clusterconfig.xml --gsinit-parameter="–encoding=UTF8" --dn-guc=“max_process_memory=2GB” --dn-guc=“shared_buffers=128MB” --dn-guc=“bulk_write_ring_size=128MB” --dn-guc=“cstore_buffers=16MB”
具體如下:
[root@db1 openGauss]# su - omm
Last login: Thu Sep 10 15:26:21 CST 2020 on pts/0
[omm@db1 ~]$ cd /opt/software/openGauss/script
[omm@db1 script]$ gs_install -X /opt/software/openGauss/clusterconfig.xml --gsinit-parameter="--encoding=UTF8" --dn-guc="max_process_memory=2GB" --dn-guc="shared_buffers=128MB" --dn-guc="bulk_write_ring_size=128MB" --dn-guc="cstore_buffers=16MB"
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/gaussdb/app/share/sslcert/om
Cluster installation is completed.
Configuring.
………………………….
Successfully started cluster.
Successfully installed application.
end deploy..
注意:輸入omm用戶密碼時,不要輸入錯誤(如密碼:openGauss@123),
步驟 6清理軟體安裝包,
[omm@db1 openGauss]$ exit
logout
[root@db1 /]# cd /root
[root@db1 script]# cd /opt/software/openGauss/
[root@db1 openGauss]# ll
total 288M
-rw-------. 1 omm dbgrp 1.4K Jan 7 10:32 clusterconfig.xml
drwx------. 15 root root 4.0K Jan 7 10:31 lib
-r--------. 1 root root 95M Dec 31 20:59 openGauss-1.1.0-openEuler-64bit-all.tar.gz
-r--------. 1 root root 65 Dec 31 20:40 openGauss-1.1.0-openEuler-64bit-om.sha256
-r--------. 1 root root 13M Dec 31 20:40 openGauss-1.1.0-openEuler-64bit-om.tar.gz
-r--------. 1 root root 65 Dec 31 20:39 openGauss-1.1.0-openEuler-64bit.sha256
-r--------. 1 root root 84M Dec 31 20:39 openGauss-1.1.0-openEuler-64bit.tar.bz2
-r--------. 1 root root 96M Jan 7 10:32 openGauss-Package-bak_392c0438.tar.gz
drwx------. 6 root root 4.0K Dec 31 20:40 script
drwxr-xr-x. 2 root root 4.0K Dec 31 20:40 simpleInstall
-r--------. 1 root root 65 Dec 31 20:39 upgrade_sql.sha256
-r--------. 1 root root 132K Dec 31 20:39 upgrade_sql.tar.gz
-r--------. 1 root root 32 Dec 31 20:38 version.cfg
-rwxr-xr-x. 1 root root 32 Oct 14 02:12 version.cfg
[root@db1 openGauss]# rm -rf openGauss-1.1.0-openEuler-64bit-all.tar.gz
[root@db1 openGauss]# rm -rf openGauss-1.1.0-openEuler-64bit-om.tar.gz
資料庫安裝結束,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/413902.html
標籤:其他
上一篇:常見的【記憶體泄漏】姿勢
下一篇:Linux學習筆記(9)
