您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“noarchive非歸檔模式下如何使用增量備份恢復數據庫”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“noarchive非歸檔模式下如何使用增量備份恢復數據庫”這篇文章吧。
實驗開始:
1) 撤銷數據庫archivelog模式
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL>
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
Database mounted.
SQL>
SQL> alter database noarchivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL>
SQL>
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 1
SQL>
2) 創建測試用表及數據
SQL> create table t(x int) tablespace users;
Table created.
SQL> insert into t values(1);
1 row created.
SQL> commit;
Commit complete.
3) 在noarchivelog模式下,0級備份(關庫mount下備份)
[oracle@wang ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 8 20:50:52 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: DBDB (DBID=3282897732)
RMAN> run{
shutdown immediate;
startup mount;
backup as backupset incremental level 0 database;
alter database open;
}
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
Starting backup at 08-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/DBdb/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/DBdb/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/DBdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 08-DEC-17
channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2q6sv_.bkp tag=TAG20171208T205150 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/DBdb/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: starting piece 1 at 08-DEC-17
channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2rxwz_.bkp tag=TAG20171208T205150 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-DEC-17
channel ORA_DISK_1: finished piece 1 at 08-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_ncsn0_TAG20171208T205150_f2o2sr2v_.bkp tag=TAG20171208T205150 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-DEC-17
database opened
RMAN>
4) 在noarchivelog模式下,1級備份(關庫mount下備份)
--先操作:
SQL> select * from t;
X
----------
1
SQL> insert into t values(2);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
X
----------
2
1
--開始備份:
RMAN>run{
shutdown immediate;
startup mount;
backup as backupset incremental level 1 database;
alter database open;
}
database closed
database dismounted
Oracle instance shut down
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
Starting backup at 09-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/DBdb/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/DBdb/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/DBdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-17
channel ORA_DISK_1: finished piece 1 at 09-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs0o5_.bkp tag=TAG20171209T005144 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/DBdb/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-17
channel ORA_DISK_1: finished piece 1 at 09-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs3p5_.bkp tag=TAG20171209T005144 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-17
channel ORA_DISK_1: finished piece 1 at 09-DEC-17
piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_ncsn1_TAG20171209T005144_f2ojs5v4_.bkp tag=TAG20171209T005144 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-17
database opened
RMAN>
6) 模擬故障,刪除所有控制文件、日志文件、數據文件、參數文件
SQL> conn / as sysdba
Connected.
SQL> select name from v$datafile;
NAME
-----------------------------------------------------------------------------------
/u01/app/oracle/oradata/DBdb/system01.dbf
/u01/app/oracle/oradata/DBdb/sysaux01.dbf
/u01/app/oracle/oradata/DBdb/undotbs01.dbf
/u01/app/oracle/oradata/DBdb/users01.dbf
/u01/app/oracle/oradata/DBdb/example01.dbf
/u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
6 rows selected.
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0/db_1/dbs/spfileDBdb.ora
--刪除:
[oracle@wang ~]$ cd /u01/app/oracle/oradata/DBdb/
[oracle@wang DBdb]$ ls -lrt
total 9887200
-rw-r----- 1 oracle oinstall 52429312 Dec 9 00:51 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Dec 9 00:51 redo03.log
-rw-r----- 1 oracle oinstall 3207340032 Dec 9 00:51 users01.dbf
-rw-r----- 1 oracle oinstall 355213312 Dec 9 00:51 example01.dbf
-rw-r----- 1 oracle oinstall 20979712 Dec 9 00:51 temp01.dbf
-rw-r----- 1 oracle oinstall 2710577152 Dec 9 01:51 undotbs01.dbf
-rw-r----- 1 oracle oinstall 744497152 Dec 9 01:54 sysaux01.dbf
-rw-r----- 1 oracle oinstall 2936020992 Dec 9 01:54 system01.dbf
-rw-r----- 1 oracle oinstall 52429312 Dec 9 01:58 redo01.log
-rw-r----- 1 oracle oinstall 10272768 Dec 9 01:58 control01.ctl
[oracle@wang DBdb]$ rm -rf *
[oracle@wang DBdb]$
[oracle@wang DBdb]$ cd /u01/app/oracle/fast_recovery_area/DBDB/newback/
[oracle@wang newback]$ ls
DBDB lost+found oradataback ts_xxf_01.dbf
[oracle@wang newback]$ rm -rf ts_xxf_01.dbf
[oracle@wang newback]$
[oracle@wang newback]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs/
[oracle@wang dbs]$ ls
hc_DBdb.dat init.ora initDBdb.ora lkDBDB orapwDBdb snapcf_DBdb.f spfileDBdb.ora
[oracle@wang dbs]$ mv spfileDBdb.ora spfileDBdb.ora.bak_2017
[oracle@wang dbs]$ ls
hc_DBdb.dat init.ora initDBdb.ora lkDBDB orapwDBdb snapcf_DBdb.f spfileDBdb.ora.bak_2017
[oracle@wang dbs]$
7) 執行恢復
--強制關機(日志里有報錯信息)
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
--啟動rman:
[oracle@wang ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Dec 9 02:04:33 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
--強制啟動到nomount模式
RMAN> startup nomount;
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 587205712 bytes
Database Buffers 243269632 bytes
Redo Buffers 2371584 bytes
--恢復參數文件,最好使用最后一次增量備份的備份介質:
RMAN> restore spfile from "/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_ncsn1_TAG20171209T005144_f2ojs5v4_.bkp";
Starting restore at 09-DEC-17
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_ncsn1_TAG20171209T005144_f2ojs5v4_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 09-DEC-17
RMAN>
--完成參數文件的恢復,利用恢復的參數文件啟動到nomount模式(也可以使用rman工具)
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
SQL>
SQL>
--恢復控制文件,注意:此處恢復控制文件,一定要使用最后一次增量備份的備份介質,否則會因為版本的問題導致恢復出現問題:
RMAN> restore controlfile from "/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_ncsn1_TAG20171209T005144_f2ojs5v4_.bkp";
Starting restore at 09-DEC-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/DBdb/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/DBdb/control02.ctl
Finished restore at 09-DEC-17
--控制文件恢復完成,數據庫啟動到mount模式
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
--執行全庫的還原
RMAN> restore database;
Starting restore at 09-DEC-17
Starting implicit crosscheck backup at 09-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 12 objects
Finished implicit crosscheck backup at 09-DEC-17
Starting implicit crosscheck copy at 09-DEC-17
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 09-DEC-17
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_ncsn1_TAG20171209T005144_f2ojs5v4_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/DBdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/DBdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/DBdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2q6sv_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2q6sv_.bkp tag=TAG20171208T205150
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/DBdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2rxwz_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_08/o1_mf_nnnd0_TAG20171208T205150_f2o2rxwz_.bkp tag=TAG20171208T205150
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 09-DEC-17
RMAN>
--由于非歸檔,且聯機重做日志丟失,所以使用noredo子句進行恢復
RMAN> recover database;
Starting recover at 09-DEC-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata/DBdb/system01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/DBdb/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/DBdb/users01.dbf
destination for restore of datafile 00006: /u01/app/oracle/fast_recovery_area/DBDB/newback/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs0o5_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs0o5_.bkp tag=TAG20171209T005144
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/app/oracle/oradata/DBdb/sysaux01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/DBdb/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs3p5_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_09/o1_mf_nnnd1_TAG20171209T005144_f2ojs3p5_.bkp tag=TAG20171209T005144
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
starting media recovery
RMAN-08187: WARNING: media recovery until SCN 3974526 complete
Finished recover at 09-DEC-17
RMAN>
RMAN> recover database noredo;
Starting recover at 09-DEC-17
using channel ORA_DISK_1
Finished recover at 09-DEC-17
RMAN>
--恢復完成,resetlogs方式打開數據庫,完成所有文件丟失的恢復
RMAN> alter database open resetlogs;
database opened
RMAN>
8) 驗證在測試前(增量備份前)插入的數據
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select * from t;
X
----------
2
1
SQL>
以上是“noarchive非歸檔模式下如何使用增量備份恢復數據庫”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。