设置数据库自启脚本

设置数据库自启脚本:
cd /usr/u01/app/product/11.2.0/dbhome_1/bin
[oracle@200-168-1-4 bin]$ vi dbstart
添加:
ORACLE_HOME="/usr/u01/app/product/11.2.0/dbhome_1"
修改:
ORACLE_HOME_LISTNER=$ORACLE_HOME

[oracle@200-168-1-4 bin]$ vi dbshut
添加:
ORACLE_HOME="/usr/u01/app/product/11.2.0/dbhome_1"
修改:
ORACLE_HOME_LISTNER=$ORACLE_HOME

--配置需要启动的实例:格式:$ORACLE_SID:$ORACLE_HOME:[Y|N]
[oracle@200-168-1-4 bin]$ vi /etc/oratab 
lubinsu:/usr/u01/app/product/11.2.0/dbhome_1:Y

新建自启脚本:
[root@200-168-1-4 init.d]# cat oralubinsu
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g release 2 autorun services
JAVA_HOME=/home/lubinsu/soft/app/jdk7
CLASSPATH=/usr/u01/app/product/11.2.0/dbhome_1/JRE:/usr/u01/app/product/11.2.0/dbhome_1/jlib:/usr/u01/app/product/11.2.0/dbhome_1/rdbms/jlib
ORACLE_BASE=/usr/u01/app; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME

ORACLE_SID=lubinsu; export ORACLE_SID

export JAVA_HOME
export CLASSPATH
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"

# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|reload|reload}"
exit 1
esac
exit 0echo "Oracle Start Succesful!OK." 
;; 
stop) 
# Oracle listener and instance shutdown 
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut 
echo "Oracle Stop Succesful!OK." 
;;
reload|restart) 
$0 stop 
$0 start 
;; 
*) 
echo $"Usage: `basename $0` {start|stop|reload|reload}" 
exit 1
--记住,下面这两行是必须的,固定格式:
# chkconfig: 345 61 61
# description: Oracle 11g release 2 autorun services
--加入启动程序中:
# chkconfig --add oralubinsu

--现在还可以这么启动关闭数据库:
[root@200-168-1-4 init.d]# service oralubinsu stop 
Processing Database instance "lubinsu": log file /usr/u01/app/product/11.2.0/dbhome_1/shutdown.log 
Oracle Stop Succesful!OK. 
[root@200-168-1-4 init.d]# service oralubinsu start 
Processing Database instance "lubinsu": log file /usr/u01/app/product/11.2.0/dbhome_1/startup.log 
Oracle Start Succesful!OK.

你可能感兴趣的:(oracle,oracle,linux,shell,11g)