分类: Oracle
2005-12-30 11:20:17
1 建立文件/etc/init.d/oracle内容后。
2 使这一文件可以执行 chmod a+x /etc/init.d/oracle
3 测试/etc/init.d/oracle start和/etc/init.d/oracle可以正常启动和关闭数据库
4 建立联结
ln -s /etc/init.d/oracle /etc/rc3.d/S95oracle
ln -s /etc/init.d/oracle /etc/rc5.d/S95oracle
ln -s /etc/init.d/oracle /etc/rc0.d/K05oracle
ln -s /etc/init.d/oracle /etc/rc1.d/K05oracle
ln -s /etc/init.d/oracle /etc/rc2.d/K05oracle
ln -s /etc/init.d/oracle /etc/rc4.d/K05oracle
ln -s /etc/init.d/oracle /etc/rc6.d/K05oracle
这样在系统启动时将可以自动启动数据库,系统关闭时将自动关闭数据库
可以通过数据库的alert文件确认。
##########start of /etc/init.d/oracle################
#!/bin/bash
#
# chkconfig: 35 95 5
# description: Startup/shutdown script for oracle listener
# and instance;
# tested in rhel as 3u3 with oracle 10gR1
# writen by blue_stone@xinhuanet.com
# 12/30/2005
case "$1" in
start)
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
touch /var/lock/subsys/oracle
# start tsnlisnter
echo "start tsnlisnter"
su - oracle -c "lsnrctl start"
# start database
echo "Start Oracle database instance"
su - oracle -c "echo "
CONN / AS SYSDBA
STARTUP
exit "|sqlplus /NOLOG"
# start enterprise manager
#echo " Start Emterprise Manager"
#su - oracle -c "emctl start dbconsole"
# start isqlplus
#echo "Start isqlplus"
#su - oracle -c "isqlplusctl start"
;;
stop)
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
rm -rf /var/lock/subsys/oracle
# shutdown database
echo "Shutdown Oracle database instance"
su - oracle -c "echo "
CONN / AS SYSDBA
SHUTDOWN immediate
exit "|sqlplus /NOLOG"
# stop tsnlisnter
echo "Stop tsnlisnter"
su - oracle -c "lsnrctl stop"
# stop enterprise manager
#echo " Stop Emterprise Manager"
#su - oracle -c "emctl stop dbconsole"
# stop isqlplus
#echo "Stop isqlplus"
#su - oracle -c "isqlplusctl stop"
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0
##########end of /etc/init.d/oracle################