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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
#!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.