# openGauss-server
**Repository Path**: Datrilla/openGauss-server
## Basic Information
- **Project Name**: openGauss-server
- **Description**: openGauss kernel ~ openGauss is an open source relational database management system.
- **Primary Language**: C++
- **License**: MulanPSL-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1818
- **Created**: 2020-07-04
- **Last Updated**: 2024-06-08
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

- [什么是openGauss](#什么是openGauss)
- [安装](#安装)
- [创建配置文件](#创建配置文件)
- [初始化和安装环境](#初始化和安装环境)
- [执行安装](#执行安装)
- [卸载openGauss](#卸载openGauss)
- [编译](#编译)
- [概要](#概要)
- [操作系统和必要依赖软件](#操作系统和必要依赖软件)
- [下载openGauss](#下载openGauss)
- [编译第三方软件](#编译第三方软件)
- [使用 build.sh编译](#使用-build.sh编译)
- [通过命令编译](#通过命令编译)
- [编译安装包](#编译安装包)
- [快速启动](#快速启动)
- [文档](#文档)
- [社区](#社区)
- [Governance](#governance)
- [讨论](#讨论)
- [Contribution](#contribution)
- [Release Notes](#release-notes)
- [许可证](#许可证)
## 什么是openGauss
openGauss 是一个开源关系型数据库系统.具有多核、高性能, full link security, intelligent operation and maintenance for enterprise features. openGauss, which is early originated from PostgreSQL, integrates Huawei's core experience in database field for many years. It optimizes the architecture, transaction, storage engine, optimizer and ARM architecture. At the meantime, openGauss as a global database open source community, aims to further advance the development and enrichment of the database software/hardware application ecosystem.
**高性能**
openGauss breaks through the bottleneck of multi-core CPU, 2-way Kunpeng 128 core 1.5 million TPMC on disk-based row store and 3.5 million TPMC on MOT (Memory-Optimized Tables) Engine.
**分区**
Divide key data structure shared by internal threads into different partitions to reduce lock access conflicts. For example, CLOG uses partition optimization to solve the bottleneck of ClogControlLock.
**NUMA 结构**
Malloc key data structures help reduce cross CPU access. The global PGPROC array is divided into several parts according to the number of NUMA nodes, solving the bottleneck of ProcArrayLock.
**核绑定**
Bind NIC interrupts to different cores and bind cores to different background threads to avoid performance instability due to thread migration between cores.
**ARM 优化**
Optimize atomic operations based on ARM platform LSE instructions, implementing efficient operation of critical sections.
**SQL Bypass**
Optimize SQL execution process through SQL bypass, 减少CPU执行开销.
**高可靠性**
Under normal service loads, the RTO is less than 10 seconds, reducing the service interruption time caused by node failure.
**并发恢复**
When the Xlog is transferred to the standby node, the standby node flushs the Xlog to storage medium. At the meantime, the Xlog is sent to the redo recovery dispatch thread. The dispatch thread sends the Xlog to multiple parallel recovery threads to replay. Ensure that the redo speed of the standby node keeps up with the generation speed of the primary host. The standby node is ready in real time, which can be promoted to primary instantly.
**MOT 引擎 (beta release)**
The Memory-Optimized Tables (MOT) storage engine is a transactional rowstore optimized for many-core and large memory and delivering extreme OLTP performance and high resources utilization. With data and indexes stored totally in-memory, a NUMA-aware design, algorithms that eliminate lock and latch contention and query native compilation (JIT), MOT provides low latency data access and more efficient transaction execution. See MOT Engine documentation (https://opengauss.org/en/docs/1.0.0/docs/Developerguide/mot.html).
**安全性**
支持账户管理,账户鉴权,账户锁定,密码复杂度检查,权限管理和认证,传输加密, 和操作审计,保护服务数据安全。
**简单操作和维持**
openGauss integrates AI algorithms into databases, reducing the burden of database maintenance.
- **SQL 预测**
openGauss supports SQL execution time prediction based on collected historical performance data.
- **SQL Diagnoser**
openGauss supports the diagnoser for SQL execution statements, finding out slow queries in advance..
- **参数自动调整**
openGauss supports automatically adjusting database parameters, reducing the cost and time of parameter adjustment.
## 安装
### 创建配置文件
安装 openGauss之前, 需要创建一个配置文件。配置文件采用XML格式,包含openGauss要在哪里部署,安装位置
IP地址,端口号。该文件用于引导如何不是openGauss.你需要根据实际需求进行配置。
以下将描述基于开发一个私有节点和备用节点的方案创建一个XML配置文件。
这只是一个样例值,你可以根据需要替换。每一行的配置项均有给出注释。
```
```
### 初始化和安装环境
创建好配置文件之后,你需要运行 gs_preinstall 脚本以准备一个账户和环境,这样你可以在最少的权限下执行
安装openGauss和管理操作,以确保系统安全。
**注意事项**
- 你必须检查上层目录权限,确保用户对安装包和配置文件目录有读写执行权限。
- XML配置文件中每个域名和IP映射必须正确 。
- 仅准许root用户可以执行gs_reinstall命令。
**步骤**
1. root登入到任意的将会安装openGauss的主机,创建目录计划用于存储安装包.
```
mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software
```
> *注意:**
>
> - 不要在home或者其他openGauss用户下创建目录因为你会缺少这些子目录的权限.
> - openGauss用户必须有目录/opt/software/openGauss的读写权限.
2. 这里用发布的包作为一个样例.上传安装包openGauss_x.x.x_PACKAGES_RELEASE.tar.gz和之前创建的配置文件
到目录下 clusterconfig.xml
3. 进去存储软件包目录并解压.
```
cd /opt/software/openGauss
tar -zxvf openGauss_x.x.x_PACKAGES_RELEASE.tar.gz
```
4. 解压openGauss-x.x.x-openEULER-64bit.tar.gz .
```
tar -zxvf openGauss-x.x.x-openEULER-64bit.tar.gz
```
解压安装包后,脚本子目录会被自动生成在目录/opt/software/openGauss里。
OM工具脚本例如gs_preinstall将会在该脚本子目录下。
5. 进入存储脚本工具的目录
```
cd /opt/software/openGauss/script
```
6. 确保OpenSSL的版本是正确的,预安装之前加载opensll的lib库。(后面复杂的有说明这种第三方依赖库)
运行以下命令. {packagePath} 指示安装包存储位置.本样例中,路径是/opt/software/openGauss.
```
export LD_LIBRARY_PATH={packagePath}/script/gspylib/clib:$LD_LIBRARY_PATH
```
7. 为了确保能成功安装,检查域名和/etc/hostname是否一致. 预安装时,域名已经被检查。
8.执行gs_preinstall以配置安装环境. 如果使用共享环境,增加--sep-env-file=ENVFILE 参数以隔离环境变量避免
和其他用户相互影响。环境隔离变量文件路径由用户指定。
交互模式下执行gs_preinstall.在执行期间,root用户和clusteropenGauss用户信任是自动建立的.
```
./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/clusterconfig.xml
```
omm 数据库管理员 (也是运行openGauss的系统用户), dbgrp是运行openGauss系统用户的群组,
/opt/software/openGauss/clusterconfig.xml是openGauss配置文件的路径 。在执行期间,
你需要根据提示词决定是否建立信任,并输入root用户或openGauss用户的密码。
### 执行安装
在执行预安装脚本准备好了安装openGauss的环境后,部署openGauss的基本安装过程.
**前提条件**
- 你已经成功执行gs_preinstall 脚本.
- 操作系统和网络服务全部运行正常.
- 你需要检查所有服务的locale参数都设置相同.
**步骤**
1. (可选)检查安装包和配置问津是否已经存在与计划目录下。如果不存在,再次执行预安装。
2. 登入openGauss的主机,切换到omm用户
```
su - omm
```
> **NOTE:**
>
> - omm 是在gs_preinstall脚本中通过-U参数指定的用户
> - 你需要使用gs_preinstall脚本指定的omm用户执行gs_install脚本。否则,执行将会报错。
3. 使用gs_install 安装openGauss.如果openGauss是在环境变量隔离模式下安装,那么运行source命令以从文件ENVFILE获得隔离的环境变量
```
#隔离变量才需要
source ENVFILE
#等价于点命令
. ENVFILE
```
```
gs_install -X /opt/software/openGauss/clusterconfig.xml
```
密码是复杂度必须满足:
- 至少八个字符.
- 不能和用户名、当前密码(修改时)、密码反序 相同.
- 至少符合以下三条:大写字母(A到Z),小写字母 (a到z), 数字(0 到9), 或者其他字符 (限定 ~!@#$%^&*()-_=+\|[{}];:,<.>/?).
4. 成功安装之后,手动删除主机root用户建信任,删除每个openGauss数据库节点的信任文件。
```
rm -rf ~/.ssh
```
### 卸载openGauss
卸载过程包括卸载openGauss 和清除oprenGauss服务环境.
#### **执行卸载**
openGauss提供了卸载脚本以帮助用户卸载openGauss.
**步骤**
1. 用操作系统用户omm登入CN定位的主机.
2. 执行 gs_uninstall 脚本卸载数据库集群.
```
gs_uninstall --delete-data
```
或者,到每个openGauss节点执行卸载.
```
gs_uninstall --delete-data -L
```
#### **删除openGauss 配置项**
卸载 openGauss 之后,如果你不需要再使用配置项部署openGauss,那么执行gs_postuninstall 脚本删除所有的服务配置。
这些配置项都是通过gs_preinstall脚本制作的。
**必要条件**
- openGauss 卸载任务成功执行.
- root用户有权限.
- 仅准许root用户执行gs_postuninstall命令.
**步骤**
1. 使用root用户登入openGauss服务
2. 云习惯ssh 域名命令检查是否可信任成功建立.然后退出.
```
plat1:~ # ssh plat2
Last login: Tue Jan 5 10:28:18 2016 from plat1
plat2:~ # exit
logout
Connection to plat2 closed.
plat1:~ #
```
3. 进入一下路径:
```
cd /opt/software/openGauss/script
```
4. 运行gs_postuninstall命令清除环境。如果安装openGauss的时候是环境变量隔离的模式,运行source命令以获得隔离文件ENVFILE的环境变量
```
#隔离变量才需要
source ENVFILE
#等价于点命令
. ENVFILE
```
```
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group
```
或者,本地登入到每个openGauss节点使用 gs_postuninstall 工具清除.
```
./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group -L
```
omm 是运行openGauss的操作系统用户,
/opt/software/openGauss/clusterconfig.xml.是openGauss的配置文件路径
如果集群安装环境是用环境变量隔离模式,那么删除隔离环境变量的参数要通过运行source命令获取。
```
unset MPPDB_ENV_SEPARATE_PATH
```
5. 在每台openGauss数据库节点删除root用户信任.
## 复杂事项
### 概要
为了编译openGauss,你需要两个组件: openGauss-server 和 binarylibs.
- openGauss-server: 主要代码. 可以通过本开源社区获得.
- binarylibs:依赖的第三方开源软件.可以通过编译openGauss-third_party 代码或者到社区下载我们已经编译好的并上传的副本,第一个方法将在下述章节介绍。
在你编译openGauss之前,请确认操作系统和必要软件依赖.
你需要使用build.sh编译 openGauss ,这个一键式编译shell脚本工具, 我们将在会稍后介绍它。
或者通过命令编译。build.sh也会产生安装包.
### 操作系统和必要依赖软件
支持以下操作系统:
- CentOS 7.6 (x86 architecture)
- openEuler-20.03-LTS (aarch64 architecture)
以下表格清单为编译openGauss的必要依赖软件.
建议你使用操作系统默认的安装包,如果不存在,建议使用这些软件的这些版本。
必要依赖软件如下:
| Software | Recommended Version |
| ------------- | ------------------- |
| libaio-devel | 0.3.109-13 |
| flex | 2.5.31 or later |
| bison | 2.7-4 |
| ncurses-devel | 5.9-13.20130511 |
| glibc.devel | 2.17-111 |
| patch | 2.7.1-10 |
| lsb_release | 4.1 |
### 下载openGauss
可通过该社区下载 openGauss-server 和 openGauss-third_party .
https://opengauss.org/zh/
在下链接, 你可以获得编译好的binarylibs.下载后请解压并重命名为**binarylibs** .
https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.0.0/openGauss-third_party_binarylibs.tar.gz
下载我们有了完整的openGauss代码, 例如, 我们把他们存储在以下目录.
- /sda/openGauss-server
- /sda/binarylibs
- /sda/openGauss-third_party
### 编译第三方软件
Before compiling the openGauss, compile and build the open-source and third-party software on which the openGauss depends. These open-source and third-party software is stored in the openGauss-third_party code repository and usually needs to be built only once. If the open-source software is updated, rebuild the software.
You can also directly obtain the output file of the open-source software compilation and build from the **binarylibs** repository.
If you want to compile third-party by yourself, please go to openGauss-third_party repository to see details.
After the preceding script is executed, the final compilation and build result is stored in the **binarylibs** directory at the same level as **openGauss-third_party**. These files will be used during the compilation of **openGauss-server**.
### 使用 build.sh编译
build.sh 是 openGauss-server 编译期间一个重要的脚本工具. It integrates software installation and compilation and product installation package compilation functions to quickly compile and package code.
The following table describes the parameters.
| Option | Default Value | Parameter | Description |
| :----- | :--------------------------- | :----------------------------- | :----------------------------------------------------------- |
| -h | Do not use this option. | - | Help menu. |
| -m | release | [debug \| release \| memcheck] | Selects the target version. |
| -3rd | ${Code directory}/binarylibs | [binarylibs path] | Specifies the path of binarylibs. The path must be an absolute path. |
| -pkg | Do not use this option. | - | Compresses the code compilation result into an installation package. |
| -nopt | Do not use this option. | - | On kunpeng platform, like 1616 version, without LSE optimized. |
> **NOTICE:**
>
> 1. **-m [debug | release | memcheck]** indicates that three target versions can be selected:
> - **release**: indicates that the binary program of the release version is generated. During compilation of this version, the GCC 高度优化 配置一处内核调试代码. 通常适用于生产环境和高性能测试环境.
> - **debug**: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, 用于开发期间的自测环境.
> - **memcheck**: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN增加了内存问题调试(应该是valgrind的类似).
> 2. **-3rd [binarylibs path]** is the path of **binarylibs**. By default, **binarylibs** exists in the current code folder. If **binarylibs** is moved to **openGauss-server** or a soft link to **binarylibs** is created in **openGauss-server**, you do not need to specify the parameter. However, if you do so, please note that the file is easy to be deleted by the **git clean** command.
> 3. Each option in this script has a default value. The number of options is small and the dependency is simple. Therefore, this script is easy to use. If the required value is different from the default value, set this parameter based on the actual requirements.
现在你已经知道了如何使用 build.sh,你可以使用build.sh通过一条命令编译openGauss-server .
```
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path]
```
样例:
```
[user@linux openGauss-server]$ sh build.sh # Compile openGauss of the release version. The binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
[user@linux openGauss-server]$ sh build.sh -m debug -3rd /sda/binarylibs # Compilate openGauss of the debug version using binarylibs we put on /sda/
```
软件编译后的路径**/sda/openGauss-server/dest**.
编译的二进制文件存储在 **/sda/openGauss-server/dest/bin**.
编译的日志: **make_compile.log**
### 通过命令编译
1. 执行以下脚本获得系统版本:
```
[user@linux openGauss-server]$ sh src/get_PlatForm_str.sh
```
> **注意:**
>
> - The command output indicates the OSs supported by the openGauss. The OSs supported by the openGauss are centos7.6_x86_64 and openeuler_aarch64.
> - If **Failed** or another version is displayed, the openGauss does not support the current operating system.
2. 配置环境变量, 基于代码下载的路径增加 **____** ,并使用上一步骤的结果替换掉 *** .
```
export CODE_BASE=________ # Path of the openGauss-server file
export BINARYLIBS=________ # Path of the binarylibs file
export GAUSSHOME=$CODE_BASE/dest/
export GCC_PATH=$BINARYLIBS/buildtools/***/gcc8.2/
export CC=$GCC_PATH/gcc/bin/gcc
export CXX=$GCC_PATH/gcc/bin/g++
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$GCC_PATH/gcc/lib64:$GCC_PATH/isl/lib:$GCC_PATH/mpc/lib/:$GCC_PATH/mpfr/lib/:$GCC_PATH/gmp/lib/:$LD_LIBRARY_PATH
export PATH=$GAUSSHOME/bin:$GCC_PATH/gcc/bin:$PATH
```
例如, 在 CENTOS X86-64 平台, binarylibs 目录位于 openGauss-server 目录的同级目录.
以下命令可以在openGauss-server目录下执行.
```
export CODE_BASE=`pwd`
export BINARYLIBS=`pwd`/../binarylibs
export GAUSSHOME=$CODE_BASE/dest/
export GCC_PATH=$BINARYLIBS/buildtools/centos7.6_x86_64/gcc8.2/
export CC=$GCC_PATH/gcc/bin/gcc
export CXX=$GCC_PATH/gcc/bin/g++
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$GCC_PATH/gcc/lib64:$GCC_PATH/isl/lib:$GCC_PATH/mpc/lib/:$GCC_PATH/mpfr/lib/:$GCC_PATH/gmp/lib/:$LD_LIBRARY_PATH
export PATH=$GAUSSHOME/bin:$GCC_PATH/gcc/bin:$PATH
```
3. 选择版本并配置.
**debug** version 调试版本:
```
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib
```
**release** version 发布版本:
```
./configure --gcc-version=8.2.0 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --without-readline --without-zlib
```
**memcheck** version 内存检查版本:
```
./configure --gcc-version=8.2.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib --enable-memory-check
```
> **注意:**
>
> 1. *[debug | release | memcheck]* 三种模式均可.
> 2. 在 ARM-based 平台, **-D__USE_NUMA** 需要被加到变量标签中 **CFLAGS**.
> 3. 在**ARMv8.1** 平台或更新版本 (如, Kunpeng 920), **-D__ARM_LSE**需要被加到 **CFLAGS**.
> 4. 如果 **binarylibs** is moved to **openGauss-server** or a soft link to **binarylibs** is created in **openGauss-server**, you do not need to specify the **--3rd** parameter. However, if you do so, please note that the file is easy to be deleted by the `git clean` command.
4.执行以下命令进行编译和安装 openGauss:
```
[user@linux openGauss-server]$ make -sj
[user@linux openGauss-server]$ make install -sj
```
5. 如果有显示下述文字, 说明成功编译安装:
```
openGauss installation complete.
```
软件编译后的路径 **$GAUSSHOME**.
编译后二进制文件存储的路径 **$GAUSSHOME/bin**.
### 编译安装包
请读取 **通过 build.sh编译** 先了解 build.sh的使用和怎么通过该脚本编译 openGauss .
你可以安装包仅通过增加选项`-pkg`.
```
[user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path] -pkg
```
样例:
```
[user@linux openGauss-server]$ sh build.sh -pkg # Compile openGauss installation package of the release version. The binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
[user@linux openGauss-server]$ sh build.sh -m debug -3rd /sda/binarylibs -pkg # Compile openGauss installation package of the debug version using binarylibs we put on /sda/
```
生成的安装包存储在 **./package** 目录.
编译日志: **make_compile.log**
安装包日志: **./package/make_package.log**
## 快速启动
见 [Quick Start](https://opengauss.org/en/docs/1.0.0/docs/Quickstart/Quickstart.html) to implement the image classification.
## 文档
更多安装引导教程和接口详见, [User Documentation](https://gitee.com/opengauss/docs).
## 社区
### Governance
Check out how openGauss implements open governance [works](https://gitee.com/opengauss/community/blob/master/governance.md).
### 讨论
- WeLink- Communication platform for developers.
- IRC channel at `#opengauss-meeting` (only for meeting minutes logging purpose)
- Mailing-list: https://opengauss.org/en/community/onlineCommunication.html
## Contribution
Welcome contributions. See our [Contributor](https://opengauss.org/en/contribution.html) for more details.
## Release Notes
For the release notes, see our [RELEASE](https://opengauss.org/en/docs/1.0.0/docs/Releasenotes/Releasenotes.html).
## License
[MulanPSL-2.0](http://license.coscl.org.cn/MulanPSL2/)