openGauss2.0.0 極簡版安裝
openGauss 的安裝在官方文件的描述中,一直以企業生產環境為標準進行安裝部署。但在個人基本的功能測試需求下,這樣的安裝操作顯得有些複雜。
在 openGauss 2.0.0 版本中(2021.03.31 釋出)新增了極簡版的軟體包,極簡版安裝的使用主體主要針對高校和個人測試環境,相對企業安裝流程更簡單快捷,更加適合高校學生或者個人功能測試的場景,該軟體包中並不包含 OM 工具,採用指令碼可以實現一鍵式安裝部署。
本文透過使用極簡版進行安裝部署,希望基本的操作示例對大家能有所幫助。
軟體環境: 包含了上一版本要求的軟體依賴包,新增了 openEuler x86 環境下需要的 libnsl 軟體包。
硬體環境: 極簡版中對於硬體環境要求描述“個人開發者最低配置 2 核 4G, 推薦配置 4 核 8G。”,本次安裝實驗採用最低配置 2c/4GB,作業系統使用 CentOS7.6.1810。
極簡版為了適應小記憶體機器,在部署時將部分重要記憶體引數設定較低,如:“shared_buffers = 32MB”、“cstore_buffers = 512MB”。
另外,極簡版安裝的資料庫字符集將原先預設的 SQL_ACSII 字符集改為 en_US.UTF-8,同時初始使用者密碼不做強制修改[modify_initial_password = false]。
執行環境配置
- 配置 YUM 源
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
yum clean all
2. 安裝依賴的軟體包
yum install libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-devel -y
3. 關閉安全設定
關閉防火牆
systemctl status firewalld
systemctl disable firewalld.service
systemctl stop firewalld.service
關閉SELinux
sed -i '/SELINUX=/d' /etc/selinux/config
echo "SELINUX=disabled" >> /etc/selinux/config
cat /etc/selinux/config|grep -v ^#|grep -v '^$'
4. 設定時區
rm -fr /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ll /etc/localtime
5. 關閉 SWAP
修改分割槽表檔案,刪除SWAP掛載資訊
cp /etc/fstab /etc/fstab.bak
sed -i '/swap/s/^/#/' /etc/fstab
cat /etc/fstab|grep -v ^#|grep -v '^$'
關閉swap
swapoff -a
6. 配置作業系統核心引數
極簡安裝但沒有實現核心引數的自動化配置,這個有些不足,希望後續將引數配置寫入指令碼。
此處參考之前的配置吧
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
vm.min_free_kbytes = 102400 ##suggest to set as physical memory * 5%
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1152921504606846720
kernel.shmmax = 18446744073709551615
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
EOF
sysctl -p
備註: openEuler 作業系統需要關閉 RemoveIPC,操作請參考官方文件。
建立普通使用者和目錄,並授權
groupadd -g 1001 dbgrp
useradd -u 2001 -g dbgrp omm
mkdir -p /opt/software/openGauss
chown -R omm:dbgrp /opt
解壓並一鍵式安裝單機 openGauss
極簡版軟體包:openGauss-2.0.0-CentOS-64bit.tar.bz2
企業版軟體包:openGauss-2.0.0-CentOS-64bit-all.tar.gz (包含 om 工具)
單機部署的資料目錄 --> /opt/software/openGauss/data/single_node
主備部署的資料目錄 --> /opt/software/openGauss/data/master 和 /opt/software/openGauss/data/slave
解壓軟體包
[root@db1 ~]# su - omm
[omm@db1 ~]$ cd /opt/software/openGauss/
[omm@db1 openGauss]$ tar -jxf openGauss-2.0.0-CentOS-64bit.tar.bz2 -C /opt/software/openGauss/
一鍵式指令碼安裝
[omm@db1 openGauss]$ cd /opt/software/openGauss/simpleInstall/
[omm@db1 simpleInstall]$ sh install.sh -w **@ -p 26000 ## -w指定資料庫初始使用者密碼、-p指定資料庫埠
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables
/home/omm/.bashrc: line 16: ulimit: open files: cannot modify limit: Operation not permitted
[step 6]: init datanode
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
creating directory /opt/software/openGauss/data/single_node ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/software/openGauss/data/single_node/base/1 ... The core dump path is an invalid directory
2021-04-01 09:58:57.927 [unknown] [unknown] localhost 139899531253504 0 [BACKEND] WARNING: macAddr is 64022/1040773698, sysidentifier is 4195761672/4064452798, randomNum is 486318270
... ...
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.
Success. You can now start the database server of single node using:
gaussdb -D /opt/software/openGauss/data/single_node --single_node
or
gs_ctl start -D /opt/software/openGauss/data/single_node -Z single_node -l logfile
[step 7]: start datanode
[2021-04-01 09:59:21.027][8464][][gs_ctl]: gs_ctl started,datadir is /opt/software/openGauss/data/single_node
[2021-04-01 09:59:21.136][8464][][gs_ctl]: waiting for server to start...
0 LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
0 LOG: [Alarm Module]Host Name: db1
0 LOG: [Alarm Module]Host IP: ...
0 LOG: [Alarm Module]Cluster Name: dbCluster
0 LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
0 WARNING: failed to open feature control file, please check whether it exists: FileName=gaussdb.version, Errno=2, Errmessage=No such file or directory.
0 WARNING: failed to parse feature control file: gaussdb.version.
0 WARNING: Failed to load the product control file, so gaussdb cannot distinguish product version.
0 LOG: Failed to initialze environment for codegen.
The core dump path is an invalid directory
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: when starting as multi_standby mode, we couldn't support data replicaton.
gaussdb.state does not exist, and skipt setting since it is optional.2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: [Alarm Module]can not read GAUSS_WARNING_TYPE env.
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: [Alarm Module]Host Name: db1
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: [Alarm Module]Host IP: ...
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: [Alarm Module]Cluster Name: dbCluster
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: [Alarm Module]Invalid data in AlarmItem file! Read alarm English name failed! line: 52
2021-04-01 09:59:21.359 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: Transparent encryption disabled.
2021-04-01 09:59:21.365 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: loaded library "security_plugin"
2021-04-01 09:59:21.365 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] WARNING: No explicit IP is configured for listen_addresses GUC.
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: InitNuma numaNodeNum: 1 numa_distribute_mode: none inheritThreadPool: 0.
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: reserved memory for backend threads is: 220 MB
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: reserved memory for WAL buffers is: 128 MB
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: Set max backend reserve memory is: 348 MB, max dynamic memory is: 11097 MB
2021-04-01 09:59:21.374 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: shared memory 330 Mbytes, memory context 11445 Mbytes, max process memory 12288 Mbytes
2021-04-01 09:59:21.404 [unknown] [unknown] localhost 140033854506752 0 0 [CACHE] LOG: set data cache size(402653184)
2021-04-01 09:59:21.415 [unknown] [unknown] localhost 140033854506752 0 0 [CACHE] LOG: set metadata cache size(134217728)
2021-04-01 09:59:21.462 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: gaussdb: fsync file "/opt/software/openGauss/data/single_node/gaussdb.state.temp" success
2021-04-01 09:59:21.462 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: create gaussdb state file success: db state(STARTING_STATE), server mode(Normal)
2021-04-01 09:59:21.483 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: max_safe_fds = 977, usable_fds = 1000, already_open = 13
The core dump path is an invalid directory
2021-04-01 09:59:21.484 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: user configure file is not found, it will be created.
2021-04-01 09:59:21.488 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: the configure file /opt/software/openGauss/etc/gscgroup_omm.cfg doesn't exist or the size of configure file has changed. Please create it by root user!
2021-04-01 09:59:21.488 [unknown] [unknown] localhost 140033854506752 0 0 [BACKEND] LOG: Failed to parse cgroup config file.
[2021-04-01 09:59:22.143][8464][][gs_ctl]: done
[2021-04-01 09:59:22.143][8464][][gs_ctl]: server started (/opt/software/openGauss/data/single_node)
import sql file
Would you like to create a demo database (yes/no)? yes ## 建立Demo資料庫
Load demoDB [school,finance] success.
[complete successfully]: You can start or stop the database server using:
gs_ctl start|stop|restart -D $GAUSSHOME/data/single_node -Z single_node
檢查資料庫
[omm@db1 ~]$ echo "PATH=/opt/software/openGauss/bin:$PATH" >> /home/omm/.bash_profile ## 配置PATH
[omm@db1 ~]$ source ~/.bash_profile
-bash: ulimit: open files: cannot modify limit: Operation not permitted ## 這裡提示開啟檔案數量限制不能修改,這...... 代表resource limit引數指令碼也沒有做相應的配置
[omm@db1 ~]$ gsql -d postgres -p 26000 -r
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+-------------+-------------+-------------------
finance | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | -- 金融場景資料庫示例
postgres | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
school | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | -- 學校場景資料庫示例
template0 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +
| | | | | omm=CTc/omm
(5 rows)
總結
openGauss 的極簡安裝沒有使用 OM 工具,即不能使用 OM 工具對 openGauss 例項進行管理和配置。
openGauss 極簡版免去了使用者配置 XML 檔案的操作,也免去了配置 1 主+1 備的配置操作,這簡化了少許安裝操作。
但是極簡版個人感覺稍有些失望,所謂的"極"字並沒有得到充分體現,系統核心引數、資源限制引數、環境變數配置、使用者建立、目錄建立和許可權等等這些操作並沒有實現自動化配置,指令碼很簡單但是並沒有寫入 install 指令碼中。
個人對“極簡”的期待是 90 分,實際感覺是 60 分,還有待完善,但值得期待。
附錄:極簡安裝主備環境
openGauss極簡主備部署,指令碼的基本操作就是分別單機安裝主、備節點,然後配置主備關係並重建備庫。同時,極簡安裝也會部署測試庫finance和school。
[omm@db1 ~]$ cd /opt/software/openGauss/
[omm@db1 openGauss]$ tar -jxf openGauss-2.0.0-CentOS-64bit.tar.bz2 -C /opt/software/openGauss/
[omm@db1 openGauss]$ cd /opt/software/openGauss/simpleInstall/
主備部署需要配合--multinode引數
[omm@db1 simpleInstall]$ sh install.sh -w **@ -p 26000 --multinode
[step 1]: check parameter
[step 2]: check install env and os setting
[step 3]: change_gausshome_owner
[step 4]: set environment variables
/home/omm/.bashrc: line 16: ulimit: open files: cannot modify limit: Operation not permitted
[init primary datanode.]
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
creating directory /opt/software/openGauss/data/master ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/software/openGauss/data/master/base/1 ... The core dump path is an invalid directory
... ...
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.
Success. You can now start the database server of single node using:
gaussdb -D /opt/software/openGauss/data/master --single_node
or
gs_ctl start -D /opt/software/openGauss/data/master -Z single_node -l logfile
[init slave datanode.]
The files belonging to this database system will be owned by user "omm".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
creating directory /opt/software/openGauss/data/slave ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/software/openGauss/data/slave/base/1 ... The core dump path is an invalid directory
2021-04-01 10:16:31.046 [unknown] [unknown] localhost 140719588914944 0 [BACKEND] WARNING: macAddr is 64022/1040773698, sysidentifier is 4195761672/4064474332, randomNum is 2212623580
... ...
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run gs_initdb.
Success. You can now start the database server of single node using:
gaussdb -D /opt/software/openGauss/data/slave --single_node
or
gs_ctl start -D /opt/software/openGauss/data/slave -Z single_node -l logfile
[config datanode.]
remote_read_mode = non_authentication
host all all ...00/32 trust
[start primary datanode.]
[2021-04-01 10:16:53.293][1997][][gs_ctl]: gs_ctl started,datadir is /opt/software/openGauss/data/master
[2021-04-01 10:16:53.400][1997][][gs_ctl]: waiting for server to start...
......
[2021-04-01 10:17:10.092][2063][datanode2][gs_ctl]: done
[2021-04-01 10:17:10.092][2063][datanode2][gs_ctl]: server started (/opt/software/openGauss/data/slave)
[2021-04-01 10:17:10.092][2063][datanode2][gs_ctl]: fopen build pid file "/opt/software/openGauss/data/slave/gs_build.pid" success
[2021-04-01 10:17:10.092][2063][datanode2][gs_ctl]: fprintf build pid file "/opt/software/openGauss/data/slave/gs_build.pid" success
[2021-04-01 10:17:10.095][2063][datanode2][gs_ctl]: fsync build pid file "/opt/software/openGauss/data/slave/gs_build.pid" success
import sql file
Would you like to create a demo database (yes/no)? yes
Load demoDB [school,finance] success.
[complete successfully]: You can start or stop the database server using:
primary: gs_ctl start|stop|restart -D $GAUSSHOME/data/master -M primary
standby: gs_ctl start|stop|restart -D $GAUSSHOME/data/slave -M standby
-> 資料庫檢查
[omm@db1 ~]$ echo "PATH=/opt/software/openGauss/bin:$PATH" >> /home/omm/.bash_profile ## 配置PATH
[omm@db1 ~]$ source ~/.bash_profile
[omm@db1 master]$ gsql -d postgres -p 26000 -r
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+-------------+-------------+-------------------
finance | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
school | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/omm +
| | | | | omm=CTc/omm
-> 主備狀態檢查
[omm@db1 master]$ gs_ctl query -D /opt/software/openGauss/data/master
[2021-04-01 10:32:43.785][2239][][gs_ctl]: gs_ctl query ,datadir is /opt/software/openGauss/data/master
HA state:
local_role : Primary
static_connections : 1
db_state : Normal
detail_information : Normal
Senders info:
sender_pid : 2151
local_role : Primary
peer_role : Standby
peer_state : Normal
state : Streaming
sender_sent_location : 0/403B850
sender_write_location : 0/403B850
sender_flush_location : 0/403B850
sender_replay_location : 0/403B850
receiver_received_location : 0/403B850
receiver_write_location : 0/403B850
receiver_flush_location : 0/403B850
receiver_replay_location : 0/403B850
sync_percent : 100%
sync_state : Sync
sync_priority : 1
sync_most_available : Off
channel : ...00:26001-->...00:37014
Receiver info:
No information