起初是在网上找了一个脚本,发现有些问题,自己改了改,可以用了。
在redhat系统关闭的过程中会检查/var/lock/subsys下的文件,逐一关闭每个服务,如果某一运行的服务在/var/lock/subsys下没有相应的选项。在系统关闭的时候,会像杀死普通进程一样杀死这个服务。
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文件确认。
oracle:
##########start of /etc/init.d/oracle################
#!/bin/bash
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################
|
把开机启动tomcat的脚本也贴这吧,以后好找。(如果和oracle在一台机器上。别忘记修改tomcat的端口)。
tomcat:
##########start of /etc/init.d/tomcat################
#!/bin/bash
#
#export JAVA_HOME=/usr/local/jdk
#export PATH=$JAVA_HOME/bin:$PATH
#export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
#export CATALINA_BASE=/usr/local/tomcat
#export CATALINA_HOME=/usr/local/tomcat
case "$1" in start) echo "start tomcat" /usr/local/tomcat/bin/startup.sh
;; stop)
echo "Shutdown tomcat" /usr/local/tomcat/bin/shutdown.sh ;; *) echo "Usage: $0 { start | stop }" exit 1 ;; esac exit 0 ##########end of /etc/init.d/tomcat################
# ln -s /etc/init.d/tomcat /etc/rc3.d/S96tomcat
# ln -s /etc/init.d/tomcat /etc/rc5.d/S96tomcat
# ln -s /etc/init.d/tomcat /etc/rc0.d/K04tomcat
# ln -s /etc/init.d/tomcat /etc/rc1.d/K04tomcat
# ln -s /etc/init.d/tomcat /etc/rc2.d/K04tomcat
# ln -s /etc/init.d/tomcat /etc/rc4.d/K04tomcat
|
阅读(1263) | 评论(1) | 转发(0) |