noarchive非歸檔模式下如何使用增量備份恢復(fù)數(shù)據(jù)庫(kù)

這篇文章主要為大家展示了“noarchive非歸檔模式下如何使用增量備份恢復(fù)數(shù)據(jù)庫(kù)”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“noarchive非歸檔模式下如何使用增量備份恢復(fù)數(shù)據(jù)庫(kù)”這篇文章吧。

網(wǎng)站設(shè)計(jì)制作過程拒絕使用模板建站;使用PHP+MYSQL原生開發(fā)可交付網(wǎng)站源代碼;符合網(wǎng)站優(yōu)化排名的后臺(tái)管理系統(tǒng);網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)收費(fèi)合理;免費(fèi)進(jìn)行網(wǎng)站備案等企業(yè)網(wǎng)站建設(shè)一條龍服務(wù).我們是一家持續(xù)穩(wěn)定運(yùn)營(yíng)了十年的創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司。

實(shí)驗(yàn)開始:

1)    撤銷數(shù)據(jù)庫(kù)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)    創(chuàng)建測(cè)試用表及數(shù)據(jù)
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級(jí)備份(關(guān)庫(kù)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級(jí)備份(關(guān)庫(kù)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)    模擬故障,刪除所有控制文件、日志文件、數(shù)據(jù)文件、參數(shù)文件
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)  執(zhí)行恢復(fù)
--強(qiáng)制關(guān)機(jī)(日志里有報(bào)錯(cuò)信息)
SQL> shutdown abort;
ORACLE instance shut down.
SQL>

--啟動(dòng)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)

--強(qiáng)制啟動(dòng)到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

--恢復(fù)參數(shù)文件,最好使用最后一次增量備份的備份介質(zhì):
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>

--完成參數(shù)文件的恢復(fù),利用恢復(fù)的參數(shù)文件啟動(dòng)到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> 


--恢復(fù)控制文件,注意:此處恢復(fù)控制文件,一定要使用最后一次增量備份的備份介質(zhì),否則會(huì)因?yàn)榘姹镜膯栴}導(dǎo)致恢復(fù)出現(xiàn)問題:
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


--控制文件恢復(fù)完成,數(shù)據(jù)庫(kù)啟動(dòng)到mount模式
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>

--執(zhí)行全庫(kù)的還原
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>

--由于非歸檔,且聯(lián)機(jī)重做日志丟失,所以使用noredo子句進(jìn)行恢復(fù)
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>


--恢復(fù)完成,resetlogs方式打開數(shù)據(jù)庫(kù),完成所有文件丟失的恢復(fù)
RMAN> alter database open resetlogs;

database opened

RMAN>


8) 驗(yàn)證在測(cè)試前(增量備份前)插入的數(shù)據(jù)
SQL> select status  from v$instance;

STATUS
------------
OPEN

SQL> select * from t;

         X
----------
         2
         1

SQL>

以上是“noarchive非歸檔模式下如何使用增量備份恢復(fù)數(shù)據(jù)庫(kù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站題目:noarchive非歸檔模式下如何使用增量備份恢復(fù)數(shù)據(jù)庫(kù)
網(wǎng)頁(yè)鏈接:http://bm7419.com/article48/jdsphp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版網(wǎng)站策劃、虛擬主機(jī)、微信小程序、營(yíng)銷型網(wǎng)站建設(shè)、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)