Chinaunix首页 | 论坛 | 博客
  • 博客访问: 877212
  • 博文数量: 206
  • 博客积分: 10276
  • 博客等级: 上将
  • 技术积分: 2358
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-01 02:41
文章分类

全部博文(206)

文章存档

2014年(1)

2013年(1)

2012年(2)

2011年(10)

2010年(14)

2009年(15)

2008年(33)

2007年(90)

2006年(40)

我的朋友

分类: Oracle

2008-10-05 16:45:26

1。生成dbora脚本
su - root
vi /etc/init.d/dbora
在脚本中添加如下内容:
#
#!/bin/sh
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/oracle/product/9.2.0
ORA_OWNER=oracle
LOG=$ORA_HOME/startup.log
touch $LOG
chmod a+r $LOG
if [! -f $ORA_HOME/bin/dbstart]
then
     echo "Oracle startup: cannot start"
     exit
fi
case $1 in
'start')
        echo "$0: starting up" >> $LOG
        date >> $LOG
        # Start Oracle Net
        if [ -f $ORA_HOME/bin/tnslsnr ] ;
        then
                echo "starting Oracle Net listener"
                su - $ORA_OWNER -c $ORA_HOME/bin/lsnrctl start >> $LOG 2>&1 &
        fi
        echo "starting Oracle databases"
        su - $ORA_OWNER -c $ORA_HOME/bin/dbstart >> $LOG 2>&1
        ;;
'stop')
        echo "$0: shutting down" >> $LOG
        date >> $LOG
        # Stop Oracle Net
        if [ -f $ORACLE_HOME/bin/tnslsnr ] ;
        then
                echo "stopping Oracle Net listener"
                su - $ORA_OWNER -c $ORA_HOME/bin/lsnrctl stop >> $LOG 2>&1
        fi
        echo "stopping Oracle databases"
        su - $ORA_OWNER -c $ORA_HOME/bin/dbshut >> $LOG 2>&1
        ;;
*)
        echo "usage: $0 {start|stop}"
        exit
        ;;
esac
#
exit
其中ORA_HOME变量设置成实际的$ORACLE_HOME路径,同样ORA_OWNER也设置成安装Oracle软件的操作系统用户名。
2。给dbora脚本添加可执行的属性
chmod a+x /etc/init.d/dbora
3。将脚本link到run level的相应路径下,实现自启动和自关闭
假设Linux系统的run level是3(启动时进入字符界面),那么
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc3.d/K01dbora
假设Linux系统的run level是5(启动时进入图形界面),那么
ln -s /etc/init.d/dbora /etc/rc5.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc5.d/K01dbora
4。重新启动系统,检查Oracle是否已经自动启动了,如果没有,那么检查$ORACLE_HOME/startup.log文件,看看有什么错误信息。
 
呵呵,其实chkconfig也就是在帮我们作link而已。
不过,chkconfig确实比较简单,我是没有习惯用而已,因为要使脚本支持chkconfig,在脚本的头部还要加两行注释。
well,添加一个使用chkconfig的文章吧
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut >> $LOG 2>&1
要是这时有用户连着能关掉么?
有用户连接时候是否可以关闭
要看dbshut脚本
9i中默认安装的dbshut脚本
只是执行shutdown命令,所以会导致有用户连接的时候无法关闭数据库
我们只需要手工去修改dbshut脚本
将其中的shutdown命令改为shutdown immediate就可以了
追加
在 start中追加 lsnrctl start&
在 stop中追加 lsnrctl stop&
阅读(2184) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~