oracle怎样完全备份?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle怎样完全备份?相关的知识,希望对你有一定的参考价值。
参考技术A 可以热备份:\\x0d\\x0aSQL> alter database begin backup\\x0d\\x0a然后退出SQL,将Oracle软件和数据文件直接拷贝\\x0d\\x0a等都拷贝完了,再进sqlplus 执行:\\x0d\\x0aSQL>alter database end backup\\x0d\\x0a然后将begin时刻到end时刻产生的归档也拷贝出来,\\x0d\\x0a这就完成了全备\\x0d\\x0a\\x0d\\x0a如果你要在oracle下备份整个数据库:可以用expdp方便的进行\\x0d\\x0aexpdp sys/XXX dumpfile=XXXX.dmp directory=XXXX\\x0d\\x0a其中directory是在oracle下建立的文件夹对象名\\x0d\\x0a假如你没建立过\\x0d\\x0a那么首先执行create directory dpdata1 as \'d:\test\dump\';\\x0d\\x0a然后把expdp这样写directory=dpdata1Oracle RMAN 备份及不完全恢复(删除archievelog)
RMAN备份命令
backup Database format=‘/home/oracle/backup/bak_full_%U_%T‘ tag=‘bak_full‘;
|
备份完后插入测试数据
insert into zz values(2); commit;
insert into qq values(2); commit;
然后通过alter system switch logfile多切几次归档,切出多个归档文件
o1_mf_1_12_cpb2xhg8_.arc o1_mf_1_14_cpb36dbo_.arc
o1_mf_1_13_cpb35zgs_.arc o1_mf_1_15_cpb37ff2_.arc
删除12和14文件
[[email protected] 2016_06_18]$ rm o1_mf_1_12_cpb2xhg8_.arc
[[email protected] 2016_06_18]$ rm o1_mf_1_14_cpb36dbo_.arc
通过在RMAN中运行处理使得报错
run {
sql‘alter database datafile 6 offline‘;
restore datafile 6;
recover datafile 6;
sql‘alter database datafile 6 online‘;
}
错误为
RMAN> recover datafile 6; Starting recover at 18-JUN-16 starting media recovery archived log for thread 1 with sequence 13 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_13_cpb35zgs_.arc |
查看archieve目录,发现确实只有
o1_mf_1_13_cpb35zgs_.arc o1_mf_1_15_cpb37ff2_.arc
查看v$log,得到最后需要应用的日志文件应该是16
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 16 CURRENT
2 14 INACTIVE
3 15 INACTIVE
被还原的6号文件的scn为
SQL> select file#,change# from v$recover_file;
FILE# CHANGE#
---------- ----------
6 1080514
查看v$log_history得知需要从10号文件开始恢复
SQL> select sequence# from v$log_history where 1080514 between first_change# and next_change#-1;
SEQUENCE#
----------
10
RMAN> list backup of archivelog all;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
3 61.04M DISK 00:00:03 16-JUN-16
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20160616T165323
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2016_06_16/o1_mf_annnn_TAG20160616T165323_cp4t83nk_.bkp
List of Archived Logs in backup set 3
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 6 1022418 08-JUN-16 1033516 16-JUN-16
1 7 1033516 16-JUN-16 1047305 16-JUN-16
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4 61.05M DISK 00:00:02 16-JUN-16
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20160616T165445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2016_06_16/o1_mf_annnn_TAG20160616T165445_cp4tbogp_.bkp
List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 6 1022418 08-JUN-16 1033516 16-JUN-16
1 7 1033516 16-JUN-16 1047305 16-JUN-16
1 8 1047305 16-JUN-16 1047358 16-JUN-16
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 61.02M DISK 00:00:03 18-JUN-16
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: ARC_BACK
Piece Name: /home/oracle/backup/arch_07r8fcti_1_1_20160618
List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 9 1047358 16-JUN-16 1071119 16-JUN-16
1 10 1071119 16-JUN-16 1080684 18-JUN-16
1 11 1080684 18-JUN-16 1080714 18-JUN-16
备份级里面有6,7,8,9,10,11,6号文件test01.dbf需要的是从10号archivelog开始,但需要恢复到16号文件,目前缺少12,14文件.
查找一下12-14文件的位置,进行确认.
RMAN> list archivelog low sequence 12 high sequence 14
2> ;
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
7 1 12 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_12_cpb2xhg8_.arc
8 1 13 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_13_cpb35zgs_.arc
9 1 14 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_14_cpb36dbo_.arc
只能不完全恢复到12
shutdown abort;
starup force mount;
RMAN> run { executing command: SET until clause Starting restore at 18-JUN-16 channel ORA_DISK_1: starting datafile backup set restore RMAN> run { executing command: SET until clause Starting recover at 18-JUN-16 starting media recovery channel ORA_DISK_1: starting archived log restore to default destination RMAN> alter database open resetlogs; database opened |
用scott/tiger登录后查看,发现插入的数据不在了.
以上是关于oracle怎样完全备份?的主要内容,如果未能解决你的问题,请参考以下文章