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

openEuler20.03上编译安装opengauss-5.0.0

原创 ziyoo0830 2023-07-27
1436

openEuler20.03上编译安装opengauss-5.0.0

为了更好的学习opengauss数据库知识,有时候需要去调试源代码来深入了解一些东西。以下记录了在openEuler20.03上编译最新的openGauss-server源代码的过程,记录了手工编译过程遇到的一些问题,同时尝试使用vscode去调试了下源代码,文中也提供了几个vscode的调试样例。

vscode调试参考:https://www.modb.pro/db/1683159982970331136,https://www.modb.pro/db/658344。

以下采用的是手工编译的方法来安装。

下载第三方libs

mkdir -p /home/debug/opengauss/binarylibs/ wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz # 以上提供的是已经编译好的包,无需再次编译, 用--with-3rdpartydir不要用--with-3rdparty_sourcedir tar -xf openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz -C /home/debug/opengauss/binarylibs/
复制

下载opengauss-server代码

下载5.0.0的源代码

cd /home/debug/opengauss/ git clone https://gitee.com/opengauss/openGauss-server.git openGauss-server -b 5.0.0
复制

configure

cd openGauss-server # 编译debug版本 ./configure --gcc-version=7.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --with-3rdpartydir=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlib # 以上是sh build.sh脚本中使用的configure命令参数记录。 ./configure --gcc-version=7.3.0 --prefix=/home/debug/opengauss/opengauss-server/openGauss-server/mppdb_temp_install --3rd=/home/debug/opengauss/binarylibs/ --enable-thread-safety --with-readline --without-zlib CFLAGS=-O0 --enable-mot --enable-debug --enable-cassert CC=g++
复制

make

make make[2]: Leaving directory '/home/debug/opengauss/opengauss-server/openGauss-server/src/test/regress' make[1]: Leaving directory '/home/debug/opengauss/opengauss-server/openGauss-server/src' make -C config all make[1]: Entering directory '/home/debug/opengauss/opengauss-server/openGauss-server/config' make[1]: Nothing to be done for 'all'. make[1]: Leaving directory '/home/debug/opengauss/opengauss-server/openGauss-server/config'
复制

make install

make install make[1]: Leaving directory '/home/debug/opengauss/opengauss-server/openGauss-server/contrib/dblink' openGauss installation complete.
复制

配置环境变量

# more .bashrc export CODE_BASE=/home/debug/opengauss-server export BINARYLIBS=/home/debug/binarylibs export GAUSSHOME=/home/debug/ogsql export GCC_PATH=$BINARYLIBS/buildtools/gcc7.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 export PGDATA=/home/debug/ogdata export PATH=$GAUSSHOME/bin:$PATH export S3_CLIENT_CRT_FILE=$GAUSSHOME/lib/client.crt export PGHOST=$PGDATA/
复制

初始化数据库

mkdir -p /home/debug/ogdata gs_initdb -D /home/debug/ogdata --nodename=pghost1 Success. You can now start the database server of single node using: gaussdb -D /home/debug/ogdata --single_node or gs_ctl start -D /home/debug/ogdata -Z single_node -l logfile
复制

启动数据库

gs_ctl start -D /home/debug/ogdata -Z single_node -l /home/debug/ogdata/log/opengauss.log
复制

登录数据库

gsql -d postgres -p 5432 -r
复制

问题记录

expected primary-expression

…/…/…/src/include/storage/cfs/cfs_converter.h:15:55: error: expected primary-expression before ‘/’ token
constexpr int CFS_EXTENT_COUNT_PER_FILE = RELSEG_SIZE / CFS_EXTENT_SIZE;
^
In file included from cfs_tools.cpp:9:0:
…/…/…/src/include/storage/cfs/cfs_converter.h:15:55: error: expected primary-expression before ‘/’ token
constexpr int CFS_EXTENT_COUNT_PER_FILE = RELSEG_SIZE / CFS_EXTENT_SIZE;
^
make[3]: *** [Makefile:49: libpagecompression.so] Error 1
make[3]: Leaving directory ‘/home/debug/opengauss/opengauss-server/openGauss-server/src/lib/page_compression’
make[2]: *** [Makefile:31: all-page_compression-recurse] Error 2
make[2]: Leaving directory ‘/home/debug/opengauss/opengauss-server/openGauss-server/src/lib’
make[1]: *** [Makefile:68: all-lib-recurse] Error 2
make[1]: Leaving directory ‘/home/debug/opengauss/opengauss-server/openGauss-server/src’
make: *** [GNUmakefile:12: all-src-recurse] Error 2

# configure 脚本中该值无法计算 ,可以直接写按默认值计算出的值。 # RELSEG_SIZE=`expr '(' 1024 / ${blocksize} ')' '*' ${segsize} '*' 1024` # RELSEG_SIZE=`expr '(' 1024 / 8 ')' '*' 1 '*' 1024` RELSEG_SIZE=131072
复制

vscode 调试代码

gaussdb的服务进程入口为src/gausskernel/process/main/main.cpp下的main函数,在此函数的第一行代码打上断点。

详细配置调试方法可参考网上方法。

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "gaussdb --help", "type": "cppdbg", "request": "launch", "program": "/home/debug/opengauss/opengauss-server/dest/bin/gaussdb", "args": [ "--help" ], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] }, { "name": "gaussdb -D /home/debug/ogdata", "type": "cppdbg", "request": "launch", "program": "/home/debug/opengauss/opengauss-server/dest/bin/gaussdb", "args": [ "--D", "/home/debug/ogdata" ], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
复制

总结

从以上编译过程可以看到,openGauss的编译还是比较简单的。
也可以编译出tar包,部署到线上测试环境,使用gdb工具进行调试。

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

评论