开机自动启动oracle数据库脚本

时间:2021-01-08 07:49:00

case $1 in

start)

su - "$ORACLE_USER" << E00

lsnrctl start

sqlplus /nolog << EOS

connect / as sysdba

startup

EOS

emctl start dbconsole

isqlplusctl start

EOO

;;

stop)

su - "$ORACLE_USER" << EOO

lsnrctl stop

sqlplus /nolog << EOS

connect / as sysdba

shutdown immediate

EOS

emctl stop dbconsole

isqlplusctl stop

EOO

;;

restart)

$0 stop

$0 start

;;

*)

echo "Usage: $0 {start| stop | restart}"

;;

esac

报存成文件oracle,存放在/etc/rc.d/init.d

#chmod 755 oracle

#系统启动时启动数据库

$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

#在启动时停止数据库

$ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle #停止

$ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle #重新启动