一、openGuass介紹
openGaussDB(openGauss)是華為雲深度融合在數據庫領域多年的經驗,結合企業級場景需求,推出的新一代企業級分布式數據庫,支持集中式與分布式兩種部署形態。在支撐傳統業務的基礎上,持續構建競爭力特性,為企業面向5G時代的挑戰,提供了無限可能。(來自華為雲官方)。openGauss 於2019年9月19日正式開源,於2020年6月30日正式開放源代碼,並成立openGuass社區。官方網站地址 https://opengauss.org。
openGuass 底層框架源自 PostgreSQL,內建 PostgreSQL 版本為 9.2.4 版本。版本定義在
include/postgresql/server/pg_config.h
/* PostgreSQL version as a string */ #define PG_VERSION "9.2.4"
兼容 Oracle 數據類型和函數
如varchar2(n) 數據類型
定義在 include/ecpgtype.h
enum ECPGttype { ECPGt_varchar2 }
add_months()
定義在include/postgresql/server/utils/timestamp.h
extern Datum add_months(PG_FUNCTION_ARGS); 1
等。
openGauss 也是一款分布式數據庫,內部實現采用pgxc架構。
二、版本及特性介紹
openGauss-1.0.0 為 openGuass 的第一個版本。
版本介紹
數據類型,表,臨時表,視圖,索引,序列,存儲過程,函數,觸發器等SQL功能;
數據類型,表,臨時表,視圖,索引,序列,存儲過程,函數,觸發器等SQL功能;
認證,權限管理,網絡通信安全,數據庫審計等安全特性;
主備雙機,物理備份,邏輯備份,極致RTO高可用功能;
大並發鏈接,分區,plan hint,NUMA化優化高性能能力。
特性介紹
標准SQL支持
支持標准的SQL92/SQL99/SQL2003/SQL2011規范,支持GBK和UTF-8字符集,支持SQL標准函數與分析函數,支持存儲過程。
數據庫存儲管理功能
支持表空間,可以把不同表規划到不同的存儲位置。
提供主備雙機
事務支持ACID特性、單節點故障恢復、雙機數據同步,雙機故障切換等。
應用程序接口
支持標准JDBC 4.0的特性、ODBC 3.5特性。
管理工具
提供安裝部署工具、實例啟停工具、備份恢復工具。
安全管理
支持SSL安全網絡連接、用戶權限管理、密碼管理、安全審計等功能,保證數據庫在管理層、應用層、系統層和網絡層的安全性。
三、基本架構
openGuass支持SQL 2003 語法標准,支持主備部署的高可用關系型數據庫。適合如下場景:
- 多種存儲模式支持符合業務場景
- NUMA 化數據結構支持高性能
- 主備模式,CRC校驗支持高可用
應用場景:
交易型應用
大並發、大數據量、以聯機事務處理為主的交易型應用,如電商、金融、O2O、電信CRM/計費等,應用可按需選擇不同的主備部署模式。
物聯網數據
在工業監控和遠程控制、智慧城市的延展、智能家居、車聯網等物聯網場景下,傳感監控設備多,采樣率高,數據存儲為追加模型,操作和分析並重的場景。
四、安裝指南
openGauss 支持單機安裝和主備環境安裝,此處示例僅僅演示單機安裝。
單機環境介紹:
CPU:AMD-2700x
內存:32G
CPU核數:8核
4.1 軟件依賴環境
#yum install -y libaio-devel\ flex \ bison \ ncurses-devel \ glibc-devel \ patch \ lsb_release
4.2 關閉防火牆和SELinux
#systemctl stop firewalld #systemctl disable firewalld #setenforce 0 #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
4.3 禁用SWAP內存
#swapoff -av swapoff /dev/mapper/rhel-swap
4.4 設置網卡MTU值
推薦 8192,不小於1500
[root@opengauss ~]# ifconfig ens33 mtu 8192 [root@opengauss ~]# ifconfig ens33 | grep mtu ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 8192
4.5 了解用戶和用戶組
為了安全管控,建議安裝用戶為自定義用戶組,軟件包已自帶 gs_preinstall 腳本檢查,相應用戶及用戶組會自動創建並創建安裝目錄
4.6 配置數據庫名稱及各項目錄
openGauss 以xml 文件讀取數據庫名稱及相應目錄
<?xml version="1.0" encoding="UTF-8"?> <ROOT> <!-- 整體信息 --> <CLUSTER> <!-- 數據庫名稱 --> <PARAM name="clusterName" value="opengauss" /> <!-- 數據庫節點名稱(hostname) --> <PARAM name="nodeNames" value="opengauss" /> <!-- 節點IP,與nodeNames一一對應 --> <PARAM name="backIp1s" value="10.10.20.173"/> <!-- 數據庫安裝目錄--> <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"/> <!-- openGauss類型,此處示例為單機類型,“single-inst”表示單機一主多備部署形態--> <PARAM name="clusterType" value="single-inst"/> </CLUSTER> <!-- 每台服務器上的節點部署信息 --> <DEVICELIST> <!-- node1上的節點部署信息 --> <DEVICE sn="1000001"> <!-- node1的hostname --> <PARAM name="name" value="opengauss"/> <!-- node1所在的AZ及AZ優先級 --> <PARAM name="azName" value="AZ1"/> <PARAM name="azPriority" value="1"/> <!-- node1的IP,如果服務器只有一個網卡可用,將backIP1和sshIP1配置成同一個IP --> <PARAM name="backIp1" value="10.10.20.173"/> <PARAM name="sshIp1" value="10.10.20.173"/> <!--DBnode--> <PARAM name="dataNum" value="1"/> <!--DBnode端口號--> <PARAM name="dataPortBase" value="26000"/> <!--DBnode主節點上數據目錄,及備機數據目錄--> <PARAM name="dataNode1" value="/opt/huawei/install/data/db1"/> <!--DBnode節點上設定同步模式的節點數--> <!--><PARAM name="dataNode1_syncNum" value="0"/><--> </DEVICE> </DEVICELIST> </ROOT>
4.7 准備安裝用戶及環境
[root@opengauss openGauss]# cd /opt/software/openGauss/ [root@opengauss openGauss]# chmod 755 -R /opt/software/ [root@opengauss openGauss]# tar -zxf openGauss-1.0.0-CentOS-64bit.tar.gz [root@opengauss openGauss]#groupadd dbgrp [root@opengauss openGauss]#useradd -G dbgrp omm export OPENGAUSSHOME=/opt/software/openGauss export LD_LIBRARY_PATH=${OPENGAUSSHOME}/script/gspylib
4.8 執行檢查腳本
[root@opengauss script]# ./gs_preinstall -U omm -G dbgrp -L -X ../clusterconfig.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. Setting pssh path Successfully set core path. Preparing SSH service. Successfully prepared SSH service. Checking OS software. Successfully check os software. Checking OS version. Successfully checked OS version. Creating cluster's path. Successfully created cluster's path. Setting SCTP service. Successfully set SCTP service. 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 opengauss --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. Set ARM Optimization. No need to set ARM Optimization. Fixing server package owner. Setting finish flag. Successfully set finish flag. Preinstallation succeeded.
4.9 創建主機互信,此處僅建立本機互信即可
[root@opengauss openGauss]#ssh-keygen -t rsa [root@opengauss openGauss]#ssh-copy-id root@opengauss
4.10 內核參數配置
內核參數由於是測試環境,跳過配置
4.11 准備安裝
[root@opengauss ~]# su - omm Last login: Thu Jul 2 01:29:14 CST 2020 on pts/0 [omm@opengauss ~]$ gs_install -X /opt/software/openGauss/clusterconfig.xml [root@opengauss script]# su - omm Last login: Thu Jul 2 01:51:38 CST 2020 on pts/0 [omm@opengauss ~]$ gs_install -X /opt/software/openGauss/clusterconfig.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: The authenticity of host 'opengauss (10.10.20.173)' can't be established. ECDSA key fingerprint is SHA256:UcIvwt+YzSb4iW7p+TmTNmaOiDT2QDyq5NuQcT2VDKU. ECDSA key fingerprint is MD5:74:e5:9c:da:88:be:9a:39:b6:7f:f2:6b:3a:48:4f:ad. Are you sure you want to continue connecting (yes/no)? yes omm@opengauss's password: omm@opengauss's password: begin to create CA cert files The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: omm@opengauss's password: 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. Configuring pg_hba on all nodes. Configuration is completed. Successfully started cluster. Successfully installed application. end deploy.. [omm@opengauss ~]$
4.12 查看進程
[omm@opengauss ~]$ ps -ef | grep gauss | egrep -v "grep" omm 35084 1 2 01:52 pts/0 00:00:02 /opt/huawei/install/app/bin/gaussdb -D /opt/huawei/install/data/db1
4.13 登錄數據庫
openGauss默認端口和PostgreSQL一樣為5432,配置文件中已更改端口為26000,這也是openGauss在配置文件中默認的端口。
[omm@opengauss ~]$ gsql -d postgres -p 26000 gsql ((openGauss 1.0.0 build 0bd0ce80) compiled at 2020-06-30 18:19:27 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. postgres=# ALTER ROLE omm IDENTIFIED BY 'Sungsasung123' REPLACE 'Bigdata@123'; ALTER ROLE --查看版本 postgres=# SELECT version(); version ------------------------------------------------------------------------------------------------------------------------------------------------------ (openGauss 1.0.0 build 0bd0ce80) compiled at 2020-06-30 18:19:27 commit 0 last mr on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 8.2.0, 64-bit (1 row) postgres=# show server_version; server_version ---------------- 9.2.4
4.14 啟動和停止
[omm@opengauss openGauss]$ gs_om -t stop Stopping cluster. ========================================= Successfully stopped cluster. ========================================= End stop cluster. [omm@opengauss openGauss]$ gs_om -t start Starting cluster. ========================================= ========================================= Successfully started.
4.15 查看數據庫狀態
[omm@opengauss ~]$ gs_om -t status --detail [ Cluster State ] cluster_state : Normal redistributing : No current_az : AZ_ALL [ Datanode State ] node node_ip instance state -------------------------------------------------------------------------------------- 1 opengauss 10.10.20.173 6001 /opt/huawei/install/data/db1 P Primary Normal [omm@opengauss ~]$ gs_om -t status --all ----------------------------------------------------------------------- cluster_state : Normal redistributing : No ----------------------------------------------------------------------- node : 1 node_name : opengauss node : 1 instance_id : 6001 node_ip : 10.10.20.173 data_path : /opt/huawei/install/data/db1 type : Datanode instance_state : Primary static_connections : 0 HA_state : Normal reason : Normal sender_sent_location : 0/0 sender_write_location : 0/0 sender_flush_location : 0/0 sender_replay_location : 0/0 receiver_received_location: 0/0 receiver_write_location : 0/0 receiver_flush_location : 0/0 receiver_replay_location : 0/0 sync_state : Async
4.16 檢查數據庫性能
[omm@opengauss ~]$ gs_checkperf Cluster statistics information: Host CPU busy time ratio : .50 % MPPDB CPU time % in busy time : 61.06 % Shared Buffer Hit ratio : 96.73 % In-memory sort ratio : 0 Physical Reads : 448 Physical Writes : 92 DB size : 28 MB Total Physical writes : 92 Active SQL count : 3 Session count : 4
4.17 安裝目錄架構介紹
[omm@opengauss opt]$ tree -d -L 3 huawei/ huawei/ ├── corefile #core 文件存放目錄,類似於pg中的core文件,用於數據庫crash追蹤 ├── install │ ├── app -> /opt/huawei/install/app_0bd0ce80 #數據庫安裝路徑,為app_0bd0ce80的軟連接 │ ├── app_0bd0ce80 │ │ ├── bin #數據庫命令執行路徑 │ │ ├── etc #數據庫配置路徑(如kerberos路徑和雲上obs映射區域配置) │ │ ├── include #數據庫頭文件 │ │ ├── lib #動態鏈接庫 │ │ └── share #共享目錄庫(包括pg擴展和ssl根證書文件) │ ├── data #數據目錄 │ │ └── db1 #數據庫文件目錄 │ └── om #運維管理目錄 │ ├── lib #執行腳本使用庫 │ └── script #工具腳本路徑 └── tmp
五、后記
openGauss 安裝x86_64僅支持CentOS 7.6 版本以下操作系統,本次測試安裝的操作系統版本為RedHat 7.8 ,因此在執行 gs_preinstall 腳本時無法檢測通過。那是不是就不可以在RedHat操作系統和7.6以上的版本無法安裝呢?不是,可以通過修改系統版本的方式/etc/redhat-release騙過檢查。但是下一步又會出錯,因為它會去檢查安數據庫裝包,數據庫安裝包是以openGauss-1.0.0-CentOS-64bit.tar.bz2 命名的,所以無法檢查通過,該問題可以通過mv 命令將 CentOS更改為RedHat即可通過。再次執行會去找openGauss-1.0.0-CentOS-64bit.sha256 校驗文件。由於數據庫文件已經做了修改,此處以同樣方式修改openGauss-1.0.0-CentOS-64bit.sha256為openGauss-1.0.0-RedHat-64bit.sha256文件即可。