Compiling the Version

A build.sh script is provided for compiling openGauss and generating the installation package. You can compile openGauss by using the script. You can also configure environment variables and run commands to compile openGauss.

This section describes the prerequisites and procedure for openGauss compilation. The following figure shows the compilation process.

Preparation Before Compiling

Downloading Code

Prerequisites

The git and git-lfs have been installed and configured on the local host.

Procedure

  1. Run the following command to download the code and open-source and third-party software repository. [git ssh address] indicates the actual code download address. You can obtain them from the openGauss community.

    [user@linux sda]$ git clone [git ssh address] openGauss-server
    [user@linux sda]$ git clone [git ssh address] openGauss-third_party
    [user@linux sda]$ # mkdir binarylibs        For details about this comment, see the following note.
    

    NOTE:

    • openGauss-server: openGauss code repository.
    • openGauss-third_party: open-source third-party software repository on which openGauss depends.
    • binarylibs: package for storing the built open-source third-party software. You can obtain the package by referring to [Compiling Open-source Software](#Compiling Open-source Software) . Since compiling and building open-source software take a long time, we have compiled and built binarylibs using openGauss-third_party and compress and upload binarylibs to the Internet.
      You can download the compressed package by visiting https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.1.0/openGauss-third_party_binarylibs.tar.gz.
      After the download is complete, decompress the package and rename the folder to binarylibs.
  2. When the progress of each download reaches 100%, the download is successful.

Compiling Open-source Software

Compiling Open-source Software

Before compiling the openGauss, compile and build the open-source and third-party software on which the openGauss depends. These open-source and third-party software is stored in the openGauss-third_party code repository. After downloading the software, you can use git lfs pull to obtain large files from the code repository. Generally, you only need to build the software once. If the open-source software is updated, rebuild the software.

Since this step takes a long time, we have compiled and built binarylibs using openGauss-third_party. You can download the package by referring to [Downloading Code](#Downloading Code).

Table 1 Requirements for the openGauss open-source and third-party software before compilation

Software

Recommended Version

python3

3.6

python3-devel

3

setuptools

36.6.1

libaio-devel

0.3.109-13

flex

2.5.31 or later

ncurses-devel

5.9-13.20130511

lsb_release

4.1

pam-devel

1.1.8-1.3.1

libffi-devel

3.1

patch

2.7.1-10

golang

1.13.3 or later

autoconf

2.69

automake

1.13.4

byacc

1.9

cmake

3.19.2

diffutils

3.7

openssl-devel

1.1.1

libtool

2.4.2 or later

libtool-devel

2.4.2 or later

Prepare GCC 7.3 before building the third-party libraries. You are advised to use the released and built third-party library GCC and configure environment variables.

After installing the software listed in Table 1, point the default Python version to python3.x and perform the following operations:

  1. Run the following commands to go to the directory of the open-source and third-party software on which the kernel depends, compile and build the open-source and third-party software, and generate binary programs or library files. /sda/openGauss-third_party is the directory for downloading open-source third-party software.

    [user@linux sda]$ cd /sda/openGauss-third_party/build
    [user@linux build]$ sh build_all.sh
    
  2. After the preceding commands are executed, the open-source and third-party software required for openGauss compilation is automatically generated. To generate any open-source and third-party software independently, go to the corresponding directory and run the build.sh script. For example:

    [user@linux sda]$ cd /sda/openGauss-third_party/dependency/openssl
    [user@linux openssl]$ sh build.sh
    

    The OpenSSL is generated.

    ![](C:/Users/gongsiyi1/Desktop/openGauss开源文档0115/en/08 openGauss Compilation Guide/public_sys-resources/icon-note.gif) NOTE: For error logs, you can view the corresponding log in the build directory and the log in the corresponding module. For example, you can view the OpenSSL compilation and installation logs in the dependency module.

    • /sda/openGauss-third_party/build/dependency_build.log
    • /sda/openGauss-third_party/dependency/build/openssl_build.log
    • /sda/openGauss-third_party/dependency/openssl/build_openssl.log

Compilation and Build Result

After the preceding script is executed, the final compilation and build result is stored in the **output **directory under the openGauss-third_party directory These files will be used during the compilation of openGauss-server.

Introduction to compile script

openGauss-server/build.sh is an important script tool during compilation. It integrates software installation and compilation and product installation package compilation functions to quickly compile and package code.

The following table describes the parameters.

Table 2 build.sh parameters

Option

Default Value

Parameter

Description

-h

Do not use this option.

-

Help menu

-m

release

[debug | release | memcheck]

Selects the target version.

-3rd

${Code directory}/binarylibs

[binarylibs path]

Specifies the path of binarylibs. The path must be an absolute path.

-pkg

Do not use this option.

-

Compresses the code compilation result into an installation package.

-nopt

Do not use this option.

-

If this option is used, the CPU of the Kunpeng platform is not optimized.

![](C:/Users/gongsiyi1/Desktop/openGauss开源文档0115/en/08 openGauss Compilation Guide/public_sys-resources/icon-note.gif) NOTE:

  1. -m [debug | release | memcheck] indicates that three target versions can be selected:
  • release: indicates that the binary program of the release version is generated. During compilation of this version, the GCC high-level optimization option is configured to remove the kernel debugging code. This option is usually used in the production environment or performance test environment.
  • debug: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, which is usually used in the development self-test environment.
  • memcheck: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN function is added based on the debug version to locate memory problems.
  1. -3rd [binarylibs path] is the path of binarylibs. By default, binarylibs exists in the current code folder. If binarylibs is moved to openGauss-server or a soft link to binarylibs is created in openGauss-server, you do not need to specify the parameter. However, if you do so, please note that the file is easy to be deleted by the git clean command.
  2. Each option in this script has a default value. The number of options is small and the dependency is simple. Therefore, this script is easy to use. If the required value is different from the default value, set this parameter based on the actual requirements.

Software Compilation and Installation

Software compilation and installation are to compile code to generate software and install the software on a computer. The one-click compilation script build.sh is provided. You can also manually configure environment variables. The two methods are described below in this section.

Prerequisites

  • The software and hardware have been prepared based on the requirements in Setting up the Compilation Environment, and the code has been downloaded by referring to [Downloading Code](#Downloading Code).
  • Open-source software has been compiled and built. For details, see [Compiling Open-source Software](#Compiling Open-source Software). GCC 7.3 has been placed in the output directory based on the directory structure of the released and compiled third-party library.
  • You are familiar with the parameter options and functions of the [Introduction to build.sh](#Introduction to compile script) script.
  • The code environment is clean, and no file is generated before the current compilation. For details, see FAQ.

Compilation Using the One-click Script

  1. Run the following command to go to the directory where the software code compilation script is stored:

    [user@linux sda]$ cd /sda/openGauss-server
    
  2. Run the following command to compile openGauss:

    [user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path]
    

    For example:

    sh build.sh      # Compile and install openGauss of the release version. binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
    sh build.sh -m debug -3rd /sdc/binarylibs            # Compile and install openGauss of the debug version.
    
  3. If the following information is displayed, the compilation is successful:

    make compile sucessfully!
    
    • The software installation path after compilation is /sda/openGauss-server/mppdb_temp_install.
    • The compiled binary files are stored in /sda/openGauss-server/mppdb_temp_install/bin.
    • Compilation log: ./build/script/makemppdb_pkg.log
  4. Import environment variables to initialize and start the database.

    export CODE_BASE=________     # openGauss-server path
    export GAUSSHOME=$CODE_BASE/mppdb_temp_install/
    export LD_LIBRARY_PATH=$GAUSSHOME/lib::$LD_LIBRARY_PATH
    export PATH=$GAUSSHOME/bin:$PATH
    

Manual Compilation

  1. Run the following command to go to the software code directory:

    [user@linux sda]$ cd /sda/openGauss-server
    
  2. Run the following script to obtain the system version:

    [user@linux openGauss-server]$ sh src/get_PlatForm_str.sh
    

    NOTE:

    • The command output indicates the OSs supported by the openGauss. The OSs supported by the openGauss are centos7.6_x86_64 and openeuler_aarch64.
    • If Failed or another version is displayed, the openGauss does not support the current operating system.
  3. Configure environment variables, add ____ based on the code download location, and replace *** with the result obtained in Step 2.

    export CODE_BASE=________     # Path of the openGauss-server file
    export BINARYLIBS=________    # Path of the binarylibs file
    export GAUSSHOME=$CODE_BASE/dest/
    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
    
  4. Select a version and configure it.

    debug version:

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

    release version:

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

    memcheck version:

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

    NOTE:

    1. [debug | release | memcheck] indicates that three target versions are available. The three target versions are as follows:
    • release: indicates that the binary program of the release version is generated. During compilation of this version, the GCC high-level optimization option is configured to remove the kernel debugging code. This option is usually used in the production environment or performance test environment.
    • debug: indicates that a binary program of the debug version is generated. During compilation of this version, the kernel code debugging function is added, which is usually used in the development self-test environment.
    • memcheck: indicates that a binary program of the memcheck version is generated. During compilation of this version, the ASAN function is added based on the debug version to locate memory problems.
    1. On the ARM-based platform, -D__USE_NUMA needs to be added to CFLAGS.
    2. On the ARMv8.1 platform or a later version (for example, Kunpeng 920), -D__ARM_LSE needs to be added to CFLAGS.
    3. If binarylibs is moved to openGauss-server or a soft link to binarylibs is created in openGauss-server, you do not need to specify the --3rd parameter. However, if you do so, please note that the file is easy to be deleted by the git clean command.
  5. Run the following commands to compile openGauss:

    [user@linux openGauss-server]$ make -sj
    [user@linux openGauss-server]$ make install -sj
    
  6. If the following information is displayed, the compilation and installation are successful:

    openGauss installation complete.
    
    • The software installation path after compilation is $GAUSSHOME.
    • The compiled binary files are stored in $GAUSSHOME/bin.

Compiling the Installation Package

To compile the installation package is to compile the code and generate the software installation package. The compilation and packaging process of the installation package is also integrated in build.sh.

Prerequisites

  • TThe software and hardware have been prepared based on the requirements for setting up the compilation environment, and the code has been downloaded by referring to Downloading Code.
  • The open-source software has been compiled and built. For details, see [Compiling Open-source Software](#Compiling Open-source Software).
  • You are familiar with the parameter options and functions of the [Introduction to build.sh](#Introduction to compile script) script.
  • The code environment is clean, and no file is generated before the current compilation. For details, see FAQ.

Procedure

  1. Run the following command to go to the code directory:

    [user@linux sda]$ cd /sda/openGauss-server
    
  2. Run the following command to compile the openGauss installation package:

    [user@linux openGauss-server]$ sh build.sh -m [debug | release | memcheck] -3rd [binarylibs path] -pkg
    

    For example:

    sh build.sh -pkg      # Generate the openGauss installation package of the release version. binarylibs or its soft link must exist in the code directory. Otherwise, the operation fails.
    sh build.sh -m debug -3rd /sdc/binarylibs -pkg            # Generate the openGauss installation package of the debug version.
    

    Compared with Software Compilation and Installation, this operation involves the process of generating software by one-click compilation and the process of encapsulating the software into an installation package. Compared with the build.sh command in Software Compilation and Installation, only the -pkg option is added.

  3. If the following information is displayed, the installation package compilation is successful:

    success!
    
    • The generated installation package is stored in the ./output directory.
    • Compilation log:./build/script/makemppdb_pkg.log
    • Installation package packaging log: ./build/script/make_package.log
Feedback
编组 3备份
    openGauss 2024-05-19 00:45:18
    cancel