openGauss environment setup | Beginner's guide

1. Construction preparation

OpenGauss development requires the use of a Linux environment. First download the remote connection tool Xshell/MobaXterm.

1. Use tools to connect to the remote Linux server, log in remotely using the root account, and create a personal account.

useradd -d /home/xxx -m xxx

2. Set a password.

passwd xxx

3. Switch to your personal account and log in with your personal account for future connections.

su - xxx

2. Compile openGauss-server

Compiling openGauss-server requires the openGauss-server source code and the third-party software repository openGauss-third_party it depends on.

Create a folder with your own name as the working directory under the root directory /data/, enter the folder, and pull the latest source code of openGauss-server. It is recommended to fork to your own gitee warehouse first, and then pull the code to facilitate subsequent community development. Code integration process, modify the code, and submit PR.

mkdir xxx
cd xxx
git clone https://gitee.com/opengauss/openGauss-server.git

openGauss的编译,需要提前把所依赖的开源第三方软件进行编译和构建。

Two ways to obtain third-party software tools

1. Source code compilation

These open source third-party software are stored in the warehouse openGauss-third_party. Users can compile the code after pulling it, usually only once. If the open source software version is updated, it needs to be rebuilt.

git clone https://gitee.com/opengauss/openGauss-third_party.git
cd openGauss-third_party/build
sh build_all.sh

 2. Directly use the compiled and built files

Since the compilation and construction of open source software takes a long time, the community provides binary files compiled by three platforms for users to download.

● openEuler_arm: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz

● openEuler_x86: https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz

● Centos_x86 : https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz

We can download the openEuler_arm version of the compressed package, use the Xftp tool to transfer it to the working directory, decompress it, and rename it to a fixed name.

tar -zxvf openGauss-third_party_binarylibs_openEuler_arm.tar.gz
mv openGauss-third_party_binarylibs_openEuler_arm binarylibs

After the source code is ready, the code can be compiled.

Two compilation methods

1. One-click script compilation.

Use built-in scripts for compilation.

cd openGauss-server
sh build.sh -m release -3rd /data/meicheng/opengauss_src/install/binarylibs  
#debug版将release换成debug

The execution process will continue without response for 5-10 minutes, and the log will be automatically output. Finally, the following content will be displayed, indicating that the compilation is successful.

make compile successfully!

Import environment variables for subsequent initialization and startup of the database.

export CODE_BASE=_________    #openGauss-server的路径
export GAUSSHOME=$CODE_BASE/mppdb_temp_install/
export LD_LIBRARY_PATH=$GAUSSSHOME/lib:$LD_LIBRARY_PATH
export PATH=$GAUSSHOME/bin:$PATH

2. Manual compilation.

cd openGauss-server

The configured environment variables are slightly different from those of one-click script compilation.

export CODE_BASE=_________    #openGauss-server的路径
export BINARYLIBS=_________    #binarylibs的路径
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=$GAUSSSHOME/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

Select version to configure

Three target versions to choose from

release: Represents a binary program that generates a release version. When compiling this version, configure GCC high-level optimization options and remove the kernel debugging code. It is usually used in production environments or performance testing environments.

debug: represents a binary program that generates a debug version. When this version is compiled, the kernel code debugging function is added and is usually used to develop a self-test environment.

memcheck: Represents the binary program that generates the memcheck version. When this version is compiled, it essentially adds the ASAN function based on the debug version. This version is usually used to locate memory problems.

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-cassert --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

Start compiling

make -sj4
make install -sj4

-s indicates silent mode, and some compilation information will not be printed.

If you use the -j parameter, make will keep increasing the number of concurrencies when executing, and sometimes you will encounter the 'cannot allicate memory' error. Generally, the number you can specify after the -j parameter is the number of CPUs X2. If the compilation environment is 4CPU, you can use the make -j8 parameter to compile.

The following content is displayed to indicate successful compilation.

