当前位置:Gxlcms > mysql > Linux安装Oracle的shell脚本

Linux安装Oracle的shell脚本

时间:2021-07-01 10:21:17 帮助过:39人阅读

在Linux平台下面安装Oracle,要做好多的准备工作。比如建立user,修改环境变量,一些oracle所需的参数。现在整理成shell脚本,以

在Linux平台下面安装Oracle,要做好多的准备工作。比如建立user,,修改环境变量,一些oracle所需的参数。现在整理成shell脚本,以方便安装。
一、创建安装脚本
vi install.sh
#/bin/bash
. ./adduser.sh
. ./sysctl.sh
. ./limits.sh
. ./mkdir.sh
. ./chprofile.sh

二、添加用户及用户组
vi adduser.sh

#/bin/bash
ADDGROUPS="oinstall dba"
ADDUSERS="oracle"

for group in $ADDGROUPS ; do

if [ -z "$( awk -F: '{print $1}' /etc/group |grep $group)" ]; then
groupadd $group
echo " Add new group $group"
else
echo " Group $group already existed"
fi
done

for user in $ADDUSERS ; do

if [ -z "$( awk -F: '{print $1}' /etc/passwd |grep $user)" ]; then
useradd $user
echo " Add new user $user"
else
echo " User $user already existed"
fi
done

if $(usermod -g oinstall -G dba oracle) ; then
echo " Modify user oracle account success"
else
echo " Modify user oracle account failure"
fi

三、创建所需的目录
vi mkdir.sh

#/bin/bash
ORACLE_FILE_BASE="/u01/app/oracle"
ORACLE_FILE_VAR="/var/opt/oracle"
ORACLE_FILE_HOME="$ORACLE_FILE_BASE/product/10.2.0/db_1"

for directory in $ORACLE_FILE_BASE $ORACLE_FILE_VAR $ORACLE_FILE_HOME ; do
if [ -d $directory ]; then
echo " Directory $directory already existed"
else
mkdir -p $directory
chown -R oracle.dba $directory
echo " Change directory $directory owner and group success"
fi
done

linux

人气教程排行