Честно "украдено" с этого блога, но переведено и ПРОВЕРЕННО лично!
This is a how to autostart the Oracle 11g R2 Database Server on CentOS 6.2. I assume you have done the following:- Install an Oracle-ready CentOS 6.2 Linux box
- Install the Oracle 11g R2 Database Server on the CentOS 6.2 Linux box
- Configure a network listener for Oracle 11g R2 Database Server on the CentOS 6.2 Linux box
- Create a fresh Oracle 11g R2 database on the CentOS 6.2 Linux box
So, it's time to run the three installed components as Linux daemons. These components are: listener, database and enterprise manager. The main programs concerning the start and stop tasks for these components can be found at $ORACLE_HOME/bin, and they are:
- listener: lsnrctl {start|stop|...}
- database: dbstart / dbshut
- ent. manager: emctl {start|stop|...}
- Login as root user in the server and create the archive /etc/init.d/oracle with the following content:
#!/bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database Server is an RDBMS created by Oracle Corporation
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1/
ORACLE_USER=oracle
if [ ! -f$ORACLE_HOME/bin/dbstart ]; then
echo "Oracle startup: cannot start"
exit
fi
RETVAL=0
prog="oracle"
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
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
stop() {
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"Stoping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
RETVAL=$?
;;
status)
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|restart|status]"
exit 1
esac
exit $RETVAL
- First, ensure that the init.d script can be executed manually:
- Use chkconfig to register the init.d script on runlevels 3, 4 and 5:
$ sudo chkconfig --add oracle
$ chkconfig --list oracle oracle 0:off 1:off 2:off 3:on 4:on 5:on 6:off
- Reboot and enjoy!
- Не забываем про файл /etc/oratab. Для автоматического запуска экземпляра базы данных необходимо параметр "N" в конце строки заменить на "Y", например так:
if so, then stop it:$ sudo chmod +x /etc/init.d/oracle $ sudo /etc/init.d/oracle start
$ sudo /etc/init.d/oracle stop
DB:/u01/app/oracle/product/11.2.0/db_1:Y
Большое спасибо за толковую и подробную статью.
ОтветитьУдалитьЧестно говоря, не моя, но найдено всё мной! :-)
Удалить"Переведено"? Неплохо переведен (вставлено что-то свое) п.4.
ОтветитьУдалить