Archive for the ‘Uncategorized’ Category

Dataguard check script for Real Application Clusters (MAA)

Friday, December 31st, 2010

Two years after my posts:
Quick Oracle Dataguard check script and More about Dataguard and how to check it I faced a whole new Dataguard between two Oracle Real Application Clusters, aka Oracle Maximum Availability Architecture (MAA).

This enviromnent is relying on Windows OS. Don’t know how this could be called “availability” but here we are. I revisited my scripts in a quick and very dirty way. Please consider that I did copy and paste to check the alignment once per thread, but it should be improved with some kind of iteration to check each thread in a more structured fashion.

#!D:\oracle\product\10.2.0\db_1\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.exe -w
use DBI;
use DBD::Oracle qw(:ora_session_modes);
# DB connection #
my $prod  = "prod";
my $stby = "stby";
my $prodh;
unless ($prodh = DBI->connect('dbi:Oracle:'.$prod, 
    'sys', 'strongpwd', 
    {PrintError=>0, AutoCommit => 0,
    ora_session_mode => ORA_SYSDBA}))  {
print "Error connecting to DB: $DBI::errstr\n";
exit(1);
}
$prodh->{RaiseError}=1;
 
my $stbyh;
unless ($stbyh = DBI->connect('dbi:Oracle:'.$stby,
    'sys', 'strongpwd',
    {PrintError=>0, AutoCommit => 0,
    ora_session_mode => ORA_SYSDBA}))  {
print "Error connecting to DB: $DBI::errstr\n";
$prodh->disconnect;
exit(1);
}
$stbyh->{RaiseError}=1;
 
my $sth;
### query stdby MRP0
$sth = $stbyh->prepare( <<EOSQL );
select thread#, SEQUENCE#, BLOCK#
    from gv\$managed_standby 
    where process='MRP0'
EOSQL
$sth->execute();
my ($mrpthread, $mrpsequence, $mrpblock) = $sth->fetchrow_array();
$sth->finish();
 
### query stdby RFS
$sth = $stbyh->prepare( <<EOSQL );
select thread#, SEQUENCE#, BLOCK#
    from gv\$managed_standby 
    where process='RFS' and client_process='LGWR' order by thread#
EOSQL
$sth->execute();
my ($rfsthread1, $rfssequence1, $rfsblock1) = $sth->fetchrow_array();
my ($rfsthread2, $rfssequence2, $rfsblock2) = $sth->fetchrow_array();
$sth->finish();
 
### query prod
$sth = $prodh->prepare( <<EOSQL );
select thread#, SEQUENCE#, BLOCK#
    from gv\$managed_standby
    where process='LNS' order by thread#
EOSQL
$sth->execute();
my ($pthread1, $psequence1, $pblock1) = $sth->fetchrow_array();
my ($pthread2, $psequence2, $pblock2) = $sth->fetchrow_array();
$sth->finish();
 
 
printf ("ENVIRONM  Thread Sequence   Block\n");
printf ("--------- ------ ---------- ----------\n");
printf ("PROD     LNS1  1 %10d %10d\n", $psequence1, $pblock1);
printf ("STANDBY  RFS1  1 %10d %10d\n", $rfssequence1, $rfsblock1);
printf ("PROD     LSN2  2 %10d %10d\n", $psequence2, $pblock2);
printf ("STANDBY  RFS2  2 %10d %10d\n", $rfssequence2, $rfsblock2);
printf ("STANDBY  MRP0  %d %10d %10d\n", $mrpthread, $mrpsequence, $mrpblock);
 
my $psequence;
my $pblock;
if ( $mrpthread == 1 ) {
$psequence=$psequence1;
$pblock=$pblock1;
} else {
$psequence=$psequence2;
$pblock=$pblock2;
}
 
$sth = $stbyh->prepare( <<EOSQL );
select nvl(sum(blocks),0)
+ $pblock - $mrpblock as BLOCK_GAP
from gv\$archived_log
where thread#=$mrpthread and sequence#
between $mrpsequence and $psequence
EOSQL
$sth->execute();
my ($mrpblockgap) = $sth->fetchrow_array();
$sth->finish();
 
$sth = $stbyh->prepare( <<EOSQL );
select nvl(sum(blocks),0)
+ $pblock1 - $rfsblock1 as BLOCK_GAP
from gv\$archived_log
where thread#=1 and sequence#
between $rfssequence1 and $psequence1
EOSQL
$sth->execute();
my ($rfsblockgap1) = $sth->fetchrow_array();
$sth->finish();
 
$sth = $stbyh->prepare( <<EOSQL );
select nvl(sum(blocks),0)
+ $pblock2 - $rfsblock2 as BLOCK_GAP
from gv\$archived_log
where thread#=2 and sequence#
between $rfssequence2 and $psequence2
EOSQL
$sth->execute();
my ($rfsblockgap2) = $sth->fetchrow_array();
$sth->finish();
printf ("\n\n%-10d blocks gap in TRANSMISSION\n", $rfsblockgap1+$rfsblockgap2);
printf ("%-10d blocks gap in APPLY (MRP0)\n", $mrpblockgap);
 
$stbyh->disconnect;
$prodh->disconnect;

Please foreward me every improvement you implement over my code: it would be nice to post it here.

Just for laughs: Mysql and Windows…

Thursday, August 27th, 2009

Mysql for Windows?? Maybe.
Windows for Mysql?? NO WAY!
:-)

Clustering the RMAN catalog on a RAC environment

Tuesday, January 13th, 2009

You have your brand new RAC deployed on a cluster and you want to manage your backups through a recovery catalog.
Suppose you don’t have a dedicate server to host your catalog, perhaps you wouldn’t configure your catalog as a RAC database: so why don’t you use Clusterware to configure your catalog as a single instance in cold failover?

OTN has a very nice whitepaper describing how to protect a single instance database. This can be nicely applied on 10g, 10gR2 or 11g: Using Oracle Clusterware to Protect A Single Instance Oracle Database 11g.

Clusterware is appealing also for traditional cold failover clusters. Licensing allows you to use Clusterware as far as you protect Oracle software or 3rd party software that use Oracle as database backend.