Este procedimento se aplica caso o ambiente em questão não tenha o Oracle Restart configurado. De início, podemos mudar o arquivo /etc/oratb conforme abaixo:
[root@oel8 ~]# cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
TALAMO:/oracle/18.0.0/product:Y
[root@oel8 ~]#
Após isso, podemos criar o arquivo dbora com o seguinte conteúdo:
[root@oel8 ~]# cat /etc/init.d/dbora
#! /bin/sh
# description: Oracle auto start-stop script.
ORA_HOME=/oracle/18.0.0/product
ORA_OWNER=oracle
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/dbstart $ORA_HOME" &
touch /var/lock/subsys/dbora
;;
'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 $ORA_HOME" &
rm -f /var/lock/subsys/dbora
;;
esac
[root@oel8 ~]#
Ajustando permissões do novo arquivo:
[root@oel8 ~]# chgrp dba /etc/init.d/dbora
[root@oel8 ~]# chmod 750 /etc/init.d/dbora
[root@oel8 ~]#
Criando links simbólicos:
[root@oel8 ~]# ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
[root@oel8 ~]# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
[root@oel8 ~]# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
[root@oel8 ~]#
Após isso, podemos reiniciar o ambiente e checar se o banco de dados foi inicializado automaticamente:
[oracle@oel8 ~]$ uptime
04:45:55 up 2 min, 1 user, load average: 4.30, 2.31, 0.90
[oracle@oel8 ~]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Mon Mar 8 04:46:04 2021
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> select instance_name,status,startup_time from v$instance;
INSTANCE_NAME STATUS STARTUP_T
---------------- ------------ ---------
TALAMO OPEN 08-MAR-21
SQL>
Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.