Linux 安装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
一、创建安装脚本
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
相关推荐
Hody 2020-08-16
FightFourEggs 2020-08-16
yanghuatong 2020-08-16
LuoXinLoves 2020-08-09
Justdoit00 2020-06-26
娜娜 2020-06-22
lklong 2020-11-22
oraclemch 2020-11-06
shilukun 2020-10-10
周嘉笙 2020-11-09
iilegend 2020-10-19
EricRay 2020-10-16
zhuzhufxz 2020-09-16
dataminer 2020-08-17
bfcady 2020-08-16
数据库设计 2020-08-16
Seandba 2020-08-16
Omega 2020-08-16