viernes, 10 de mayo de 2013

Inicio automático Oracle en Linux

En este post nos indica cómo configurar el inicio automático de Oracle 10 en un S.O. Linux (Red Hat).

Luego de instalado Oracle, debemos editar el archivo /etc/oratab, donde dice algo similar a:

$ORACLE_SID:$ORACLE_HOME:N

Cambiamos la "N" por "Y" -- o sea le decimos que sí! :) --

Quedaría:

$ORACLE_SID:$ORACLE_HOME:Y

Ejemplo

orcl10:/u01/app/oracle/product/10.2.0/db_1:Y

Luego creamos el archivo /etc/init.d/dbora con el usuario root, con el siguiente contenido:

#!/bin/bash
#
# chkconfig: 35 99 10
# description: Starts and stops Oracle processes
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
#
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1ORA_OWNER=oracle
case "$1" in
'start')
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"

if [ -f $ORA_HOME/bin/oemctl ]; then
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
fi

su - $ORA_OWNER -c $ORA_HOME/bin/dbstart

# Start the Intelligent Agent
#if [ -f $ORA_HOME/bin/agentctl ]; then
# su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
#else
# su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_start"
#fi
# Start Enterprise Management Console
#if [ -f $ORA_HOME/bin/oemctl ]; then
# su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
#fi
# Start HTTP Server
#if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
# su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
#fi
touch /var/lock/subsys/dbora
;;
'stop')
# Stop HTTP Server
#if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
# su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
#fi
# Stop Enterprise Management Console
if [ -f $ORA_HOME/bin/oemctl ]; then
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
fi
# Stop the Intelligent Agent
#if [ -f $ORA_HOME/bin/agentctl ]; then
# su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl stop"
#else
# su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_stop"
#fi
# Stop the TNS Listener su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
rm -f /var/lock/subsys/dbora
;;
esac

# End of script dbora
A continuación (seguimos con root) seteamos los privilegios sobre el archivo dbora:

chmod 750 /etc/init.d/dbora
Y asociamos al servicio con los runlevels apropiados:

chkconfig --level 345 dbora on
La instancia ahora debería iniciarse automáticamente al reinicio de nuestro servidor Oracle. Hay un bug conocido que nos puede complicar al reinicio, pero no preocuparse, porque por suerte "es conocido" y tiene solución!

Si nos encontramos con este error:

Failed to auto-start Oracle Net Listener
using /ade/vikrkuma_new/bin/tnslsnr

Se debe a un path hard-coded en el script dbstart. Para solucionarlo editamos el archivo $ORACLE_HOME/bin/dbstart y reemplazamos la siguiente línea (línea 78 aprox.):

ORACLE_HOME_LISTENER=/ade/vikrkuma_new/oracle
Con ésto:

ORACLE_HOME_LISTENER=$ORACLE_HOME
Ahora sí, con esta modificación el listener debería iniciar automáticamente sin problema alguno.

Espero que este post les sea de utilidad!

y cualquier corrección se les agradece...

No hay comentarios:

Publicar un comentario