Inicializando bancos automáticamente

Esse fim de semana tivemos uma queda de energia e o tempo foi maior do que os NoBreakes puderam suportar. Consequencia: nossos servidores foram desligados. Mas o melhor foi que semana passada desligamos a inicialização automática dos bancos para fazer um teste de performance e uso de memória. Ou seja, tive que conectar-me ao servidor no Sábado afim de colocar as principais bases no ar.

Normalmente, no LINUX, os scripts de inicialização de banco ficam dentro do diretório /etc/rc.d/init.d . Lá você poderá encontrar arquivos como dbifx ou dbora, que geralmente contém os scripts de inicialização dos bancos que vocÊ deseja que sejam iniciados automáticamente quando o servidor é ligado. Os arquivos e locais podem variar dependendo da versão do Linux (ou S.O.), mas manteremos o escopo dentro desse padrão. Procure por arquivos com nome dbifx ou dbora dentro do diretório /etc/rc.d/init.d . Se não existir crie o seu.
Existem várias formas de informar que instâncias você deseja que sejam iniciadas automáticamente. Abaixo um exemplo de um trecho em Informix e Oracle:
start() {
echo "`date`: iniciando banco informix">>$LOGFILE 2>&1
for i in `ls -1 /opt/informix/etc/onconfig.*
cut -d. -f2
grep -v std `
ONCONFIG=onconfig.$i export ONCONFIG;
export INFORMIXDIR=/opt/informix
$INFORMIXDIR/bin/oninit>/dev/null 2>&1
cut -c 1-48`
if [ "$STATUS@" = "shared memory not initialized for INFORMIXSERVER@" ]; then
echo -e "Informix " $i "\t" OFFLINE>>$LOGFILE 2>&1
echo -e "Informix 10" $i "\t" `$INFORMIXDIR/bin/onstat -
awk -F "--" '{ print $2,$4,$3 }'`>>$LOGFILE 2>&1

# Set this to bring up Oracle Net Listener
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"

# Start Oracle Net Listener
if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo "$0: Starting Oracle Net Listener" >> $LOG 2>&1
$ORACLE_HOME_LISTNER/bin/lsnrctl start >> $LOG 2>&1 &
export VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version
grep "LSNRCTL for "
cut -d' ' -f5
cut -d'.' -f1`
echo "Failed to auto-start Oracle Net Listene using $ORACLE_HOME_LISTNER/bin/tnslsnr"

# Set this in accordance with the platform
if [ ! $ORATAB ] ; then
echo "Set ORATAB to dir where oratab file is located"
exit 1;

startinst() {
# Called programs use same database ID

# Put $ORACLE_HOME/bin into PATH and export.
PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH
# add for bug # 652997

echo ""
echo "$0: Starting up database \"$ORACLE_SID\""
echo ""

if [ -f $SPFILE -o -f $SPFILE1 -o -f $PFILE ] ; then
sqldba command=startup ;
$SQLDBA << font="">
connect / as sysdba

This weekend we had some energy down at the company and the time was great than the time that the No Breakers could support. Consequence: our servers went down. But the best of all was that in the week before we turned off the automatic startup of the databases, for a performance and memory utilization test. So, I had to connect there to bring up the main instances online.
Normally, on LINUX, the initialization script for the databases that you want to startup automatically stays at the /etc/rc.d/init.d directory. There you'll find files as the dbifx and dbora, which normally keeps the scripts for the instances that you want to automatically startup when the server is turned on. The files content and places can be different depending on the Linux version or Operational System, but we keep the default scope. Search for files with the name of "dbifx" or "dbora" inside the /etc/rc.d/init.d directory. If it doesn't exist, create your own!
There are a lot of syntaxes to inform the bases that you want to startup automatically. Above there's a part of this script to Informix and Oracle databases.


  1. The time is currently x o'clock Eastern Standard time. From March to November it is Daylight saving s time, which is when we turn out clocks forward an hour as part of a scheme to be out of bed when it's light.

    What I meant was that most of the Brazilians that I have met where I live hate the cold and are not afraid to say so. The bear likes to take naps in the snow, as well as roll in it and go swimming, which is something that they cannot imagine in such weather.

    I know that I'm not a child molester, but the parents... they can be a bit nutty.


Postar um comentário

Postagens mais visitadas deste blog

Derretendo o Sistema

Resolving the "X" Problem

And if there was Black Metal bands 5.000 years ago?