oracle adg 备份,Oracle Physical Dataguard环境使用RMAN备份和恢复
Oracle Physical Dataguard環(huán)境使用RMAN備份和恢復(fù)
由于Physical Dataguard使用的是塊恢復(fù)技術(shù)來保持和PRIMARY的一致性,因此可以在STANDBY
上進(jìn)行rman備份,從而減輕PRIMARY的壓力.當(dāng)PRIMARY出現(xiàn)數(shù)據(jù)庫故障時(shí),可以使用在STANDBY上
的備份來進(jìn)行恢復(fù).
先決條件:需要配置catalog.
在PRIMARY上以catalog方式連接,并且注冊數(shù)據(jù)庫
[oracle@PRIMARY admin]$ $ORACLE_HOME/bin/rman target / catalog
> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> configure db_unique_name CP connect identifier 'cp';
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'cp' CONNECT IDENTIFIER? 'cp';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN> configure db_unique_name cepstby connect identifier 'cepstby';
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'cepstby' CONNECT IDENTIFIER? 'cepstby';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
查看已注冊的數(shù)據(jù)庫信息,rman自動(dòng)識別數(shù)據(jù)庫角色等信息.
RMAN> list db_unique_name of database;
List of Databases
DB Key? DB Name? DB ID??????????? Database Role??? Db_unique_name
------- ------- ----------------- ---------------? ------------------
1?????? CP??? 2894644313?????? PRIMARY????????? CP
1?????? CP??? 2894644313?????? STANDBY????????? CEPSTBY
rman 連接到STANDBY的target進(jìn)行備份
[oracle@standby ~]$ $ORACLE_HOME/bin/rman target / catalog
Manager: Release 11.1.0.7.0 - Production on Sat Mar 26 10:52:00 2016
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
connected to target database: CP (DBID=2894644313, not open)
connected to recovery catalog database
在standby上執(zhí)行備份操作.
RMAN> run
2> {
3> allocate channel c2 device type disk;
4> backup as backupset database format '/home/oracle/%U';
5> release channel c2;
6> }
allocated channel: c2
channel c2: SID=1085 device type=DISK
Starting backup at 26-MAR-16
Starting implicit crosscheck backup at 26-MAR-16
Finished implicit crosscheck backup at 26-MAR-16
.............................
我們通過在主庫移動(dòng)文件來摸擬數(shù)據(jù)文件被破壞的情形
[oracle@primary]$ mv /u01/app/oracle/oradata/cp/users01.dbf /u01/app/oracle/oradata/cp/oldusers01.dbf
DONGDONGTANG> startup;
ORACLE instance started.
Total System Global Area 1135747072 bytes
Fixed Size????? 2158992 bytes
Variable Size??? 822087280 bytes
Database Buffers?? 301989888 bytes
Redo Buffers????? 9510912 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/cp/users01.dbf'
接下來我們要做的是從備庫上復(fù)制相關(guān)備份文件到主庫中
[oracle@standby ~]$ scp /home/oracle/0* 192.168.56.21:/home/oracle/bak
在主庫中對相關(guān)文件進(jìn)行catalog
[oracle@PRIMARY admin]$ $ORACLE_HOME/bin/rman target / catalog
Manager: Release 11.1.0.7.0 - Production on Sat Mar 26 10:56:56 2016
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
connected to target database: CP (DBID=2894644313, not open)
connected to recovery catalog database
RMAN> catalog start with '/home/oracle/bak';
searching for all files that match the pattern /home/oracle/bak
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/bak/09r1eku6_1_1
File Name: /home/oracle/bak/08r1ekse_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/bak/09r1eku6_1_1
File Name: /home/oracle/bak/08r1ekse_1_1
現(xiàn)在可以發(fā)現(xiàn)4號文件的相關(guān)備份信息
RMAN> list backup of datafile 4;
List of Backup Sets
===================
BS Key? Type LV Size?????? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
111???? Full??? 1.08G????? DISK??????? 00:00:53???? 26-MAR-16
BP Key: 176?? Status: AVAILABLE? Compressed: NO? Tag: TAG20160326T105302
PRIMARYece Name: /home/oracle/bak/08r1ekse_1_1
List of Datafiles in backup set 111
File LV Type Ckp SCN??? Ckp Time? Name
---- -- ---- ---------- --------- ----
4?????? Full 927757???? 26-MAR-16 /u01/app/oracle/oradata/cp/users01.dbf
恢復(fù)/u01/app/oracle/oradata/cp/users01.dbf文件
RMAN> run
{
allocate channel c1 device type disk;
restore datafile 4;
recover datafile 4;
release channel c1;
}2> 3> 4> 5> 6> 7>
allocated channel: c1
channel c1: SID=1090 device type=DISK
Starting restore at 26-MAR-16
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/cp/users01.dbf
channel c1: reading from backup PRIMARYece /home/oracle/bak/08r1ekse_1_1
channel c1: PRIMARYece handle=/home/oracle/bak/08r1ekse_1_1 tag=TAG20160326T105302
channel c1: restored backup PRIMARYece 1
channel c1: restore complete, elapsed time: 00:00:03
Finished restore at 26-MAR-16
Starting recover at 26-MAR-16
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 26-MAR-16
released channel: c1
再次嘗試打開數(shù)據(jù)庫.
....................
Variable Size??? 822087280 bytes
Database Buffers?? 301989888 bytes
Redo Buffers????? 9510912 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/cp/users01.dbf'
DONGDONGTANG> alter database open;
Database altered.
DONGDONGTANG> select name,status from v$datafile where file#=4;
NAME
--------------------------------------------------------------------------------
STATUS
-------
/u01/app/oracle/oradata/cp/users01.dbf
ONLINE
主數(shù)據(jù)庫已經(jīng)可以成功打開.
總結(jié)
以上是生活随笔為你收集整理的oracle adg 备份,Oracle Physical Dataguard环境使用RMAN备份和恢复的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 爬虫代码_Python 你
- 下一篇: python 数组赋值_pythonam