Applying Datafile resize in logical standby

Well,
with the record_unsupported_operations-true . I was able to capture the commands that oracle skipped. using that info i was able to write a simple piece of code to use that information to get
Alter database datafile commands executed on my logical standby database which in this case has exactly the same structure as my primary.

/* Program Name : Datafile Alter command capture
Author : Fuad Arshad
Purpose : To capture alter database datafile commands from dba_logstdby_events
and execute on logical standby
Prerequisites : dbms_logstdby.apply_set(‘RECORD_UNSUPPORTED_OPERATIONS’,'TRUE’);
dbms_LOGSTDBY.apply_set(‘MAX_EVENTS’,'a value of your choosing based on events ‘);
Licensed : Creative Commons.
*/

set serveroutput on
declare
p_errbuf varchar2(500);
p_retcode number(1);
cursor dba_events is
SELECT to_char(event) event1 FROM dba_logstdby_events WHERE status_code=’16226′and event_timestamp>systimestamp-1
and event like ‘ALTER DATABASE DATAFILE%’;
begin
for
dbevent in dba_events LOOP
DBMS_OUTPUT.PUT_LINE(‘Statement : ‘ || dbevent.event1 );
execute immediate dbevent.event1;
end LOOP;
EXCEPTION
when no_data_found then
null;
when others then
p_errbuf := sqlerrm;
p_retcode := 1;
DBMS_OUTPUT.PUT_LINE(‘Error : ‘ || p_errbuf|| ‘Error Code’ || p_retcode );
end;

This is a very simple way of making sure all the datafiles on the standby look exactly the same as the Primary. I’m sure there are many other ways to do this and if there are please share how u would have taken care of the alter database datafile issue. Comments and improvements as well as ideas are always welcome.

DBMS_LOGSTDBY and recording unsupported operations

DBMS_LOGSTDBY is the heart and soul of the logical standby management infrastructure . While trying to figure out how to get my alter database datafile operations . i bumped in a record unsupported operations in $logstdby_stats . There seems to be no mention in the documentation and no reference to this parameter being set anywhere . If you to set it though

>exec dbms_logstdby.apply_set(‘RECORD_UNSUPPORTED_OPERATIONS’,'TRUE’);

This will help capture the unsupported operations as the ORA-16226 operations. I am planning on then reading the clob and re executing the statements onto the logical standy. I still have to figure that part out but stay tuned ….

Beware of Recycle bin objects and drop table triggers

Just this morning i was asked to investigate why a simple insert was failing . The error the users were getting was

INSERT INTO “ABC” ( “ABC1″, “ABC2″, “ABC3″, “ABC4″ ) VALUES
( ‘ABC1′, 1234, ‘N’, ‘NN’ )

ORA-20009: Cannot drop table Drop Not Authorized
ORA-06512: at line 14)

While we knew this was a error generated by our custom trigger that we have implemented for securing our databases from malicious application table drops. We were a little puzzled as to why a simple insert would invoke our table drop prevention trigger.

After a little dose of 10046 this became apparent to us

PARSING IN CURSOR #3 len=62 dep=1 uid=0 oct=12 lid=0 This was going on
tim=48271684044651 hv=0 ad=’1045a248′
drop table “APP_NAME”.”BIN$YQPns5G0IL7gQzwEPI0gvg==$0″ purge
END OF STMT
PARSE #3:c=0,e=450,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=48271684044648

The row insert required the table to extend to a segment that was previously owned by a dropped object . To clear space Oracle actually issues a drop table purge when it needs to extend an existing object.

We are now modifying our security trigger to exclude BIN$ objects .

Edait: after a question in the comments i have now validated that an implicit commit will happen if an insert and purge recycle bin are executed . i am going to test creating an outof space and reuse situation to see if that would cause an implicit commit too. Thanks to Chen Shapiro to point ing out the implicit commits in DDL statements.

Update: Oracle manages the space management operation outside of a transaction and a commit will not happen to the operations that have happened in the outlying transaction. it seems purge dba_recyclebin and an internal drop table purge for space management by oracle are handled differently

Posted in oracle. 3 Comments »

Oracle Dataguard Broker and CFC

During a recent implementation of Dataguard on  a Active/Passive Cluster. I started receiving weird errors using the installation/configuration phase. The Grid control add standby wizard which is something i like to use for smaller databases started out the the process  but would never complete it leaving the primary and the standby in a weird state.
Errors like

DMON: cannot open configuration file “/usr/local/oracle/product/10.2/dbs/dr2test.dat”
  ORA-27037: unable to obtain file status

 error = ORA-16572
