飞腾平台编译安装openGauss数据库

1. 环境检查
1.1 检查OS版本
openGauss支持的操作系统:
CentOS 7.6(x86_64 架构)
openEuler-20.03-LTS(aarch64 架构)
openEuler-20.03-LTS(x86_64架构)
Kylin-V10(aarch64 架构)
Kylin-V10(x86_64 架构)
Asianux 7.6(x86_64架构)
FusionOS 22 (aarch64 架构)
FusionOS 22 (x86 架构)
cat etc/os-release

操作系统为openEuler-20.03-LTS(aarch64 架构)
1.2 检查cpu型号
lscpu | grep "Vendor ID"

安装平台Vendor ID:0x70为飞腾CPU
1.3. 禁用防火墙和selinux
禁用防火墙
systemctl status firewalldsystemctl stop firewalldsystemctl disable firewalldsystemctl is-enabled firewalld
禁用SELINUX
/usr/sbin/sestatus -v
如果selinux为enable状态,则修改/etc/selinux/config文件:
SELINUX=disabled
或使用下面命令:
sed -i '/^SELINUX=.*/ s//SELINUX=disabled/' etc/selinux/config
并重启服务器
1.4 配置yum源并安装依赖包
上传操作系统iso到/tmp目录
配置本地yum源
mkdir mnt/isomount -o loop tmp/openeuler20.03LTS.iso mnt/isocd etc/yum.repos.dvi media.repo[InstallMedia]name=openeuler20.03LTSgpgcheck=0enabled=1baseurl=file:///mnt/isoyum clean allyum makecacheyum listyum -y install libaio-devel flex bison ncurses-devel glibc-devel patch openeuler-lsb readline-devel unzip dos2unix vim git wget lrzsz net-tools bzip2 gcc tree zlib*
1.5 安装Python3
建议安装Python3.6+
yum install python3 python3-pip
软链接python命令为python3.7
ln -s usr/bin/python3.7 usr/bin/pythonpython -V

1.6 设置字符集参数
vi etc/profileexport LANG=en_US.UTF-8
1.7 设置时区和时间
[root@localhost ~] timedatectl set-timezone Asia/Shanghai[root@localhost ~] timedatectl status
2 下载软件包
cd soft2/git clone https://gitee.com/opengauss/openGauss-server.git openGauss-server -b 5.0.0wget -c https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz
3. 脚本编译安装
3.1 openGauss-server编译
tar -xvf openGauss-third_party_binarylibs_openEuler_arm.tar.gzmv openGauss-third_party_binarylibs_openEuler_arm binarylibscd openGauss-server/sh build.sh -m debug -3rd soft/binarylibs -pkg
说明
-m [debug | release | memcheck]表示可选择三种目标版本:
release:代表生成release版本的二进制程序,该版本编译时,配置GCC高级别优化选项,去除内核调试代码,通常用于生产环境或性能测试环境。
debug:代表生成debug版本的二进制程序,该版本编译时,增加内核代码调试功能,通常用于开发自测环境。
memcheck:代表生成memcheck版本的二进制程序,该版本编译时,在debug版本基础上新增ASAN功能,通常用于定位内存问题。
显示如下内容,表示编译成功。

生成的安装包会存放在./output目录下。
编译和打包日志为:./build/script/makemppdb_pkg.log。
4. 编译后验证
编译结束后,可按以下方式对编译后的openGauss进行验证:
4.1 创建用户
groupadd dbgrpuseradd omm -g dbgrppasswd omm
4.2 使用omm用户,在~/.bashrc中增加以下环境变量
su - ommvi ~/.bashrc
使环境变量生效
source .bashrc
4.3 建立数据目录和日志目录
su - rootchown -R omm:dbgrp /soft2/openGauss-serversu - ommmkdir ~/datamkdir ~/log
4.4 数据库初始化
su - ommgs_initdb -D /home/omm/data --nodename=db1
初始化日志如下:
The files belonging to this database system will be owned by user “omm”.This user must also own the server process.The database cluster will be initialized with locale “en_US.UTF-8”.The default database encoding has accordingly been set to “UTF8”.The default text search configuration will be set to “english”.fixing permissions on existing directory /home/omm/data … okcreating subdirectories … in ordinary occasionokcreating configuration files … okselecting default max_connections … 100selecting default shared_buffers … 1024MBBegin init undo subsystem meta.[INIT UNDO] Init undo subsystem meta successfully.creating template1 database in /home/omm/data/base/1 … The core dump path is an invalid directory2023-07-20 16:10:19.012 [unknown] [unknown] localhost 281468516106256 0[0:0#0] [BACKEND] WARNING: macAddr is 64174/3171074048, sysidentifieris 4205755650/3221270315, randomNum is 96513835okinitializing pg_authid … oksetting password … okinitializing dependencies … okloading PL/pgSQL server-side language … okcreating system views … okcreating performance views … okloading system objects’ descriptions … okcreating collations … okcreating conversions … okcreating dictionaries … oksetting privileges on built-in objects … okinitialize global configure for bucketmap length … okcreating information schema … okloading foreign-data wrapper for distfs access … okloading foreign-data wrapper for log access … okloading hstore extension … okloading foreign-data wrapper for MOT access … okloading security plugin … okupdate system tables … okcreating snapshots catalog … okvacuuming database template1 … okcopying template1 to template0 … okcopying template1 to postgres … okfreezing database template0 … okfreezing database template1 … okfreezing database postgres … okWARNING: enabling “trust” authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or–auth-local and --auth-host, the next time you run gs_initdb.Success. You can now start the database server of single node using:gaussdb -D /home/omm/data --single_nodeorgs_ctl start -D /home/omm/data -Z single_node -l logfile
4.5 启动数据库
su - ommgs_ctl start -D /home/omm/data -Z single_node -l /home/omm/log/opengauss.log
启动完毕后可通过 ps -ef | grep gaussdb检查数据库进程情况,或通过 gs_ctl query -D /home/omm/data检查数据库状态,或使用 gsql -d postgres 进入gsql命令行查看数据库的相关信息。


5. FAQ
编译安装过程中遇到的问题
FAQ 1:python版本需要3.6+以上版本,操作系统自带的python2.7不符合要求,需要安装python3.7,不然编译脚本错误。
解决方案:
yum安装Python3.7
yum install python3 python3-pip
软链接python命令为python3.7
ln -s /usr/bin/python3.7 /usr/bin/python
FAQ 2:一键式脚本编译build.sh使用 -m release编译release版本的二进制程序,初始化数据库报错。
解决方案:
目前还未解决,绕过方案使用-m debug编译debug版本的二进制程序.可以初始化数据库成功。
sh build.sh -m debug -3rd /soft/binarylibs -pkg
-m [debug | release | memcheck]表示可选择三种目标版本:
release:代表生成release版本的二进制程序,该版本编译时,配置GCC高级别优化选项,去除内核调试代码,通常用于生产环境或性能测试环境。
debug:代表生成debug版本的二进制程序,该版本编译时,增加内核代码调试功能,通常用于开发自测环境。
memcheck:代表生成memcheck版本的二进制程序,该版本编译时,在debug版本基础上新增ASAN功能,通常用于定位内存问题。