Oracle设置为自启动
学习了:http://blog.itpub.net/31015730/viewspace-2148412/
oracle自带dbstart命令,主要进行系统启动设置;
在/etc/rc.d/init.d中创建oracle文件,这个文件拷贝过来,注意不需要修改$1为$ORACLE_HOME;
注意使用chkconfig oracle on命令进行oracle启动的添加;
#!/bin/bash # oracle: Start/Stop Oracle Database 11g R2 # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # . /etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0 ORACLE_USER=oracle case "$1" in 'start') if [ -f $LOCKFILE ]; then echo $0 already running. exit 1 fi echo -n $"Starting Oracle Database:" su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start" su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole" touch $LOCKFILE ;; 'stop') if [ ! -f $LOCKFILE ]; then echo $0 already stopping. exit 1 fi echo -n $"Stopping Oracle Database:" su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop" su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut" su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole" rm -f $LOCKFILE ;; 'restart') $0 stop $0 start ;; 'status') if [ -f $LOCKFILE ]; then echo $0 started. else echo $0 stopped. fi ;; *) echo "Usage: $0 [start|stop|status]" exit 1 esac exit 0
修改oracle文件权限,设置开机启动
chmod 755 /etc/init.d/oracle chkconfig oracle on