openGauss InstallationGuide complete

3. openGauss-OM compilation

openGauss-OM is the operation and maintenance management module (OperationManager), which provides management interfaces and tools for daily maintenance and configuration management of openGauss.

After the source code is compiled in the openGauss-server code warehouse, there is no gs_om. You need to compile openGauss-OM separately, copy the compiled openGauss-xxx-om.tar.gz package to the directory where the openGauss-server installation package is located, and then install it according to the enterprise version.

Steps

1. Download the code repository.

git clone https://gitee.com/opengauss/openGauss-OM.git

2. Execute compilation.

ocd openGauss-OM
chmod +x build.sh
export BINARYLIBS=/data/XXX/binarylibs      #这里写你的第三方软件包的文件目录
./build.sh -3rd $BINARYLIBS

The following content is displayed, indicating that gauss-OM is compiled successfully.

ROOT_DIR:XXXXX
Everything is ready.
success!

Enter the package directory, copy the compiled openGauss-xxx-om.tar.gz package to the directory where the openGauss-server installation package is located, and then install it according to the enterprise version.

4. Compile the product installation package

This step is to make the openGauss software installation package. The compilation and packaging process of the installation package is also integrated in build.sh.

Steps

1. Enter the openGauss-server directory.

2. Execute the command to compile the installation package.

osh build.sh -m [debug | release | memcheck] -3rd [binarylibs path] -pkg

3. The following content is displayed to indicate that the installation package is compiled.

make server(all) package success!

4. The packaged installation package is stored in the ./output directory.

5. Post-compilation verification

After compilation, the compiled openGauss can be verified as follows:

1. Create data directory and log directory.

mkdir ~/data
mkdir ~/log

2. Database initialization.

gs_initdb -D ~/data --nodename=db1

3. Start the database server.

gs_ctl start -D ~/data -Z single_node -l ~/log/opengauss.log

4. Enter the database server.

After the database installation is completed, a database named postgres will be generated by default. You can connect to this database for testing.

gsql -d postgres

After the connection is successful, information similar to the following will be displayed.

gsql(一些版本时间信息)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help
openGauss=#

5. Use openGauss.

5.1 Create database user.

CREATE USER XXX WITH PASSWORD "xxxxxxx";

5.2 Set the user as system administrator.

GRANT ALL PRIVILEGES TO xxx;

5.3 Create database.

CREATE DATABASE db_tpcc OWNER XXX;

5.4 After the db_tpcc database is created, you can exit the postgres database as follows, and use a new user to connect to the db_tpcc database to perform table creation and other operations.

\q      #退出当前数据库
gsql -d db_tpcc -U XXX    #连接数据库db_tpcc

5.5 Create SCHEMA.

CREATE SCHEMA test AUTHORIZATION XXX;

5.6 Create tables.

CREATE TABLE mytable (name varchar(16), age int);

5.7 Insert data into the table.

INSERT INTO mytable values("XXX", 18);

5.8 View the data in the table.

SELECT * FROM mytable;

6. Summary

openGauss is an open source relational database management system, released under the Mulan Permissive License v2. The openGauss core deeply integrates Huawei's many years of experience in the database field, combined with the needs of enterprise-level scenarios, to continuously build competitive features. 

That’s it for today’s sharing, welcome to communicate~ 

Fellow chicken "open sourced" deepin-IDE and finally achieved bootstrapping! Good guy, Tencent has really turned Switch into a "thinking learning machine" Tencent Cloud's April 8 failure review and situation explanation RustDesk remote desktop startup reconstruction Web client WeChat's open source terminal database based on SQLite WCDB ushered in a major upgrade TIOBE April list: PHP fell to an all-time low, Fabrice Bellard, the father of FFmpeg, released the audio compression tool TSAC , Google released a large code model, CodeGemma , is it going to kill you? It’s so good that it’s open source - open source picture & poster editor tool
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/gaussdb/blog/11052552