397 Star 1.3K Fork 1.5K

GVPopenGauss / openGauss-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

openGauss Logo

English | 简体中文

什么是openGauss

openGauss是一款开源的关系型数据库管理系统,它具有多核高性能、全链路安全性、智能运维等企业级特性。 openGauss内核早期源自开源数据库PostgreSQL,融合了华为在数据库领域多年的内核经验,在架构、事务、存储引擎、优化器及ARM架构上进行了适配与优化。作为一个开源数据库,期望与广泛的开发者共同构建一个多元化技术的开源数据库社区。

openGauss架构

高性能

openGauss突破了多核CPU的瓶颈,实现两路鲲鹏128核150万tpmC,内存优化表(MOT)引擎达350万tpmC。

数据分区

内部线程共享的关键数据结构进行数据分区,减少加锁访问冲突。比如CLOG就采用分区优化,解决ClogControlLock锁瓶颈。

NUMA化内核数据结构

关键数据结构NUMA化分配,减少跨CPU访问。比如全局PGPROC数组按照NUMA Node的数目分为多份,分别在对应NUMA Node上申请内存。解决ProcArrayLock锁瓶颈。

绑核优化

把网络中断绑核和后台业务线程绑核区分开,避免运行线程在核间迁移造成的性能不稳定。

ARM指令优化

结合ARM平台的原子操作lse进行优化,实现关键互斥变量原子高效操作。

SQL BY PASS

通过SQL BY PASS优化SQL执行流程,简化CPU执行开销。

高可靠

正常业务负载情况下,RTO小于10秒,降低节点故障导致的业务不可用时间。

并行恢复

主机日志传输到备机时,备机日志落盘的同时,发送给重做恢复分发线程,分发线程根据日志类型和日志操作的数据页发给多个并行恢复线程进行日志重做,保证备机的重做速度跟上主机日志的产生速度。这样备机实时处于ready状态,从而实现瞬间故障切换。

MOT引擎(Beta发布)

内存优化表(MOT)存储引擎是一个专为多核大内存优化的存储引擎,具有极高的联机事务处理(OLTP)性能和资源利用率。MOT的数据和索引完全存储在内存中,通过NUMA感知执行,算法消除闩锁争用以及查询JIT本地编译,提供低时延数据访问及高效事务执行。更多请参考MOT引擎文档

安全

openGauss支持账号管理,账号认证,口令复杂度检查,账号锁定,权限管理和校验,传输加密,操作 审计等全方位的数据库安全能力,保护业务满足安全要求。

易运维

openGauss将AI算法集成到数据库中,减少数据库维护的负担。

  • SQL预测

openGauss根据收集的历史性能数据进行编码和基于深度学习的训练及预测,支持SQL执行时间预测。

  • SQL诊断器

openGauss支持SQL执行语句的诊断器,提前发现慢查询。

  • 参数自动调整

openGauss通过机器学习方法自动调整数据库参数,提高调参效率,降低正确调参成本。

安装

创建配置文件

在安装openGauss之前,需要创建clusterconfig.xml配置文件。XML文件包含部署openGauss的服务器信息、安装路径、IP地址以及端口号等。用于告知openGauss如何部署。用户需根据不同场配置对应的XML文件。

下面以一主一备的部署方案为例,说明如何创建XML配置文件。 以下value取值信息仅为示例,可自行替换。每行信息均有注释进行说明。

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
    <!-- openGauss整体信息 -->
    <CLUSTER>
    <!-- 数据库名称 -->
        <PARAM name="clusterName" value="dbCluster" />
    <!-- 数据库节点名称(hostname) -->
        <PARAM name="nodeNames" value="node1,node2" />
    <!-- 节点IP,与nodeNames一一对应 -->
        <PARAM name="backIp1s" value="192.168.0.11,192.168.0.12"/>
    <!-- 数据库安装目录-->
        <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="node1"/>
        <!-- node1所在的AZ及AZ优先级 -->
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
        <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.11"/>
            <PARAM name="sshIp1" value="192.168.0.11"/>
            
	    <!--dbnode-->
	    	<PARAM name="dataNum" value="1"/>
	    <!--DBnode端口号-->
	    	<PARAM name="dataPortBase" value="26000"/>
	    <!--DBnode主节点上数据目录,及备机数据目录-->
	    	<PARAM name="dataNode1" value="/opt/huawei/install/data/db1,node2,/opt/huawei/install/data/db1"/>
	    <!--DBnode节点上设定同步模式的节点数-->
	    	<PARAM name="dataNode1_syncNum" value="0"/>
        </DEVICE>

        <!-- node2上的节点部署信息,其中“name”的值配置为主机名称(hostname) -->
        <DEVICE sn="1000002">
            <PARAM name="name" value="node2"/>
            <PARAM name="azName" value="AZ1"/>
            <PARAM name="azPriority" value="1"/>
            <!-- 如果服务器只有一个网卡可用,将backIP1和sshIP1配置成同一个IP -->
            <PARAM name="backIp1" value="192.168.0.12"/>
            <PARAM name="sshIp1" value="192.168.0.12"/>
	</DEVICE>
    </DEVICELIST>
