1.建立启动文件:
#cd /etc/rc.d/init.d
#touch oracle10g
2.为脚本设置权限:
#chmod 755 oracle10g
3 编辑脚本:
#vi oracle10g
内容如下:
#!/bin/bash
#
# chkconfig: 1235 99 01
# description: init script to start/stop oracle database 10g, TNS listener, EMS, isqlplus
#
#
#
# match these values to your environment:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle
# export ORACLE_TERM=xterm
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
export NLS_LANG='AMERICAN_AMERICA.UTF8'
export ORACLE_SID=db
# export DISPLAY=localhost:0
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<lsnrctl start
sqlplus /nolog<connect / as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start
EOO
;;
stop)
su - "$ORACLE_USER"<lsnrctl stop
sqlplus /nolog<connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop
EOO
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
说明:chkconfig:1235 99 01 是指脚本将为运行级1 , 2, 3, 5启动oracle 10g服务,启动优先级为99,关闭优先级为01
4.设置oracle 数据库的自启动"
#chkconfig --level 1235 oracle10g on
5.使用sevice启动oracle 数据库:
#service oracle10g start 如果能够启动,说明配置成功
#service oracle10g stop 停止数据库
OK !一切完成!望大家多多支持!
本文出自 “菜鸟网络工程师” 博客,谢绝转载!