openGauss源码安装

openGauss源码安装

参考官方文档:Compilation | openGauss

平台配置:

操作系统:CentOS 7.6

处理器数:2

每个处理器的核数:2

运行内存:8G

磁盘内存:200G

1. 创建omm用户

groupadd og
useradd -g og omm

2. 安装相关依赖

yum install -y libaio-devel-0.3.109
yum install -y flex 2.5.37
yum install -y bison 2.7-4
yum install -y ncurses-devel 5.9-13.20130511
yum install -y glibc-devel 2.17-111
yum install -y patch 2.7.1-10
yum install -y redhat-lsb 4.1
yum install -y readline-devel 7.0-13

3. 升级gcc和g++

yum install -y centos-release-scl-rh 
yum install -y centos-release-scl 
# 安装gcc7 
yum install -y devtoolset-7-gcc.x86_64
yum install -y devtoolset-7-gcc-c++.x86_64
# 启用
scl enable devtoolset-7 bash
# 查看版本
gcc --version
g++ --version

# 防止失效方法1:修改软连接(推荐)
mv /usr/bin/gcc /usr/bin/gcc4.8.5
ln -s  /opt/rh/devtoolset-7/root/usr/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++4.8.5
ln -s /opt/rh/devtoolset-7/root/usr/bin/g++ /usr/bin/g++
mv /usr/bin/cc /usr/bin/cc4.8.5
ln -s /opt/rh/devtoolset-7/root/usr/bin/cc /usr/bin/cc
mv /usr/bin/c++ /usr/bin/c++4.8.5
ln -s /opt/rh/devtoolset-7/root/usr/bin/c++ /usr/bin/c++

# 防止失效方法2:修改环境变量
echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile

4. 升级CMake

# 下载
wget -c https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
# 解压
tar zxvf cmake-3.20.2.tar.gz
# 进入解压目录
cd cmake-3.20.2
# 构建
./bootstrap
# 编译
gmake
# 安装
gmake install
# 链接 目的是添加到环境变量中
ln -s /usr/local/bin/cmake /usr/bin/cmake

5. 切换到omm用户

su - omm

6. 下载openGauss相关的源代码

cd /home/omm/
# 下载第三方依赖
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
tar -zxvf openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
mv openGauss-third_party_binarylibs_Centos7.6_x86_64 binarylibs
# 下载openGauss源码
git clone https://gitee.com/opengauss/openGauss-server.git

7. 修改脚本参数

7.1. 打开cmake_compile.sh

vim /home/omm/openGauss-server/build/script/utils/cmake_compile.sh

7.2. 将make -sj改为make或make -j4(大约位于第120行)

作用:为了避免并发数太大而把内存撑爆,然后报错

实际运行情况:

  1. 在满足开头所介绍的"平台配置"的虚拟机中,可以产生作用
  2. 在阿里云服务器中(1核,2G内存,60G磁盘内存),依然会报内存不足的错误

7.3. 保存文件并退出

8. 运行脚本

cd /home/omm/openGauss-server

# 这个命令要留意官方文档
sh build.sh -m debug -3rd /home/omm/binarylibs

查看编译日志:vim /home/omm/openGauss-server/build/script/makemppdb_pkg.log

9. 配置环境变量

9.1. 打开文件~/.bashrc

vim ~/.bashrc

9.2. 写入以下内容后,保存并退出

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

9.3. 使环境变量生效

source ~/.bashrc

10. 建立数据目录和日志目录

cd

mkdir data
mkdir log

11. 初始化数据库

gs_initdb -D /home/omm/data --nodename=gauss

12. 启动数据库

gs_ctl start -D /home/omm/data -Z single_node -l /home/omm/log/openGauss.log

13. 连接数据库

gsql -d postgres -p 5432 -r

14. 调试配置

(1) 在.vscode文件夹中创建launch.json文件,内容如下:

{
    // 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": "openGauss-debug",
            "type": "cppdbg",
            "request": "attach",
            "program": "/home/omm/openGauss-server/mppdb_temp_install/bin/gaussdb",
            "processId": "${command:pickProcess}",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

(2) 忽略中断信号

# 新建文件
cd /home/omm
vim ~/.gdbinit

# 写入如下内容
handle SIGUSR1 nostop
handle SIGUSR2 nostop

15. 虚拟机开放端口

15.1. 查看5432端口状态

firewall-cmd --zone=public --query-port=5432/tcp

如果输出no,则需要开放端口

15.2. 开放端口

firewall-cmd --zone=public --add-port=5432/tcp --permanent 

15.3. 防火墙重载

firewall-cmd --reload
posted @   碧波蔚蓝  阅读(2119)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示