openGauss极简版自动安装脚本

此脚本用于自动安装openGauss极简版数据库,使用脚本前,配置脚本头部配置信息,在Linux需要安装openGauss的用户下创建install.sh脚本,然后运行脚本即可。

**注:**此脚本建议在熟悉openGauss极简版安装流程的情况下使用,openGauss极简版安装官方教程如下,openGauss极简版安装

脚本内容如下:

#!/bin/bash

########################
# 参数设置,使用前需要配置,脚本需要在数据库安装用户下执行
########################

# openGauss安装目录,数据库将安装在${gauss_install_dir}/openGauss目录下,请确保目录为空
gauss_install_dir=/path/to/

gauss_pkg_name=openGauss-Server-7.0.0-RC2-CentOS7-x86_64.tar.bz2

gauss_pkg_download_url=https://opengauss.obs.cn-south-1.myhuaweicloud.com/7.0.0-RC2/CentOS7/x86/${gauss_pkg_name}

# openGauss数据库密码
db_password=******

# openGauss数据库服务端口
db_port=5432

#######################
# 脚本执行逻辑,用户无需查看
#######################

# 检查是否有历史openGauss进程
echo "Check history openGauss process"
pid=$(ps -ux | grep -- 'gaussdb' | grep -v grep | awk '{print $2}' | head -n 1)

if [ -n "${pid}" ]; then
    echo "There is a history openGauss process, pid: ${pid}"
    echo "Please check and kill it manually"
    exit 1
fi

# 清空openGauss安装目录
echo "Clean openGauss install directory"
rm -rf ${gauss_install_dir}/openGauss

if [ $? -ne 0 ]; then
    echo "Clean openGauss install directory failed"
    exit 1
fi

# 创建openGauss安装目录
echo "Create openGauss install directory"

mkdir -p ${gauss_install_dir}/openGauss/pkg ${gauss_install_dir}/openGauss/server

if [ $? -ne 0 ]; then
    echo "Create openGauss install directory failed"
    exit 1
fi

# 下载openGauss安装包
echo "Download openGauss package"

cd ${gauss_install_dir}/openGauss/pkg

wget ${gauss_pkg_download_url}

if [ $? -ne 0 ]; then
    echo "Download openGauss package failed"
    exit 1
fi

ls -l

# Unzip openGauss package
echo "Unzip openGauss package"

cd ${gauss_install_dir}/openGauss/pkg

tar -xf ${gauss_pkg_name} -C ../server/

if [ $? -ne 0 ]; then
    echo "Unzip openGauss package failed"
    exit 1
fi

cd ../server
ls -l

# Run install.sh
echo "Run install.sh"

cd ${gauss_install_dir}/openGauss/server/simpleInstall/

echo 'yes' | sh install.sh -w "${db_password}" -p ${db_port} && source ~/.bashrc

# Query openGauss status
echo "Query openGauss status"

gs_ctl query -D $GAUSSHOME/data/single_node

if [ $? -ne 0 ]; then
    echo "Query openGauss status failed"
    exit 1
fi

echo "Install openGauss success"
Logo

鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。

更多推荐