</ROOT>

初始化安装环境

创建完openGauss配置文件后,在执行安装前,为了后续能以最小权限进行安装及openGauss管理操作,保证系统安全性,需要运行安装前置脚本gs_preinstall准备好安装用户及环境。

安装前置脚本gs_preinstall可以协助用户自动完成如下的安装环境准备工作:

  • 自动设置Linux内核参数以达到提高服务器负载能力的目的。这些参数直接影响数据库系统的运行状态,请仅在确认必要时调整。
  • 自动将openGauss配置文件、安装包拷贝到openGauss主机的相同目录下。
  • openGauss安装用户、用户组不存在时,自动创建安装用户以及用户组。
  • 读取openGauss配置文件中的目录信息并创建,将目录权限授予安装用户。

注意事项

  • 用户需要检查上层目录权限,保证安装用户对安装包和配置文件目录读写执行的权限。
  • xml文件中各主机的名称与IP映射配置正确。
  • 只能使用root用户执行gs_preinstall命令。

操作步骤

1.以root用户登录待安装openGauss的任意主机,并按规划创建存放安装包的目录。

mkdir -p /opt/software/openGauss
chmod 755 -R /opt/software

说明

  • 不建议把安装包的存放目录规划到openGauss用户的家目录或其子目录下,可能导致权限问题。
  • openGauss用户须具有/opt/software/openGauss目录的读写权限。

2.将安装包“openGauss-x.x.x-openEULER-64bit.tar.gz”和配置文件“clusterconfig.xml”都上传至上一步所创建的目录中。

3.在安装包所在的目录下,解压安装包openGauss-x.x.x-openEULER-64bit.tar.gz。安装包解压后,在/opt/software/openGauss目录下自动生成script目录。在script目录下生成gs_preinstall等OM工具脚本。

cd /opt/software/openGauss
tar -zxvf openGauss-x.x.x-openEULER-64bit.tar.gz

4.进入工具脚本目录。

cd /opt/software/openGauss/script

5.如果是openEuler的操作系统,执行如下命令打开performance.sh文件,用#注释sysctl -w vm.min_free_kbytes=112640 &> /dev/null,键入“ESC”键进入指令模式,执行 :wq保存并退出修改。

vi /etc/profile.d/performance.sh

6.为确保openssl版本正确,执行预安装前请加载安装包中lib库。执行命令如下,其中 {packagePath} 为用户安装包放置的路径,本示例中为/opt/software/openGauss。

export LD_LIBRARY_PATH={packagePath}/script/gspylib/clib:$LD_LIBRARY_PATH

7.为确保成功安装,检查 hostname 与 /etc/hostname 是否一致。预安装过程中,会对hostname进行检查。

8.使用gs_preinstall准备好安装环境。若为共用环境需加入--sep-env-file=ENVFILE参数分离环境变量,避免与其他用户相互影响,ENVFILE为用户自行指定的环境变量分离文件的路径。 执行如下命令,即采用交互模式执行前置,并在执行过程中自动创建root用户互信和openGauss用户互信:

./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.(可选)检查安装包和openGauss配置文件在规划路径下是否已存在,如果没有,重新执行预安装,确保预安装成功,再执行以下步骤。

2.登录到openGauss的主机,并切换到omm用户。

su - omm

说明

  • omm为gs_preinstall脚本中-U参数指定的用户。
  • 以上述omm用户执行gs_install脚本。否则会报执行错误。

