先决条件:
我们都知道数据泵(Data Pump)不能直接在物理备用数据库上执行,这由于执行数据泵时数据泵会创建和维护一个表,还要求数据库必须是READ WRITE模式,因此我们必须从其他数据库使用NETWORK_LINK备份物理备用数据库。
NETWORK_LINK参数启动主要通过使用一个有效的数据库链接。当expdp启动连接后由source_database_link引用物理备用数据库,检索数据,并将数据写入到一个转储文件集。
物理备用数据库必须是“READ ONLY”模式。
执行备份:
物理备用数据库的相关操作:
点击(此处)折叠或打开
- -- Connect to Physical Standby database and check its status
- SQL> select instance_name, status from v$instance;
- INSTANCE_NAME STATUS
- ---------------- ------------
- PHYSTBY 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
- ---------------- ------------
- PHYSTBY OPEN
- SQL> select open_mode from v$database;
- OPEN_MODE
- --------------------
- READ ONLY
其他数据库(READ WRITE)操作:
点击(此处)折叠或打开
- -- 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