Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2381296
  • 博文数量: 384
  • 博客积分: 10193
  • 博客等级: 上将
  • 技术积分: 3785
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-09 18:02
文章分类

全部博文(384)

文章存档

2011年(10)

2010年(29)

2009年(39)

2008年(36)

2007年(43)

2006年(198)

2005年(29)

分类: Oracle

2005-12-30 11:20:17

在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文件确认。


##########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################

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