Chinaunix首页 | 论坛 | 博客
  • 博客访问: 59998
  • 博文数量: 6
  • 博客积分: 770
  • 博客等级: 军士长
  • 技术积分: 180
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-24 20:54
文章存档

2010年(5)

2008年(1)

我的朋友

分类: Oracle

2008-03-28 10:35:08

oracle 自动启动脚本的编写、
修改Oracle系统配置文件/etc/oratab
/etc/oratab 格式为: SID:ORACLE_HOME:AUTO
把AUTO域设置为Y(大写),只有这样,oracle 自带的dbstart和dbshut才能够发挥作用。我的为:
orcl:/opt/app/oracle/product/10.2.0/db_1:Y

2、 编写服务脚本:
如下
#!/bin/bash
#
#################FUNCTION#############
#
# AutoStart Oracle and listener
# AutoStop Oracle and listener
#
#####################################
#
# Created by ouyangyu  2008-3-28
#
case "$1" in
start)
echo "开始启动 Oracle 10gR2 数据库系统 ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : 开始启动 Oracle 10gR2 数据库系统." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
dbstart >> /home/oracle/log/oracle
echo +"%T %a %D : 完成."
echo "开始启动 Oracle 监听程序 ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : 开始启动 Oracle 监听程序." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
lsnrctl start >> /home/oracle/log/oracle
echo +"%T %a %D :完成。"
echo "开始启动 Oracle 管理程序 ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : 开始启动 Oracle 管理程序." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
emctl start dbconsole >> /home/oracle/log/oracle
echo +"%T %a %D :完成。"
echo ""
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : Finished." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
touch /home/oracle/log/oracle_touch
;;
stop)
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
su - oracle -c "lsnrctl stop" >> /home/oracle/log/oracle
echo "Done."
echo "关闭 Oracle 管理程序 ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : 关闭 Oracle 管理程序." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
emctl stop dbconsole >> /home/oracle/log/oracle
echo +"%T %a %D :完成。"
 
rm -f /home/oracle/log/oracle_touch
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle
su - oracle -c "dbshut" >>/home/oracle/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /home/oracle/log/oracle
date +" %T %a %D : Finished." >> /home/oracle/log/oracle
echo "-------------------------------------------------" >> /home/oracle/log/oracle

;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac
将脚本命名为oracle,保存在/etc/rc.d/init.d下
改变文件属性:chmod 755 oracle
注意:在windows下编辑此文件时有DOS格式字符导致在linux下不能够正常运行,建议用gedit 或用 vi编辑
3、建立服务连接:
系统启动时启动数据库,我们需要以下连结∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc5.d/S99oracle #rc4.d unused

--------------------------------------------------------------------------------
要在重新启动时停止数据库,我们需要以下连结∶

--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle # 停止
$ ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle # 重新启动
 
阅读(734) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:oracle DBA 命令参考: alter database

给主人留下些什么吧!~~