Init Script2014/10/05 |
Create an init Script to make Oracle start automatically on system booting.
|
|
[1] | Set environment variables for "oracle" user like follows. |
[oracle@db01 ~]$
vi /etc/oratab # end line: change db01:/usr/oracle/app/product/11.2.0/dbhome_1: Y
[oracle@db01 ~]$
vi ~/.bash_profile # add follows to the end export ORACLE_SID=db01 |
[2] | Create an init Script with the root user. |
[root@db01 ~]#
vi /etc/rc.d/init.d/oracle # it's an example, edit it you like. #!/bin/bash # oracle: Start/Stop Oracle Database 11g R2 # # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # # processname: oracle . /etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/usr/oracle/app/product/11.2.0/dbhome_1 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 chmod 755 /etc/rc.d/init.d/oracle [root@db01 ~]# chkconfig --add oracle [root@db01 ~]# chkconfig oracle on
|
Sponsored Link |
|