Sunday, July 13, 2014

Consistent Expdp !

During Export (exdpd) a database in oracle10g and oracle11g , if any DML is executed then it will added with the export jobs .

For removing this problem and also taking a CONSISTENT backup we can use below script :

"  expdp system/sys123 directory=test_dir dumpfile=scott.dmp schemas=scott flashback_time=SYSTIMESTAMP"

---


Tuesday, July 1, 2014

Flashback in a Data Guard Environment

01) Flashback on PRIMARY database :

$ sqlplus "/ as sysdba"

SQL> alter system set cluster_database=false scope=spfile sid='pbldb1'; //recommended

$ srvctl stop database -d pbldb

$ sqlplus "/ as sysdba"

SQL> startup mount

$ rman target /

RMAN> FLASHBACK DATABASE TO RESTORE POINT BEFORE_EOD;

RMAN> ALTER DATABASE OPEN RESETLOGS;

SQL> alter system set cluster_database=true scope=spfile sid='pbldb1';

SQL> shutdown immediate

$ srvctl start database -d pbldb

$ srvctl start service -d pbldb





02) Using Flashback in STANDBY database 

Link : http://uhesse.com/2010/08/06/using-flashback-in-a-data-guard-environment/

Problem : Using Flashback , we restored database successfully on primary site . But the dataguard environment is not sync cause of resetlog command . 

Here , we enable flashback on dataguard site , also .


Solution :


0) SQL> select database_role,flashback_on from v$database;

DATABASE_ROLE    FLASHBACK_ON
---------------- ------------------
PHYSICAL STANDBY YES



1) From Primary :

  select resetlogs_change# from v$database;

 9421383974

In Standby Database :

1) Shutdown and start as mount :

[oracle@droda1 ~]$ echo $ORACLE_SID
pbldg
[oracle@droda1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 2 01:21:58 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
*
ERROR at line 1:
ORA-16136: Managed Standby Recovery not active


SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 3.4206E+10 bytes
Fixed Size                  2245480 bytes
Variable Size            1.7583E+10 bytes
Database Buffers         1.6576E+10 bytes
Redo Buffers               45674496 bytes
Database mounted.
SQL> 


2) Run the Flashback Command :

  flashback database to scn  9421383971;   //  (Make -3 from primary SCN .)


3) Finally Run the Apply Process :

  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

===

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +RECO
Oldest online log sequence     5
Next log sequence to archive   0
Current log sequence           7

Consistent Backup During Expdp

During Export (exdpd) a database in oracle10g and oracle11g , if any DML is executed then it will added with the export jobs .

For removing this problem and also taking a CONSISTENT backup we can use below script :

"  expdp system/sys123 directory=test_dir dumpfile=scott.dmp schemas=scott flashback_time=SYSTIMESTAMP"