我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

noarchive非归档模式下如何使用增量备份恢复数据库

这篇文章主要为大家展示了“noarchive非归档模式下如何使用增量备份恢复数据库”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“noarchive非归档模式下如何使用增量备份恢复数据库”这篇文章吧。

网站设计制作过程拒绝使用模板建站;使用PHP+MYSQL原生开发可交付网站源代码;符合网站优化排名的后台管理系统;网站设计制作、网站设计收费合理;免费进行网站备案等企业网站建设一条龙服务.我们是一家持续稳定运营了十年的创新互联网站建设公司。

实验开始:

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非归档模式下如何使用增量备份恢复数据库”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


当前标题:noarchive非归档模式下如何使用增量备份恢复数据库
链接URL:http://mswzjz.cn/article/jdsphp.html

其他资讯