首页 > 编程语言 >openGauss源码安装

openGauss源码安装

时间:2022-10-01 18:45:09浏览次数:75  
标签:bin omm 源码 yum usr install 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

yum install readline-devel

3. 升级gcc和g++

yum install -y centos-release-scl-rh 
yum install -y centos-release-scl 
# 安装gcc7 
yum install devtoolset-7-gcc.x86_64
yum install 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. 切换到omm用户

su - omm

5. 下载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

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

6. 修改脚本参数

6.1. 打开cmake_compile.sh

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

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

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

实际运行情况:

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

6.3. 保存文件并退出

7. 运行脚本

cd /home/omm/openGauss-server

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

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

8. 配置环境变量

8.1. 打开文件~/.bashrc

vim ~/.bashrc

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

8.3. 使环境变量生效

source ~/.bashrc

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

cd

mkdir data
mkdir log

10. 初始化数据库

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

11. 启动数据库

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

12. 连接数据库

gsql -d postgres -p 5432 -r

13. 调试配置

(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

14. 虚拟机开放端口

14.1. 查看5432端口状态

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

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

14.2. 开放端口

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

14.3. 防火墙重载

firewall-cmd --reload

标签:bin,omm,源码,yum,usr,install,openGauss,安装
From: https://www.cnblogs.com/AnkleBreaker-ZHX/p/16747576.html

相关文章