暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss从源码到自动化

原创 李宏达 2020-12-04
1934

一、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 openGauss-server
README.md build.sh
build/get_PlatForm_str.sh package/package.sh
dependency/c-ares/build.sh src/get_PlatForm_str.sh
dependency/openssl/build.sh src/manager/om/script/local/LocalCheckOS.py

详细修改内容

三、Compile openGauss-third_party

1. 拉取源码

[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

2. 下载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

3. 安装依赖包

[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++

4. 执行编译

该环境为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

5. 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

6. 日志及排错

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

1. 拉取源码

[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

2. 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

3. 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命令删除。
  • 执行编译
[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 version.cfg

五、Install openGauss

1. OM tool Installation

2. Automatic Installation

  • openGauss目前最多节点支持一主四备四级联库
  • 通过shell脚本和批量化工具实现自动化安装

表1 安装脚本清单

选项 说明
1,11,111 … xml模板
common.sh 公共命令
install.sh 简化安装主程序
uninstall.sh 卸载
filename 记录节点信息
one.sh 通过预配置命令一键安装
school.sql 学校数据模型展示数据库
finance.sql 金融数据模型展示数据库
README.MD 参考文档
  • 使用方法
[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 安装脚本清单

参数 默认值
user_name omm
user_grp dbgrp
host_port 26000
install_location /opt/gaussdb
mode 1-single node 11- 1primary,1standby 111- 1primary,1standby,1cascade
file list of hostname and ip

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 

原文链接http://www.lihongda.club/index.php/2020/12/01/opengauss%e4%bb%8e%e6%ba%90%e7%a0%81%e5%88%b0%e8%87%aa%e5%8a%a8%e5%8c%96/

最后修改时间:2020-12-04 16:55:46
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论