3.使用gs_install安装openGauss。若为环境变量分离的模式安装的集群需要source环境变量分离文件ENVFILE。

gs_install -X /opt/software/openGauss/clusterconfig.xml

/opt/software/openGauss/script/clusterconfig.xml为openGauss配置文件的路径。在执行过程中,用户需根据提示输入数据库的密码,密码具有一定的复杂度,为保证用户正常使用该数据库,请记住输入的数据库密码。

密码复杂度要求:

  • 长度至少8个字符。
  • 不能和用户名、当前密码(ALTER)、当前密码的倒序相同。
  • 以下至少包含三类:大写字母(A - Z)、小写字母(a - z)、数字(0 - 9)、其他字符(仅限~!@#$%^&*()-_=+|[{}];:,<.>/?)。

4.安装执行成功之后,需要手动删除主机root用户的互信,即删除openGauss数据库各节点上的互信文件。

rm -rf ~/.ssh

卸载openGauss

卸载openGauss的过程包括卸载openGauss和清理openGauss服务器环境。

执行卸载

openGauss提供了卸载脚本,帮助用户卸载openGauss。

操作步骤

1.以操作系统用户omm登录数据库主节点。

2.使用gs_uninstall卸载openGauss。

gs_uninstall --delete-data

或者在openGauss中每个节点执行本地卸载。

gs_uninstall --delete-data -L

一键式环境清理

在openGauss卸载完成后,如果不需要在环境上重新部署openGauss,可以运行脚本gs_postuninstall对openGauss服务器上环境信息做清理。openGauss环境清理是对环境准备脚本gs_preinstall所做设置的清理。 前提条件

  • openGauss卸载执行成功。
  • root用户互信可用。
  • 只能使用root用户执行gs_postuninstall命令。

操作步骤

1.以root用户登录openGauss服务器。

2.查看互信是否建成功,可以互相执行ssh 主机名。输入exit退出。

plat1:~ # ssh plat2 
Last login: Tue Jan  5 10:28:18 2016 from plat1 
plat2:~ # exit 
logout 
Connection to plat2 closed. 
plat1:~ #

3.进入script路径下。

cd /opt/software/openGauss/script

4.使用gs_postuninstall进行清理。若为环境变量分离的模式安装的集群需要source环境变量分离文件ENVFILE。

./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group

或者在openGauss中每个节点执行本地后置清理。

./gs_postuninstall -U omm -X /opt/software/openGauss/clusterconfig.xml --delete-user --delete-group -L

omm为运行openGauss的操作系统用户名,/opt/software/openGauss/clusterconfig.xml为openGauss配置文件路径。

若为环境变量分离的模式安装的集群需删除之前source的环境变量分离的env参数unset MPPDB_ENV_SEPARATE_PATH

5.删除各openGauss数据库节点root用户互信。

编译

概述

编译openGauss需要openGauss-server和binarylibs两个组件。

  • openGauss-server:openGauss的主要代码。可以从开源社区获取。

  • binarylibs:openGauss依赖的第三方开源软件,你可以直接编译openGauss-third_party代码获取,也可以从开源社区下载已经编译好的并上传的一个副本。

对于数据库、三方库、GCC的编译以及常见问题,参照博客openGauss数据库编译指导

在编译openGauss之前,请检查操作系统和软件依赖要求。

openGauss可以通过一键式shell工具build.sh进行编译,也可以通过命令进行编译。安装包由build.sh生成。

操作系统和软件依赖要求

openGauss支持以下操作系统:

  • CentOS 7.6(x86架构)

  • openEuler-20.03-LTS(aarch64架构)

适配其他系统,参照博客openGauss数据库编译指导

以下表格列举了编译openGauss的软件要求。

建议使用从列出的操作系统安装盘或安装源中获取的以下依赖软件的默认安装包进行安装。如果不存在以下软件,请参考推荐的软件版本。

软件依赖要求如下:

软件 推荐版本
libaio-devel 0.3.109-13
flex 2.5.31及以上版本
bison 2.7-4
ncurses-devel 5.9-13.20130511
glibc-devel 2.17-111
patch 2.7.1-10
lsb_release 4.1
readline-devel 7.0-13

下载openGauss

可以从开源社区下载openGauss-server和openGauss-third_party。

https://opengauss.org/zh/

可以通过以下网站获取编译好的binarylibs。下载后请解压缩并重命名为binarylibs

各版本和分支对应编译好的三方库二进制地址如下:

分支 tag gcc版本 下载路径
1.0.0 v1.0.0 gcc7.3 https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.0.0/openGauss-third_party_binarylibs.tar.gz
v1.0.1
1.1.0 v1.1.0 gcc7.3 https://opengauss.obs.cn-south-1.myhuaweicloud.com/1.1.0/openGauss-third_party_binarylibs.tar.gz
2.0.0 v2.0.0 gcc7.3 https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.0/openGauss-third_party_binarylibs.tar.gz
v2.0.1
v2.0.2
v2.0.3
v2.0.4
v2.0.5
2.1.0 v2.1.0 gcc7.3 https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.1.0/openGauss-third_party_binarylibs.tar.gz
3.0.0 v3.0.0 gcc7.3 https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/openGauss-third_party_binarylibs.tar.gz
v3.0.1
v3.0.2
v3.0.3 openEuler_arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm-3.0.3.tar.gz
openEuler_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64-3.0.3.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64-3.0.3.tar.gz
3.1.0 v3.1.0 gcc7.3 openEuler_arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
v3.1.1
5.0.0 v5.0.0 gcc7.3 openEuler 20.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler 20.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
openEuler 22.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs_2203/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz
openEuler 22.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs_2203/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz
5.1.0 v5.1.0 gcc7.3 openEuler 20.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler 20.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc7.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
openEuler 22.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz
openEuler 22.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz
gcc10.3 openEuler 20.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler 20.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
openEuler 22.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz
openEuler 22.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.1.0/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz
master gcc7.3 openEuler_arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc7.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
openEuler 22.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz
openEuler 22.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc7.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz
gcc10.3 openEuler_arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
openEuler_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz
Centos_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
openEuler 22.03 arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_arm.tar.gz
openEuler 22.03 x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/gcc10.3/openGauss-third_party_binarylibs_openEuler_2203_x86_64.tar.gz

现在我们已经拥有完整的openGauss代码,把它存储在以下目录中(以sda为例)。

  • /sda/openGauss-server
  • /sda/binarylibs
  • /sda/openGauss-third_party

编译第三方软件

在编译openGauss之前,需要先编译openGauss依赖的开源及第三方软件。这些开源及第三方软件存储在openGauss-third_party代码仓库中,通常只需要构建一次。如果开源软件有更新,需要重新构建软件。

用户也可以直接从binarylibs库中获取开源软件编译和构建的输出文件。

如果你想自己编译第三方软件,请到openGauss-third_party仓库查看详情。

执行完上述脚本后,最终编译和构建的结果保存在与openGauss-third_party同级的binarylibs目录下。在编译openGauss-server时会用到这些文件。

代码编译

使用build.sh编译代码

openGauss-server中的build.sh是编译过程中的重要脚本工具。该工具集成了软件安装编译和产品安装包编译功能,可快速进行代码编译和打包。。

参数说明请见以下表格。

选项 缺省值 参数 说明
-h 请勿使用此选项。 - 帮助菜单。
-m release [debug | release | memcheck] 选择目标版本。
-3rd ${Code directory}/binarylibs [binarylibs path] 指定binarylibs路径。该路径必须是绝对路径。
-pkg 请勿使用此选项。 - 将代码编译结果压缩至安装包。
-nopt 请勿使用此选项。 - 如果使用此功能,则对鲲鹏平台的相关CPU不进行优化。

注意

  • -m [debug | release | memcheck] 表示有三个目标版本可以选择:
    • release:生成release版本的二进制程序。此版本编译时,通过配置GCC高级优化选项,去除内核调试代码。此选项通常在生成环境或性能测试环境中使用。
    • debug:表示生成debug版本的二进制程序。此版本编译时,增加了内核代码调试功能,一般用于开发自测环境。
    • memcheck:表示生成memcheck版本的二进制程序。此版本编译时,在debug版本的基础上增加了ASAN功能,用于定位内存问题。
  • -3rd [binarylibs path]为binarylibs的路径。默认设置为当前代码文件夹下存在binarylibs,因此如果binarylibs被移至openGauss-server中,或者在openGauss-server中创建了到binarylibs的软链接,则不需要指定此参数。但请注意,这样做的话,该文件很容易被git clean命令删除。
  • 该脚本中的每个选项都有一个默认值。选项数量少,依赖简单。因此,该脚本易于使用。如果实际需要的参数值与默认值不同,请根据实际情况配置。

现在你已经知晓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       # 编译安装release版本的openGauss。需代码目录下有binarylibs或者其软链接,否则将会失败。
[user@linux openGauss-server]$ sh build.sh -m debug -3rd /sda/binarylibs    # 编译安装debug版本的openGauss

编译后的软件安装路径为:/sda/openGauss-server/dest

编译后的二进制文件路径为:/sda/openGauss-server/dest/bin

编译日志: make_compile.log

使用命令编译代码

1.获取对应的开源三方库二进制文件:

从3.1.0分支和3.0.3 tag开始,对于不同的环境提供不同的开源三方库二进制文件。 目前社区提供Centos_x86_64, openEuler_aarch64, openEuler_x86_64三种平台的三方库二进制。 可以从对应地址下载 下载openGauss

2.配置环境变量

export CODE_BASE=________     # openGauss-server的路径
export BINARYLIBS=________    # binarylibs的路径
export GAUSSHOME=$CODE_BASE/dest/
export GCC_PATH=$BINARYLIBS/buildtools/________    # gcc的版本,根据三方包中对应的gcc版本进行填写即可,一般有gcc7.3或gcc10.3两种
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版本:

# gcc7.3.0版本
./configure --gcc-version=7.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib

# gcc10.3.1版本(一般用于openEuler + ARM架构)
./configure --gcc-version=10.3.1 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib

# gcc10.3.0版本
./configure --gcc-version=10.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib

release版本:

# gcc7.3.0版本
./configure --gcc-version=7.3.0 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --with-readline --without-zlib

# gcc10.3.1版本(一般用于openEuler + ARM架构)
./configure --gcc-version=10.3.1 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --with-readline --without-zlib

# gcc10.3.0版本
./configure --gcc-version=10.3.0 CC=g++ CFLAGS="-O2 -g3" --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-thread-safety --with-readline --without-zlib

memcheck版本:

# gcc7.3.0版本
./configure --gcc-version=7.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib --enable-memory-check

# gcc10.3.1版本(一般用于openEuler + ARM架构)
./configure --gcc-version=10.3.1 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib --enable-memory-check

# gcc10.3.0版本
./configure --gcc-version=10.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib --enable-memory-check

注意

  • [debug | release | memcheck] 表示有三个目标版本可用。
  • ARM平台上,需要把 -D__USE_NUMA 添加至 CFLAGS 中。
  • ARMv8.1及以上平台(如鲲鹏920),需要把 -D__ARM_LSE 添加至CFLAGS中。
  • 如果binarylibs被移至openGauss-server中,或者在openGauss-server中创建了到binarylibs的软链接,则不需要指定 --3rd 参数。但请注意,这样做的话,该文件很容易被git clean命令删除。

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

举例:

sh build.sh -pkg       # 生成release版本的openGauss安装包。需代码目录下有binarylibs或者其软链接,否则将会失败。
sh build.sh -m debug -3rd /sdc/binarylibs -pkg           # 生成debug版本的openGauss安装包
  • 生成的安装包存放目录:./package

  • 编译日志: make_compile.log

  • 安装包打包日志: ./package/make_package.log

快速入门

参考快速入门

文档

更多安装指南、教程和API请参考用户文档

社区

治理

查看openGauss是如何实现开放治理

交流

贡献

欢迎大家来参与贡献。详情请参阅我们的社区贡献

发行说明

请参见发行说明

许可证

MulanPSL-2.0

木兰宽松许可证, 第2版 2020年1月 http://license.coscl.org.cn/MulanPSL2 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 0. 定义 “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体” 是指提交贡献的机构及其“关联实体”。 “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 6. 语言 “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 条款结束 如何将木兰宽松许可证,第2版,应用到您的软件 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package; Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.

简介

openGauss kernel ~ openGauss is an open source relational database management system. 展开 收起
MulanPSL-2.0
取消

发行版 (9)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/opengauss/openGauss-server.git
git@gitee.com:opengauss/openGauss-server.git
opengauss
openGauss-server
openGauss-server
master

搜索帮助

14c37bed 8189591 565d56ea 8189591