viernes, 23 de febrero de 2024

Oracle Base de Datos y Listener Automatizar el inicio (Oracle Auto Start)

 Oracle Base de Datos y Listener Automatizar el inicio

 Ya sabemos que cada vez que enviamos reiniciar el servidor de la base de datos el servicio no levanta de forma automática por lo que es necesario realizarlo de forma manual. Este proceso se vuelve tedioso cuando están en ventanas de mantenimiento y tienes múltiples servidores de base de datos que reiniciar.

Aquí les comparto como lo pueden hacer que sea de forma automática el inicio, cabe indicar que este articulo aplica para a base de datos standalone.

Antes de empezar debemos de tener los siguientes datos:

 

ORACLE_HOME

/u01/app/oracle/product/19.3/db_home

DB Name

orcl

Nombre Listener

LISTENER

Archivo Oratab

/etc/oratab

 

1.      Editar archive /etc/oratab cambiar flag de :N a :Y

nano /etc/oratab

 Como debe de quedar

orcl:/u01/app/oracle/product/19.3/db_home:Y

 2.      Crear archivo dboracle

nano /etc/init.d/dboracle

 Pegar código reemplazado los valores según tu configuración

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# 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/19.3/db_home
ORA_OWNER=oracle
 
 
if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi
 
 
case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login 
        # will not prompt the user for any values
        # Remove "&" if you don't want startup as a background process.
        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start LISTENER" &
        su - $ORA_OWNER -c $ORA_HOME/bin/dbstart &
        touch /var/lock/subsys/oracle
        ;;
    '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
        Su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop LISTENER"
        rm -f /var/lock/subsys/oracle
        ;;
esac
exit

 

3.      Permisos al archivo dboracle

chmod 750 /etc/init.d/dboracle

 

4.      Asociar  dboracle como servicio del sistema operativo

systemctl enable dboracle
chkconfig dboracle on
service dboracle start

 

 

5.      Reiniciar el sistema para probar

Init 6

 

Espero les sirva para optimizar sus tiempos de manteniento