- openGauss源碼編譯
- 參考文檔:https://gitee.com/opengauss/openGauss-server/blob/master/README.md
- 准備工作
-
硬件環境
CPU:4C
內存:8G
磁盤大小:100G -
操作系統
CentOS7.6 x86架構 -
軟件依賴
libaio-devel:0.3.109-13
flex:2.5.37
bison:2.7-4
ncurses-devel:5.9-14.20130511
glibc-devel:2.17-324
patch:2.7.1
redhat-lsb-core:4.1-27
readline-devel:6.2-11
perl:5.16.3
以上可以使用yum安裝,bison由於yum安裝的是3.x的版本,可以下載rpm包安裝 -
源碼包及開源第三方軟件
openGauss源碼:opengauss-openGauss-server-v2.0.0.tar.gz
下載地址:https://gitee.com/opengauss/openGauss-server/repository/archive/v2.0.0?format=tar.gz
開源第三方軟件:由於編譯時間較長,使用官方編譯構建的包 openGauss-third_party_binarylibs.tar.gz
下載地址:https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.0/openGauss-third_party_binarylibs.tar.gz注:軟件依賴包版本需盡量與官方文檔一致
- 源碼編譯安裝
-
解壓源碼包,開源第三方軟件壓縮包
// 將下載的壓縮包上傳到/data目錄后,解壓 # cd /data # tar -zxvf opengauss-openGauss-server-v2.0.0.tar.gz # tar -zxvf openGauss-third_party_binarylibs.tar.gz // 重命名開源第三方軟件解壓目錄為binarylibs # mv openGauss-third_party_binarylibs binarylibs
-
編譯安裝
有兩種編譯方式:一鍵式腳本編譯,手動編譯
i. 一鍵式腳本編譯// 進入openGauss源碼目錄 # cd /data/openGauss-server // 查看build.sh的相關參數 # sh build.sh -h Usage: build.sh [OPTION] -h|--help show help information -m|--version_mode this values of paramenter is debug, release or memcheck, the default value is release -3rd|--binarylib_dir the parent directory of binarylibs -pkg|--package (deprecated option)package the project,by default, only compile the project -wrap|--wrap_binaries wrop up the project binaries. By default, only compile the project -nopt|--not_optimized on kunpeng platform, like 1616 version, without LSE optimized // 使用build.sh進行編譯, -m可指定三種版本:debug,release,memcheck, -3rd指定開源第三方軟件的絕對路徑, 如需編譯安裝包, 可加 -pkg 參數 # sh build.sh -m debug -3rd /data/binarylibs
使用腳本編譯的過程中出現內存不足的情況,這里改成手動編譯
ii. 手動編譯
// 查看系統版本 sh /data/openGauss-server/src/get_PlatForm_str.sh centos7.6_x86_64 // 設置環境變量 # cat ~/.bash_profile export CODE_BASE=/data/openGauss-server export BINARYLIBS=/data/binarylibs # 開源第三方軟件路徑 export GAUSSHOME=$CODE_BASE/dest/ # 編譯后的二進制文件存放路徑 export GCC_PATH=$BINARYLIBS/buildtools/centos7.6_x86_64/gcc7.3/ # centos7.6_x86_64是查詢出來的系統版本 export CC=$GCC_PATH/gcc/bin/gcc export CXX=$GCC_PATH/gcc/bin/g++ export LD_LIBRARY_PATH=/usr/lib64/perl5:$GAUSSHOME/lib:$GCC_PATH/gcc/lib64:$GCC_PATH/isl/lib:$GCC_PATH/mpc/lib/:$GCC_PATH/mpfr/lib/:$GCC_PATH/gmp/lib/:$BINARYLIBS/dependency/centos7.6_x86_64/libobs/comm/lib/:$BINARYLIBS/platform/centos7.6_x86_64/Huawei_Secure_C/Dynamic_Lib/:$LD_LIBRARY_PATH export LIBRARY_PATH=$BINARYLIBS/platform/centos7.6_x86_64/Huawei_Secure_C/Dynamic_Lib/:$BINARYLIBS/dependency/centos7.6_x86_64/libobs/comm/lib/:$LIBRARY_PATH export PGDATABASE=postgres PATH=$GAUSSHOME/bin:$GCC_PATH/gcc/bin:$PATH:$HOME/bin export PATH // 生效環境變量 # source ~/.bash_profile // 執行configure # cd /data/openGauss-server // 指定編譯debug版本(release版本去掉--enable-debug, memcheck版本增加--enable-memory-check) # ./configure --gcc-version=7.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --without-readline --without-zlib // 編譯安裝 # make -sj4 # make install -sj4
輸出 openGauss installation complete. 則安裝成功。
openGauss安裝路徑:GAUSSHOME
openGauss二進制文件路徑:GAUSSHOME/bin