1,将脚本和opengauss软件包放到同一个目录下(不要放到/root下面,建议放到/opt/soft下面目录权限要有755),不需要进行解压缩,安装包下载地址如下:
软件包 | openGauss
2.规划好gs的数据目录,提前创建好目录,例如放到/data/guassdb/data下面,你只需要提前创建好/data就行了
3.将操作系统镜像ISO挂载到/os下面
下面就是执行安装脚本就行了:
#!/usr/bin/bash
export LANG=en_US
##check current dir
CURRENT_DIR=$(pwd)
if [ CDIR=${CURRENT_DIR:0:5} == '/root' ]
then
echo "Error: current dir can\'t be /root!"
exit
fi
#check db package
DB_PKG=`ls $CURRENT_DIR/openGauss-*-64bit-all.tar.gz |wc -l`
if [ $DB_PKG -lt 1 ]
then
echo "Error: Current Dir can\'t find package: openGauss-xx-64bit-all.tar.gz"
echo "You need put this scripts to openGauss package directory!!!"
exit
fi
###check iso mount point
if [ -d /os/Packages ]
then
if [ `du -sm /os |awk '{print $1}'` -lt 3000 ]
then
echo "Error:You Need mount ISO to /os"
exit
fi
else
echo "Error:You Need mount ISO to /os"
exit
fi
clear
echo "--------------------------------------------------------------------------------"
echo "--------------- ----------------"
echo "--------------- Welcome to Single openGauss install ----------------"
echo "--------------- --by Brent 20240601 ----------------"
echo "--------------------------------------------------------------------------------"
echo "Please Enter HOSTNAME:"
read HOSTNAME
echo "Please Enter Local IP :"
read IP
echo "Please Enter OpenGauss Setup Dir[/opt/huawei]:"
read SETUP_DIR
echo "Please Enter OpenGauss Data Dir[/data/opengauss/data]:"
read DATA_DIR
echo "Please Enter OpenGauss ClusterName:"
read CLUSTER_NAME
echo "Please Enter OpenGauss Listen Port[15400]:"
read PORT
echo "Please Enter OpenGauss CharSet[UTF8]:"
read CHARSET
if [ -z $SETUP_DIR ]
then
SETUP_DIR='/opt/huawei'
fi
if [ -z $CHARSET ]
then
CHARSET=UTF-8
fi
if [ -z $DATA_DIR ]
then
DATA_DIR=/data/opengauss/data
fi
if [ -z $PORT ]
then
PORT=15400
fi
KERNEL=`uname -r`
KERNEL_S=${KERNEL:0:1}
echo "################################################################################################"
echo "########################################System Env Config#######################################"
echo "################################################################################################"
echo " #######################################Modify HOSTNAME######################################"
case "$KERNEL_S" in
2)
sed -i 's/HOSTNAME=/#HOSTNAME=/' /etc/sysconfig/network
echo "HOSTNAME=$HOSTNAME" >>/etc/sysconfig/network
echo "##############################Disable Firewalld#############################"
service iptables stop
chkconfig iptables off
;;
*)
hostnamectl --static set-hostname $HOSTNAME
echo " ######################################Disable Firewalld#####################################"
systemctl disable firewalld
systemctl stop firewalld
timedatectl set-timezone "Asia/Shanghai"
systemctl stop avahi-dnsconfd
systemctl stop avahi-daemon
systemctl disable avahi-dnsconfd
systemctl disable avahi-daemon
systemctl stop NetworkManager
systemctl disable NetworkManager
#关闭时间同步
systemctl stop chronyd
systemctl disable chronyd
mv /etc/chrony.conf /etc/chrony.conf.bak
echo "NOZEROCONF=yes" >>/etc/sysconfig/network
;;
esac
echo "$IP $HOSTNAME" >> /etc/hosts
echo " #####################################Disable selinux########################################"
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
setenforce 0
echo " ####################################Config Yum Source#######################################"
mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
echo "
[OpenEuler]
name = Enterprise Linux OpenEuler DVD
baseurl=file:///os
gpgcheck=0
enabled=1
" >/etc/yum.repos.d/OpenEuler.repo
echo " #####################################Install Packages#######################################"
for i in tar libaio-devel compat-libstdc++ ksh compat-libcap1 elfutils-libelf-devel unixODBC-devel numactl-devel gcc gcc-c++ xorg-x11-xauth xterm make sysstat readline readline-devel openssl openssl-devel glibc libaio unzip libXtst java smartmontools openssh-clients compat-libstdc++ device-mapper-multipath compat-libcap1 dstat net-tools psmisc
do
yum install -y $i >/dev/null
done
for i in bc gcc gcc-c++ binutils make gdb cmake glibc ksh xterm elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc-devel libaio libaio-devel libXrender libXrender-devel libX11 libXau sysstat libXi libXtst libgcc librdmacm-devel libstdc++ libstdc++-devel libxcb net-tools nfs-utils compat-libcap1 compat-libstdc++ smartmontools targetcli python python-configshell python-rtslib python-six unixODBC unixODBC-devel unzip wget device-mapper device-mapper-multipath lrzsz
do
yum install -y $i >/dev/null
done
echo "################################################################################################"
echo "#######################################openGauss preinstall#####################################"
echo "################################################################################################"
echo " ################################Generate cluster_config.xml#################################"
>$CURRENT_DIR/cluster_config.xml
echo '<?xml version="1.0" encoding="UTF-8"?> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <ROOT> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <CLUSTER> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="clusterName" value="'$CLUSTER_NAME'" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="nodeNames" value="'$HOSTNAME'" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="gaussdbAppPath" value="'$SETUP_DIR'/install/app" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="gaussdbLogPath" value="'$SETUP_DIR'/log/omm" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="tmpMppdbPath" value="'$SETUP_DIR'/tmp" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="gaussdbToolPath" value="'$SETUP_DIR'/install/om" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="corePath" value="'$SETUP_DIR'/corefile" /> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="backIp1s" value="'$IP'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' </CLUSTER> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <DEVICELIST> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <DEVICE sn="'$HOSTNAME'"> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="name" value="'$HOSTNAME'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="azName" value="AZ1"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="azPriority" value="1"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="backIp1" value="'$IP'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="sshIp1" value="'$IP'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <!--dbnode--> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="dataNum" value="1"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="dataPortBase" value="15400"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="dataListenIp1" value="'$IP'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="dataNode1" value="'$DATA_DIR'"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' <PARAM name="dataNode1_syncNum" value="0"/> ' >>$CURRENT_DIR/cluster_config.xml
echo ' </DEVICE> ' >>$CURRENT_DIR/cluster_config.xml
echo ' </DEVICELIST> ' >>$CURRENT_DIR/cluster_config.xml
echo '</ROOT> ' >>$CURRENT_DIR/cluster_config.xml
tar -zxf openGauss-*-openEuler-64bit-all.tar.gz
tar -zxf openGauss-*-openEuler-64bit-om.tar.gz
cd script
##preinstall
./gs_preinstall -U omm -G dbgrp -X $CURRENT_DIR/cluster_config.xml
##install
echo "################################################################################################"
echo "#########################################openGauss install######################################"
echo "################################################################################################"
su - omm -c "gs_install -X $CURRENT_DIR/cluster_config.xml --gsinit-parameter=\"--locale=en_US.${CHARSET}\""
##status
su - omm -c "gs_om -t status"
echo ""
echo ""
echo "You Can See preinstall log at : $SETUP_DIR/log/omm/omm/om/gs_preinstall-xxxxx.log"
echo "You Can See install log at : $SETUP_DIR/log/omm/omm/om/gs_install-xxxxx.log or $SETUP_DIR/log/omm/omm/om/gs_local-xxxx.log"
安装截图如下:
中间需要输入操作系统omm密码和数据库omm密码两次
安装完成后,可以切换到omm用户登录到数据库: