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:
INFOMRIX:
#!/bin/ksh
start() {
LOGFILE=/opt/informix/log/startupdb.log
echo "`date`: iniciando banco informix">>$LOGFILE 2>&1
for i in `ls -1 /opt/informix/etc/onconfig.*
cut -d. -f2
grep -v std `
do
ONCONFIG=onconfig.$i export ONCONFIG;
INFORMIXSERVER=$i; export INFORMIXSERVER;
export INFORMIXDIR=/opt/informix
$INFORMIXDIR/bin/oninit>/dev/null 2>&1
STATUS=`$INFORMIXDIR/bin/onstat -
cut -c 1-48`
if [ "$STATUS@" = "shared memory not initialized for INFORMIXSERVER@" ]; then
echo -e "Informix " $i "\t" OFFLINE>>$LOGFILE 2>&1
else
echo -e "Informix 10" $i "\t" `$INFORMIXDIR/bin/onstat -
awk -F "--" '{ print $2,$4,$3 }'`>>$LOGFILE 2>&1
fi
done
}

ORACLE:
# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.2.0/db_1
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
else
LOG=$ORACLE_HOME_LISTNER/listener.log

# 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`
else
echo "Failed to auto-start Oracle Net Listene using $ORACLE_HOME_LISTNER/bin/tnslsnr"
fi
fi

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


startinst() {
# Called programs use same database ID
export ORACLE_SID

# Put $ORACLE_HOME/bin into PATH and export.
PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH
# add for bug # 652997
LD_LIBRARY_PATH=${SAVE_LLP}:${ORACLE_HOME}/lib ; export LD_LIBRARY_PATH
PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
SPFILE1=${ORACLE_HOME}/dbs/spfile.ora

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

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

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.

Comentários

  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.

    ResponderExcluir

Postar um comentário

Postagens mais visitadas deste blog

CPF pra Estelionatário Ver!

Data Protector Cannot connect to the SCM (Service Control Manager)

Puff Power Daneryes