Monday, November 30, 2009

Perform Export and Import Parallely

This helped me in saving space in some of activities and also in cases to do parallel export and import.

Scenario 1 :
You were asked to import a schema of your production server into your test server for some purpose. You are expecting that the export will take 5 hours and again the import will take quite more than that. In this case, you can use this option which will save your time in exporting and shipping the file to the other server.By doing this we will be able to export and import parallel on the same box.

1. In your test server, add the production database tnsnames to your tnsnames.ora
2. Create a unix pipe

mknod pipe name -p

ex : mknod ram_pipe -p

3. Start your export :
exp system/password@prod file=ram_pipe owner=erpds statistics=none log=/u01/export.log &

Remember to use & at the end to start the export in back groud and You be able to notice from the logfile whtr the pipe broken due to some errors in the export commands or the export is progressing...!!

4. Now from the same terminal start the import..!!

imp system/XXXXX@testserver file=ram_pipe fromuser=erpds touser=testds log=/u01/import.log &

Simple..!! You will notice one job wil be exporting and other will be importing...!!

Friday, October 23, 2009

Oracle 10g Logminer Example

Oracle 10g Logminer

To find out what Oracle is writing to the redo log files called LogMiner. The redo log files store all the data needed to perform a database recovery and record all changes (INSERT, UPDATE and DELETE) made to the database.

Below are the steps how to setup and mine a archive log :

1. Make sure you get the list of archives generated for the day using the below commnand. From the below output identify the archivelogs you are going to mine using logminer..

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

select thread#, sequence#, completion_time from v$archived_log order by completion_time desc;

2. Now Build a Logminer dictionary , make sure you have the follwoing folder available and your unix account have acces to it :

execute dbms_logmnr_d.build('dictionary.ora','/d01/oracle');

3. Copy all the archivelog to a path and register all the logs as show below :

execute dbms_logmnr.add_logfile('/d02/archivelogs/backup/arch/8045.arc',dbms_logmnr.addfile);

execute dbms_logmnr.add_logfile('/d02/archivelogs/backup/arch/8046.arc',dbms_logmnr.addfile);

execute dbms_logmnr.add_logfile('/d02/archivelogs/backup/arch/8047.arc',dbms_logmnr.addfile);

4. Now from the below view , make sure you have all the registered logs available for mining.

select log_id, filename from v$logmnr_logs;

5.Using the below view's find the first scn and high scn to mine from the registered logs.

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

select low_time,high_time,low_scn,next_scn from v$logmnr_logs;

6.From the above out gather the details and add it to the below logminer session :

execute dbms_logmnr.start_logmnr(dictfilename =>'/d01/oracle/dictionary.ora',starttime => to_date('2008-04-21 10:00:14', 'yyyy-mm-dd hh24:mi:ss'), endtime => to_date('2008-04-21 12:11:07', 'yyyy-mm-dd hh24:mi:ss'));

7. As v$logmnr_contents is a temporary view, once you disconnect your session , you won't be able to see the content, so make sure you create a table of all the contents of the view.

Note : If you mine a bunch of logs , create table will take more time to get created.

create table logmnr_table_1 as select * from v$logmnr_contents;