===========linux下开机自动启动Oracle脚本============
#注意:例子中的oralce命令在/u01/app/oracle/product/10.2.0/db_1/bin/目录。
#修改ORA_HOME的值为ORACLE的目录。
- #!/bin/bash
- #root
- #chkconfig: 345 51 49
- #description: starts the oracle dabase deamons
- #
- ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
- ORA_OWNER=oracle
- case "$1" in
- 'start')
- echo -ne "Starting oracle 11g ... \n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
- echo -e "Done.\n"
- echo -e "Starting Oracle Listeners ... \n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
- echo -e "Done.\n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole" #启动web管理界面:
- echo -ne "input root password......\n"
- su - root -c "touch /var/lock/subsys/oracle11g"
- echo -e "\n"
- ;;
- 'stop')
- echo -ne "shutting down oracle 11g ... \n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
- echo -ne "dbshut ok !\n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
- echo -ne "lsnrctl stop ok !\n"
- su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
- #su - root -c "/home/oracle/ufsoft/stop.sh"
- echo -ne "input root password......\n"
- su - root -c "rm -f /var/lock/subsys/oracle11g"
- echo
- ;;
- 'restart')
- echo -ne "restarting oracle 11g ... \n"
- $0 stop
- $0 start
- echo
- ;;
- *)
- echo "Usage: oracle {start|stop|restart} "
- exit 1
- esac
- exit 0
============建立一个名为oralce10g的脚本==========
[root@cwserver ~]# gedit /etc/rc.d/init.d/oracle10g
#复制粘贴本文开头的脚本。或者直接使用附件中的oracle10g文件
#给予执行权限
[root@cwserver ~]# chmod 755 /etc/rc.d/init.d/oracle10g
#注意:例子中的oralce命令在/home/oracle/oracle/product/10.2.0/db_1/bin目录。
你可以自己修改成自己的目录。
============添加到启动、关闭、重启动服务序列中===
$ ln -s /etc/rc.d/init.d/oracle10g /etc/rc.d/rc2.d/S99oracle10g
$ ln -s /etc/rc.d/init.d/oracle10g /etc/rc.d/rc3.d/S99oracle10g
$ ln -s /etc/rc.d/init.d/oracle10g /etc/rc.d/rc5.d/S99oracle10g
$ ln -s /etc/rc.d/init.d/oracle10g /etc/rc.d/rc0.d/K01oracle10g
$ ln -s /etc/rc.d/init.d/oracle10g /etc/rc.d/rc6.d/K01oracle10g
============添加并启动察看服务=============================
$/sbin/chkconfig --add /etc/rc.d/init.d/oracle10g
$/sbin/chkconfig --list /etc/rc.d/init.d/oracle10g
============修改Oracle系统配置文件/etc/oratab=====
$ gedit /etc/oratab
最后一行更改为:
orcl:/home/oracle/oracle/product/10.2.0/db_1:Y
============end==大功告成====================
阅读(7370) | 评论(0) | 转发(1) |