Technological recipes that I've held to prepare some solutions DBA environment. (by Felipe Donoso Bastias)

4 Oct 2010

Oracle Standby: Log shipping rcp

www.felipedonoso.cl
felipe@felipedonoso.cl
RC6016
1NF3RNU5



If you need to make a Oracle Standby Database in Unix environment and you haven't the typical tools like ssh,ftp,nfs and/or Data Guard (Oracle) you can to use rcp and rsh for to transport the archived logs (and to use cksum or sum for to check the copied files).

First:

You should to have installed rsh-server, and then to configure the /etc/hosts.equiv

Second:

Execute periodically this script for to copy archived redolog files:

#!/usr/bin/ksh
# ----------------------------------------------------------------------
# Autores : Felipe Donoso Bastias
#
#
# Version : 1.1
#
# Fecha de Creacion : 14-12-2007
#
# Objetivos : Copiar los archived logs al servidor secundario
#
# Modificado : 28-12-2007
# - Se agrega comprobacion de cheksum a los archivos traspasados
# - Se modifica el formato de salida de los archivos de log
#
# Observaciones : Se comprueba la integridad de cada archivo (Checksum) a través
# del utilitario cksum.
#
# ----------------------------------------------------------------------
listado_remoto=/opt/oracle/stby/listado_remoto.txt
listado_local=/opt/oracle/stby/listado_local.txt
arch_des=
/u02/oradata/felipe
log=/opt/oracle/stby/log_shipping.log
log_hist=/opt/oracle/stby/log_shipping_hist.log
remote_host=felipe_prod
local_host=felipe_stby
rsh $remote_host ls $
arch_des/\*.arc > $listado_remoto
ls $
arch_des/*.arc > $listado_local
lista_archivos=$(sdiff -s $listado_remoto $listado_local | grep \< | awk ' { $2=R; print}') print "+----------------------------------------------------------------+" > $log
print "| Ejecucion de proceso copiado de archive |" >> $log
print "+----------------------------------------------------------------+" >> $log
print "******************************************************************" >> $log
echo "Lista de Archivos a Copiar: ">> $log
echo $lista_archivos >> $log
print "Inicio Copia de archived logs: "$(date) >> $log
for foo in $lista_archivos;do
rcp $remote_host:$foo $arch_des
cksum_local=$(cksum $foo | awk '{print $1}')
cksum_remoto=$(rsh $remote_host cksum $foo | awk '{print $1}')
#Aqui se hace una comprobacion del archivo recien copiado
keeplooping=1

while [[ $keeplooping -eq 1 ]] ; do
if [[ "$cksum_local" = "$cksum_remoto" ]] ; then
#el archived fue bien copiado
keeplooping=0
fi
if [[ "$cksum_local" != "$cksum_remoto" ]] ; then
echo "CKSUM local : $cksum_local" >> $log
echo "CKSUM remoto: $cksum_remoto" >> $log
echo "Hay que realizar la copia de nuevo de $foo" >> $log
sleep 20
rcp $remote_host:$foo $arch_des
cksum_local=$(cksum $foo | awk '{print $1}')
cksum_remoto=$(rsh $remote_host cksum $foo | awk '{print $1}')
fi
done
done
print "Fin Copia de archived logs: "$(date) >> $log
echo "Lista de Archivo no copiados: ">> $log
rsh $remote_host ls
$arch_des/\*.arc > $listado_remoto
ls
$arch_des/*.arc > $listado_local
lista_archivos=$(sdiff -s $listado_remoto $listado_local | grep \< | awk ' { $2=R; print}') echo $lista_archivos >> $log
print "+----------------------------------------------------------------+" >> $log
print "| Fin de Ejecucion de proceso |" >> $log
print "+----------------------------------------------------------------+" >> $log
print " " >> $log
print " " >> $log
print " " >> $log
print " " >> $log
cat $log >> $log_hist


Its very easy, sorry for my very BAD english.
PD: I executed this in environment ORacle 7.3 on Solaris 6
Greetings for all, in special for my Sindy friend. Felipe



Share:

Copyright © DBA TIPS | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com | Free Blogger Templates