openGauss
开源数据库
openGauss社区官网
开源社区
openGauss从源码到自动化
openGauss 从源码到自动化
openGauss
openGauss 是一款开源关系型数据库管理系统,采用木兰宽松许可证 v2 发行。openGauss 内核源自 PostgreSQL,深度融合华为在数据库领域多年的经验,结合企业级场景需求,持续构建竞争力特性。同时 openGauss 也是一个开源的数据库平台,鼓励社区贡献、合作。
官网地址:https://opengauss.org/zh/
社区地址:https://gitee.com/opengauss/openGauss-server
openGauss Support Release-2020/12/01
- centos_x86_64
- openeuler_aarch64
- openeuler_x86_64
- asianux_x86_64
因客户需求对红旗系统进行适配。
Adapted Asianux System
编译 openGauss 需要 openGauss-server 和 binarylibs 两个组件。
openGauss-server:openGauss 的主要代码。可以从开源社区获取。
binarylibs:openGauss 依赖的第三方开源软件,你可以直接编译 openGauss-third_party 代码获取,也可以从开源社区下载已经编译好的并上传的一个副本。
openGauss 对于操作系统的限制在于 openGauss-third_party,和 OM 工具的限制,内核本身没有操作系统限制;所以修改 OM 工具和和三方库进行适配。
主要修改文件
详细修改内容
openGauss-third_party: https://gitee.com/opengauss/openGauss-third_party/pulls/31
openGauss-server: https://gitee.com/opengauss/openGauss-server/pulls/448/files
Compile openGauss-third_party
拉取源码
[root@asianux] git clone https://gitee.com/opengauss/openGauss-third_party.git
[root@asianux openGauss-third_party]# ls
build buildtools CONTRIBUTING.md dependency platform README.md Third_Party_Open_Source_Software_Notice
build directory includes scripts that can build all of the third-party that we depend on.
buildtools includes the build tools used to compile these opensources and openGauss-server.
dependency includes all depended opensource files of openGauss-server.
platform includes the opensource software from Huawei company
下载 gcc,放在如下位置
[root@asianux gcc]# pwd
/opt/openGauss-third_party/buildtools/gcc
[root@asianux gcc]# ls
build.sh config.ini gcc-8.2.0.tar.gz
gcc 下载链接 gcc-8.2.0.zip or gcc-8.2.0.tar.gz
安装依赖包
[root@asianux] yum install -y libaio-devel ncurses-devel pam-devel libffi-devel python3-devel glibc-devel libtool autoconf flex patch bison dkms rsync gcc-c++
执行编译
该环境为 16c/64g,对内存要求 32g 及以上。
[root@asianux build]# pwd
/opt/openGauss-third_party/build
[root@asianux build]# nohup sh build_all.sh &
[root@asianux build]# cat nohup.out
[BUILD] buildtools .................... OK [1471.33s]
[BUILD] dependency .................... OK [1383.96s]
[BUILD] platform ...................... OK [ 5.34s]
total time:2860.64
binarylibs
在openGauss-third_party上层目录生成binarylibs文件夹。
[root@asianux opt]# tree -L 2 binarylibs/
binarylibs/
├── buildtools
│ └── asianux_x86_64
├── dependency
│ └── asianux_x86_64
└── platform
└── asianux_x86_64
6 directories, 0 files
日志及排错
对应的模块和组件:
- openGauss-third_party/build
- openGauss-third_party/module/build
- openGauss-third_party/module/components
- module 和 components
相应的日志:
[root@asianux openGauss-third_party]# ls build/
build_all.sh buildtools_build.log common.sh dependency_build.log get_PlatForm_str.sh nohup.out platform_build.log requirements.txt
[root@asianux openGauss-third_party]# ls buildtools/build/
build_buildtools.sh cmake_build.log gcc_build.log gmp_build.log isl_build.log mpc_build.log mpfr_build.log
[root@asianux openGauss-third_party]# ls buildtools/gcc/
build_libstd.log build.sh config.ini gcc-8.2.0 gcc-8.2.0.tar.gz install_comm install_comm_dist
编译依赖 python3 环境,多数报错是由于缺少依赖包所致,可通过上述日志 Troubleshooting。
Compile openGauss-server
拉取源码
[root@asianux openGauss-server]# git clone https://gitee.com/opengauss/openGauss-server.git
[root@asianux openGauss-server]# ls
aclocal.m4 binarylibs.tar.gz config config.status contrib COPYRIGHT docker GNUmakefile.in make_compile.log package README.md src Third_Party_Open_Source_Software_Notice
build.sh config.log configure CONTRIBUTING.md doc GNUmakefile License Makefile README.en.md simpleInstall third_party
binarylibs
将编译好的 binarylibs 文件夹放入 openGauss-server 的子目录。
[root@asianux openGauss-server]# ls
aclocal.m4 binarylibs.tar.gz config config.status contrib COPYRIGHT docker GNUmakefile.in make_compile.log package README.md src Third_Party_Open_Source_Software_Notice
binarylibs build.sh config.log configure CONTRIBUTING.md doc GNUmakefile License Makefile README.en.md simpleInstall third_party
build.sh
openGauss-server 中的 build.sh 是编译过程中的重要脚本工具。该工具集成了软件安装编译和产品安装包编译功能,可快速进行代码编译和打包。。
参数说明请见以下表格。
说明:
- **-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命令删除。
执行编译
[root@asianux openGauss-server]# nohup sh build.sh &
[root@asianux openGauss-server]# ls package/
make_package.log openGauss-1.0.1-asianux-64bit-Libpq.tar.gz openGauss-1.0.1-asianux-64bit.tar.gz separate_debug_information.sh
openGauss-1.0.1-asianux-64bit-kernel.tar.gz openGauss-1.0.1-asianux-64bit-symbol.tar.gz package.sh
Install openGauss
OM tool Installation
OM 安装为官方推荐安装方式。
详细安装方式见官网 https://opengauss.org/zh/docs/1.0.1/docs/installation/installation.html
Automatic Installation
openGauss 目前最多节点支持一主四备四级联库。
通过 shell 脚本和批量化工具实现自动化安装。
使用方法
[root@asianux simpleInstall]# ./install.sh --help
Usage: ./install.sh [OPTION]
-?|--help show help information
-U|--user_name cluster user
-G|--user_grp group of the cluster user
-P|--host_port database server port
-D|--install_location installation directory of the openGauss program
-M|--mode installation mode ...
-F|--file list of hostname and ip
表 2 安装脚本清单
1-single node 11- 1primary,1standby 111- 1primary,1standby,1cascade | |
Command Install
更改 primary1_hostname 和 primary1_ip 为实际值。
[root@asianux simpleInstall]# cat filename
M1:primary1_hostname:primary1_ip
S1:standby1_hostname:standby1_ip
S2:standby2_hostname:standby2_ip
S3:standby3_hostname:standby3_ip
S4:standby4_hostname:standby4_ip
C1:cascade1_hostname:cascade1_ip
C2:cascade2_hostname:cascade2_ip
C3:cascade3_hostname:cascade3_ip
C4:cascade4_hostname:cascade4_ip
[root@asianux simpleInstall]# sh install.sh -M 1 -F filename
One Button Install
password 为数据库密码,rootpasswd 为主机密码。
[root@asianux simpleInstall]# cat one.sh
#!/bin/bash
password="********"
rootpasswd="="********""
/usr/bin/expect <<EOF
set timeout 600
spawn sh install.sh -M 1 -F filename
expect {
"New password:" { send "$password\r"; exp_continue }
"Retype new password:" { send "$password\r"; exp_continue }
"*create trust for root (yes/no)?" { send "yes\r"; exp_continue }
"*Password:" { send "$rootpasswd\r"; exp_continue }
"*create trust for it (yes/no)?" { send "yes\r"; exp_continue }
"Password:" { send "$password\r"; exp_continue }
"Please enter password for database:" { send "$password\r"; exp_continue }
"Please repeat for database:" { send "$password\r"; exp_continue }
"*create a demo database (yes/no)?" { send "no\r"; exp_continue }
eof
}
EOF
[root@asianux simpleInstall]# sh one.sh