Saturday, August 26, 2023

How To Use DataPump Export (EXPDP) To Export From Physical Standby Database

This document describes how to successfully execute DataPump Export to export data from a Physical Standby database.

Taking dump file from a large primary database for some reason can be a challenge for DBA.

Although existing features such as parallelism can be speed up process but this load cannot be tolerated on the production database.

So once solution is taking dump on standby.


SOLUTION

It's important to know that Data Pump Export (expdp) cannot be executed directly on the Physical Standby database. This is due to the fact that Data Pump Export needs to create and maintain a Master Table which requires that a database would be open in "READ WRITE" mode. Therefore it is necessary to connect from a "non-Standby" database (which will maintain the Master Table) to the Physical Standby database using parameter NETWORK_LINK.


The NETWORK_LINK parameter initiates an export by using a valid database link. This means that the system to which the expdp client is connected contacts the Physical Standby database referenced by the source_database_link, retrieves data from it, and writes the data to a dump file set back on the connected system.


The Physical Standby database must be opened in "READ ONLY" mode.


Steps to execute to export from Physical Standby Database


On Physical Standby Database:

-- Connect to Physical Standby database and check its status


SQL> select instance_name, status from v$instance;


INSTANCE_NAME    STATUS

---------------- ------------

<STDBY_DB_NAME>  MOUNTED


-- Cancel managed recovery and open database in "READ ONLY" mode.

SQL> alter database recover managed standby database cancel;

SQL> alter database open read only;


-- Verify database status

SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS

---------------- ------------

<STDBY_DB_NAME>  OPEN


SQL> select open_mode from v$database;


OPEN_MODE

--------------------

READ ONLY


On "Non Standby" Database (another database as a proxy, this can be a light with minimal resource and use only for this way.


-- create DB Link, Oracle Directory and test it


SQL> create database link expdp_primary connect to system identified by <password> using ‘standby_database’;


SQL> select db_unique_name from v$database;


SQL> select db_unique_name from v$database@expdp_primary;


SQL> create directory datapump as ‘/tmp’;


-- Use NETWORK_LINK to database link above to connect to the Physical Standby database:


$expdp system/<password> directory=datapump network_link=expdp_primary full=y dumpfile=standby_database.dmp logfile=standby_database.log


♨️Also another option is convert standby database to snapshot and take export pump and finally comver to physical standby.

This can done by a manual script under a job.


*********************************

Typical Errors when exporting from Physical Standby databases

ISSUE:

UDE-01033: operation generated ORACLE error 1033

ORA-01033: ORACLE initialization or shutdown in progress

UDE-00003: all allowable logon attempts failed

CAUSE:

•No NETWORK_LINK parameter was used to connect to Physical Standby database 
- AND -

•Physical Standby runs in "MOUNTED" state


SOLUTION:


•Use NETWORK_LINK={database link} to connect Physical Standby database.


•Make sure that a valid database link exists to connect to Standby database.


•Run Physical Standby database in "READ ONLY" mode.


ISSUE:

ORA-39006: internal error

ORA-39065: unexpected master process exception in DISPATCH

ORA-01033: ORACLE initialization or shutdown in progress

ORA-02063: preceding line from {database link}


ORA-39097: Data Pump job encountered unexpected error -1033


CAUSE:

•Physical Standby runs in "MOUNTED" state

SOLUTION:

•Connect to Physical Standby database to open the database in "READ ONLY MODE".


Some recommendations for taking dump on large databases:


  • Use standby to prevent load affected on primary database.
  • Use parallelism to use more process and minimize time.
  • Take dump as data_only first 
  •     Take all indexes as a sqlfile by import
  •     Run DDL commands from multiple sessions at the same time to index creation 
  • Exclude statistsics from export if possible
  • For partitions table use merge option if possible 
  • Optimize  STREAMS_POOL_SIZE param
  • Set AQ_TM_PROCESSES>0 if possible
  • On Rac PARALLEL_FORCE_LOCAL=TRUE


Regards,

Alireza Kamrani

No comments:

Post a Comment

Oracle Standby troubleshooting

 đź’˘ Oracle Standby troubleshootingđź’˘   Written by: Alireza Kamrani In this post I represented an essential methods to evaluating , configuri...