1、设置OS变量
修改/etc/oratab文件,添加内容如下
o12c:/u01/app/oracle/product/12.1.0.2/db_1:N
创建脚本存放目录,编辑脚本oraset.sh
mkdir /home/oracle/scripts
cd /home/oracle/scripts
vim oraset.sh,内容如下:
#!/bin/bash
#################
if [ -f /etc/oratab ];then
OTAB=/etc/oratab
elif [ -f /var/opt/oracle/oratab ];then
OTAB=/var/opt/oracle/oratab
else
echo "oratab file not found."
exit
fi
#
if [ -z $1 ];then
SIDLIST=$(egrep -v "#|\*" ${OTAB} | cut -f1 -d:)
PS3='SID? '
select sid in ${SIDLIST};do
if [ -n $sid ];then
HOLD_SID=$sid
break
fi
done
else
if egrep -v '#\*' ${OTAB} | grep -w "${1}:">/dev/null;then
HOLD_SID=$1
else
echo "SID: $1 not found in $OTAB"
fi
sh