DG 2009-01-15-08:26:48        0 2 0 NSV0: Failed to connect to remote database p
rkmdb1. Error is ORA-12541
DG 2009-01-15-08:26:48        0 2 0 NSV0: Failed to send message to site prkmdb1
. Error code is ORA-12541.
 DMON: test unable to contact primary for DRC version check
  DMON: status ORA-12541:
~

The problem is that the dataguard broker cannot traverse through a  virtual  node name which is used in a Active/Passive or CFC  configuration,
According to Metalink Note # 413696.1 which is very appropriately named “Data Guard Broker does not support Cold Failover Clusters” 
“The Data Guard Broker does not support Cold Failover Clusters (also called Active/Passive clusters) in any version up to and including Oracle Database 10g Release 2. You cannot use the Broker nor Enterprise Manager, you have to create and manage your standby configuration using SQLPlus”

The support for  CFC’s come in a limited fashion in Oracle 11gR1 only if Oracle clusterware is used.

This means that a dataguard standby has to be manually created and configured and all instances have to be monitored individually.

,

Happy new year 2009

Happy New Year 2009 to everyone. Hopefully this new year gives me more time to write about the things i do and the things i like to do.

DataGuard Setup (Physical)

Recently i have had the opportunity to finally plunge into the world of Dataguard and i was pleasantly surprised by the ease of setup and use for Dataguard. The steps below were used to create a physical standby database. The setup was Oracle 10.2.0.4 on AIX .
These steps do not account for a FAL server at this point.
Prereqs
1. Primary database has to be in archivelog mode
2. Standby redo log files are beneficial and even though not required for physical standby should be created.
3. log_archive_dest_2 needs to be configured which log_archive_dest_state_2 set to defer till the standby is up.

Steps.

1. create a backup of the primary database either on disk or tape.

run {
backup database plus archivelog;
backup current controlfile for standby ; —– important step
}

2. create an init.ora file and move it to the standby host.
3. modify the init.ora to include a db_unique_name different from primary
4. add db_dile_name_convert and log_file_name_convert if the filesystem structure is not going to be identical to the primary.
5. restore the database on the standby host
On the Standby Host.

rman target abc/abc@def
conn auxiliary /
run {
startup nomount;
duplicate target database for standby dorecover;
}

6. Ensure tnsnames.ora is current and tested ont he primary and standby hosts.
7. Start shipping redo by changing log_archive_dest_state_2=enable on the primary.

You have a physical standby up and running. I’ll post some tests and monitoring scripts as well as conversion to a logical standby in future posts

Books of Interest (Rman)

I thought i should make a quick blog post of some books that have helped me alot as quick reference and as an alternative to the manuals as a fast grab and look books

I’ll start with Books on Rman in this first post on books .
Oracle RMAN Pocket Reference is a very good handy guide to rman syntax and commands though it seems it has not seen an update in a while.

Robert Freeman has a wonderful set of books for Rman in both the 9 and 10 flavors. I keep both at hand for help supporting my 9 and 10 Databases. They have helped me tremendously in supporting backups and restores for my databases
9i Rman Backup And Recovery
10g RMAN Backup & Recovery

I would definitely recommend these as must on hand books for any recoveries or backup help.

RIP @carlback

The tweets have been pouring in about Carl Backstrom a prominent Apex evangalist and Product manager at Oracle that died in a car crash yesterday. Jow Kallman has some detail about the contact with the family and about getting a trust opened for Carl’s Daughter here .
I had the oppuruntunity to meet Carl at Open world this year and had been following and learning about APex thru Carl for a while a great loss indeed.
RIP @carlback

Soem info about carl backstrom can be found at this blog http://carlback.blogspot.com

OOW 2008 Final thoughts

I had the opportunity to attend Oracle Openworld this year and i was blown away by all the people and the content presented at OOW this year.
Barring a few technical mishaps like Schedule Builder being down for a about a day it seemed that the event was very well planned and The teams behind the event should get a big kudos for managing and arranging such a huge event as well as they did.
There was a lot of knowledge shared during the event at the presentations as well as the lounges. I truly believe for me the lounges were the highlight of the event. Meeting a lot of fellow Tweeters, Bloggers and Oracle Ace’s was simply fabulous. There was a lot of knowledge transfer and knowledge building during this event.
The unconference events were a nice way to sit back , relax and understand some nice technical content.
The Oracle Fusion Middleware lounge were doing some nice video post cards Which can be seen here .
Some pictures of the event can be found here and at flickr here.

Some of the important announcement included Exadata appliance and the Oracle Database machine which marked Oracle’s move into the hardware arena in partnership with HP. Oracle Beehive a successor to Oracle Collaboration suite was also announced at the event.

Oracle OpenWorld Live Post for Sep 24