Chinaunix首页 | 论坛 | 博客
  • 博客访问: 486821
  • 博文数量: 142
  • 博客积分: 4126
  • 博客等级: 上校
  • 技术积分: 1545
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-22 10:03
文章分类

全部博文(142)

文章存档

2011年(8)

2010年(7)

2009年(64)

2008年(63)

我的朋友

分类:

2008-03-20 11:16:43

起初是在网上找了一个脚本,发现有些问题,自己改了改,可以用了。
在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

       

阅读(1271) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-07-17 17:06:35

老大,我问一下,我按照你上面的这个测试了一下,在root用户下是没问题的,但是我的oracle数据库是在oracle这个用户下的,在oracle这个用户下,你上面那个oracle文件start时,里面有要我输入密码的,而且stop选项没反应。请问这个是怎么回事?