RMANシングルインスタンスインクリメンタルバックアップおよびリカバリテスト
83453 ワード
RMANシングルインスタンスインクリメンタルバックアップおよびリカバリテスト
一、テストシーン
二、テスト手順
一、表挿入テストデータの作成SQL> create table test (id number);
Table created.
SQL> insert into test values(1);
1 row created.
SQL> insert into test values(2);
1 row created.
SQL> insert into test values(3);
1 row created.
SQL> insert into test values(4);
1 row created.
SQL> insert into test values(5);
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL>
SQL>
SQL> select * from test;
ID
----------
1
2
3
4
5
二、RMAN 0級全備RMAN> backup incremental level 0 database tag 'db0' format '/u01/rman/db0_%T.bak';
Starting backup at 2018/06/22 08:50:51
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=389 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=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/cs.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/secure.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2018/06/22 08:50:52
channel ORA_DISK_1: finished piece 1 at 2018/06/22 08:50:59
piece handle=/u01/rman/db0_20180622.bak tag=DB0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 2018/06/22 08:50:59
Starting Control File and SPFILE Autobackup at 2018/06/22 08:50:59
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-00.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2018/06/22 08:51:00
三、試験データの挿入を続けるSQL> insert into test values(6);
1 row created.
SQL> insert into test values(7);
1 row created.
SQL> insert into test values(8);
1 row created.
SQL> insert into test values(9);
1 row created.
SQL> insert into test values(10);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
四、RMAN 1級増分バックアップRMAN> backup incremental level 1 database tag 'db1' format '/u01/rman/db1_%T.bak';
Starting backup at 2018/06/22 08:54:15
using channel ORA_DISK_1
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=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/cs.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/secure.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2018/06/22 08:54:16
channel ORA_DISK_1: finished piece 1 at 2018/06/22 08:54:19
piece handle=/u01/rman/db1_20180622.bak tag=DB1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2018/06/22 08:54:19
Starting Control File and SPFILE Autobackup at 2018/06/22 08:54:19
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2018/06/22 08:54:20
五、バックアップアーカイブRMAN> backup archivelog all format '/u01/rman/arch_%T.bak' tag 'arch';
Starting backup at 2018/06/22 09:29:59
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=11 RECID=931 STAMP=979320140
channel ORA_DISK_1: starting piece 1 at 2018/06/22 09:30:00
channel ORA_DISK_1: finished piece 1 at 2018/06/22 09:30:01
piece handle=/u01/rman/arch_20180622.bak tag=ARCH comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=932 STAMP=979375362
input archived log thread=1 sequence=3 RECID=934 STAMP=979464451
input archived log thread=1 sequence=4 RECID=935 STAMP=979464479
input archived log thread=1 sequence=5 RECID=936 STAMP=979464485
input archived log thread=1 sequence=6 RECID=937 STAMP=979464599
channel ORA_DISK_1: starting piece 1 at 2018/06/22 09:30:01
六、open状態でデータファイル、パラメータファイル、制御ファイルを削除する[oracle@gs ~]$ rm -rf /u01/app/oracle/oradata/orcl/*.dbf
[oracle@gs ~]$ rm -rf /u01/app/oracle/oradata/orcl/*.ctl
[oracle@gs ~]$ rm /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora
[oracle@gs ~]$ ll /u01/app/oracle/oradata/orcl/
total 290484
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo03.log
-rw-r----- 1 oracle oinstall 52429312 Jun 21 08:42 redo04b.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:29 redo04.log
七、強制的にデータベースを閉鎖する[oracle@gs ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jun 22 09:35:46 2018
Copyright © 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown abort
ORACLE instance shut down.
八、RMANデータベースをnomountに起動する[oracle@gs ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jun 22 09:36:55 2018
Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
Oracle
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 285213576 bytes
Database Buffers 775946240 bytes
Redo Buffers 5517312 bytes
九、nomountでspfileを回復するRMAN> restore spfile from '/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl';
Starting restore at 2018/06/22 09:43:57
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2018/06/22 09:43:58
十、データベースをspfileで起動させるRMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 2137886720 bytes
Fixed Size 2254952 bytes
Variable Size 1224738712 bytes
Database Buffers 905969664 bytes
Redo Buffers 4923392 bytes
十一、RMAN nomountで制御ファイルを回復するRMAN> restore controlfile from '/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl';
Starting restore at 2018/06/22 09:45:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1149 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/oradata/orcl/control02.ctl
Finished restore at 2018/06/22 09:45:53
十二、RMAN mountモードでデータファイルを復元し、応用ログでデータベースを回復するRMAN> alter database mount;
RMAN> restore database;
Starting restore at 2018/06/22 09:47:41
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/secure.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db0_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db0_20180622.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 2018/06/22 09:47:57
RMAN> recover database;
Starting recover at 2018/06/22 09:51:19
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/orcl/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/orcl/sysaux01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/orcl/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/orcl/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/orcl/secure.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db1_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db1_20180622.bak tag=DB1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
starting media recovery
archived log for thread 1 with sequence 6 is already on disk as file /u01/app/oracle/oradata/orcl/redo04.log
archived log for thread 1 with sequence 7 is already on disk as file /u01/app/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/arch/1_3_979320362.dbf thread=1 sequence=3
archived log file name=/u01/arch/1_4_979320362.dbf thread=1 sequence=4
archived log file name=/u01/arch/1_5_979320362.dbf thread=1 sequence=5
archived log file name=/u01/app/oracle/oradata/orcl/redo04.log thread=1 sequence=6
archived log file name=/u01/app/oracle/oradata/orcl/redo01.log thread=1 sequence=7
archived log file name=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=8
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018/06/22 09:51:21
十三、データベースを開くRMAN> alter database open resetlogs;
database opened
十四、表testの整合性を検証するSQL> conn admin/oracle
Connected.
SQL> select * from test;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
三、RMANに関する注意点
1、インクリメンタルバックアップリストアデータファイル(restore)は0レベルのバックアップで実現され、recoverはN個の1レベルのバックアップで実現される.2、T 0の時点でレベル0とレベル1のバックアップを行ったと仮定し、T 1の時点でRMANがデータを回復し、データベース(alter database open resetlogs)を開く.この場合、T 0時点(resetlog以前)のフルバックアップを復元する必要がある場合は、T 0時点制御ファイルを復元してrestore,recoverを行う必要があります.(このシーンはlist incarnationで試してもいいですhttps://blog.csdn.net/henrybai/article/details/38037255)3、nomount状態でRMANは復元制御ファイルを上書きすることができる.4、コードブロックを使用して回復を完成することができるrun {
set until time "to_date('2018-06-22 14:03:00','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
}
四、研究を広げる N
は、T 0時点0レベルのバックアップ、T 1時点1レベルのバックアップ、T 2時点1レベルのバックアップがあると仮定する.T 2のレベル1のバックアップが失われた場合は、T 1バックアップにのみリカバリできます.
このとき、T 1時点にリカバリする必要がある場合は、restoreおよびrecoverはuntil timeを実行します.RMAN> recover database until time "to_date('2018-06-22 14:00:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:43:08
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/22/2018 16:43:08
RMAN-06555: datafile 1 must be restored from backup created before 2018/06/22 14:00:00
recover until time,
2018-06-22 14:07:00 1 , 。restore,recover until time。
RMAN> restore database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting restore at 2018/06/22 16:44:24
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/secure.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db0_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db0_20180622.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018/06/22 16:44:31
RMAN> recover database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:44:50
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 7 is already on disk as file /u01/arch/1_7_979475128.dbf
archived log for thread 1 with sequence 8 is already on disk as file /u01/arch/1_8_979475128.dbf
archived log for thread 1 with sequence 9 is already on disk as file /u01/arch/1_9_979475128.dbf
archived log for thread 1 with sequence 10 is already on disk as file /u01/arch/1_10_979475128.dbf
archived log for thread 1 with sequence 11 is already on disk as file /u01/arch/1_11_979475128.dbf
archived log for thread 1 with sequence 12 is already on disk as file /u01/arch/1_12_979475128.dbf
archived log file name=/u01/arch/1_7_979475128.dbf thread=1 sequence=7
archived log file name=/u01/arch/1_8_979475128.dbf thread=1 sequence=8
archived log file name=/u01/arch/1_9_979475128.dbf thread=1 sequence=9
archived log file name=/u01/arch/1_10_979475128.dbf thread=1 sequence=10
archived log file name=/u01/arch/1_11_979475128.dbf thread=1 sequence=11
archived log file name=/u01/arch/1_12_979475128.dbf thread=1 sequence=12
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018/06/22 16:44:51
RMAN> alter database open resetlogs;
database opened
復旧完了
データがT 1時点に復元されたことを確認
SQL> create table test (id number);
Table created.
SQL> insert into test values(1);
1 row created.
SQL> insert into test values(2);
1 row created.
SQL> insert into test values(3);
1 row created.
SQL> insert into test values(4);
1 row created.
SQL> insert into test values(5);
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL>
SQL>
SQL> select * from test;
ID
----------
1
2
3
4
5
RMAN> backup incremental level 0 database tag 'db0' format '/u01/rman/db0_%T.bak';
Starting backup at 2018/06/22 08:50:51
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=389 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=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/cs.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/secure.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2018/06/22 08:50:52
channel ORA_DISK_1: finished piece 1 at 2018/06/22 08:50:59
piece handle=/u01/rman/db0_20180622.bak tag=DB0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 2018/06/22 08:50:59
Starting Control File and SPFILE Autobackup at 2018/06/22 08:50:59
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-00.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2018/06/22 08:51:00
SQL> insert into test values(6);
1 row created.
SQL> insert into test values(7);
1 row created.
SQL> insert into test values(8);
1 row created.
SQL> insert into test values(9);
1 row created.
SQL> insert into test values(10);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
RMAN> backup incremental level 1 database tag 'db1' format '/u01/rman/db1_%T.bak';
Starting backup at 2018/06/22 08:54:15
using channel ORA_DISK_1
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=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/cs.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/secure.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2018/06/22 08:54:16
channel ORA_DISK_1: finished piece 1 at 2018/06/22 08:54:19
piece handle=/u01/rman/db1_20180622.bak tag=DB1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2018/06/22 08:54:19
Starting Control File and SPFILE Autobackup at 2018/06/22 08:54:19
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2018/06/22 08:54:20
RMAN> backup archivelog all format '/u01/rman/arch_%T.bak' tag 'arch';
Starting backup at 2018/06/22 09:29:59
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=11 RECID=931 STAMP=979320140
channel ORA_DISK_1: starting piece 1 at 2018/06/22 09:30:00
channel ORA_DISK_1: finished piece 1 at 2018/06/22 09:30:01
piece handle=/u01/rman/arch_20180622.bak tag=ARCH comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=932 STAMP=979375362
input archived log thread=1 sequence=3 RECID=934 STAMP=979464451
input archived log thread=1 sequence=4 RECID=935 STAMP=979464479
input archived log thread=1 sequence=5 RECID=936 STAMP=979464485
input archived log thread=1 sequence=6 RECID=937 STAMP=979464599
channel ORA_DISK_1: starting piece 1 at 2018/06/22 09:30:01
[oracle@gs ~]$ rm -rf /u01/app/oracle/oradata/orcl/*.dbf
[oracle@gs ~]$ rm -rf /u01/app/oracle/oradata/orcl/*.ctl
[oracle@gs ~]$ rm /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora
[oracle@gs ~]$ ll /u01/app/oracle/oradata/orcl/
total 290484
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:31 redo03.log
-rw-r----- 1 oracle oinstall 52429312 Jun 21 08:42 redo04b.log
-rw-r----- 1 oracle oinstall 52429312 Jun 22 09:29 redo04.log
[oracle@gs ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jun 22 09:35:46 2018
Copyright © 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown abort
ORACLE instance shut down.
[oracle@gs ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jun 22 09:36:55 2018
Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
Oracle
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 285213576 bytes
Database Buffers 775946240 bytes
Redo Buffers 5517312 bytes
RMAN> restore spfile from '/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl';
Starting restore at 2018/06/22 09:43:57
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2018/06/22 09:43:58
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 2137886720 bytes
Fixed Size 2254952 bytes
Variable Size 1224738712 bytes
Database Buffers 905969664 bytes
Redo Buffers 4923392 bytes
RMAN> restore controlfile from '/u01/app/oracle/product/11.2.0/db_1/dbs/control_c-1494212616-20180622-01.ctl';
Starting restore at 2018/06/22 09:45:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1149 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/oradata/orcl/control02.ctl
Finished restore at 2018/06/22 09:45:53
RMAN> alter database mount;
RMAN> restore database;
Starting restore at 2018/06/22 09:47:41
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/secure.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db0_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db0_20180622.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 2018/06/22 09:47:57
RMAN> recover database;
Starting recover at 2018/06/22 09:51:19
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/orcl/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/orcl/sysaux01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/orcl/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/orcl/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/orcl/secure.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db1_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db1_20180622.bak tag=DB1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
starting media recovery
archived log for thread 1 with sequence 6 is already on disk as file /u01/app/oracle/oradata/orcl/redo04.log
archived log for thread 1 with sequence 7 is already on disk as file /u01/app/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oracle/oradata/orcl/redo03.log
archived log file name=/u01/arch/1_3_979320362.dbf thread=1 sequence=3
archived log file name=/u01/arch/1_4_979320362.dbf thread=1 sequence=4
archived log file name=/u01/arch/1_5_979320362.dbf thread=1 sequence=5
archived log file name=/u01/app/oracle/oradata/orcl/redo04.log thread=1 sequence=6
archived log file name=/u01/app/oracle/oradata/orcl/redo01.log thread=1 sequence=7
archived log file name=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=8
archived log file name=/u01/app/oracle/oradata/orcl/redo03.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018/06/22 09:51:21
RMAN> alter database open resetlogs;
database opened
SQL> conn admin/oracle
Connected.
SQL> select * from test;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
1、インクリメンタルバックアップリストアデータファイル(restore)は0レベルのバックアップで実現され、recoverはN個の1レベルのバックアップで実現される.2、T 0の時点でレベル0とレベル1のバックアップを行ったと仮定し、T 1の時点でRMANがデータを回復し、データベース(alter database open resetlogs)を開く.この場合、T 0時点(resetlog以前)のフルバックアップを復元する必要がある場合は、T 0時点制御ファイルを復元してrestore,recoverを行う必要があります.(このシーンはlist incarnationで試してもいいですhttps://blog.csdn.net/henrybai/article/details/38037255)3、nomount状態でRMANは復元制御ファイルを上書きすることができる.4、コードブロックを使用して回復を完成することができる
run {
set until time "to_date('2018-06-22 14:03:00','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
}
四、研究を広げる N
は、T 0時点0レベルのバックアップ、T 1時点1レベルのバックアップ、T 2時点1レベルのバックアップがあると仮定する.T 2のレベル1のバックアップが失われた場合は、T 1バックアップにのみリカバリできます.
このとき、T 1時点にリカバリする必要がある場合は、restoreおよびrecoverはuntil timeを実行します.RMAN> recover database until time "to_date('2018-06-22 14:00:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:43:08
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/22/2018 16:43:08
RMAN-06555: datafile 1 must be restored from backup created before 2018/06/22 14:00:00
recover until time,
2018-06-22 14:07:00 1 , 。restore,recover until time。
RMAN> restore database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting restore at 2018/06/22 16:44:24
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/secure.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db0_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db0_20180622.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018/06/22 16:44:31
RMAN> recover database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:44:50
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 7 is already on disk as file /u01/arch/1_7_979475128.dbf
archived log for thread 1 with sequence 8 is already on disk as file /u01/arch/1_8_979475128.dbf
archived log for thread 1 with sequence 9 is already on disk as file /u01/arch/1_9_979475128.dbf
archived log for thread 1 with sequence 10 is already on disk as file /u01/arch/1_10_979475128.dbf
archived log for thread 1 with sequence 11 is already on disk as file /u01/arch/1_11_979475128.dbf
archived log for thread 1 with sequence 12 is already on disk as file /u01/arch/1_12_979475128.dbf
archived log file name=/u01/arch/1_7_979475128.dbf thread=1 sequence=7
archived log file name=/u01/arch/1_8_979475128.dbf thread=1 sequence=8
archived log file name=/u01/arch/1_9_979475128.dbf thread=1 sequence=9
archived log file name=/u01/arch/1_10_979475128.dbf thread=1 sequence=10
archived log file name=/u01/arch/1_11_979475128.dbf thread=1 sequence=11
archived log file name=/u01/arch/1_12_979475128.dbf thread=1 sequence=12
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018/06/22 16:44:51
RMAN> alter database open resetlogs;
database opened
復旧完了
データがT 1時点に復元されたことを確認
RMAN> recover database until time "to_date('2018-06-22 14:00:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:43:08
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/22/2018 16:43:08
RMAN-06555: datafile 1 must be restored from backup created before 2018/06/22 14:00:00
recover until time,
2018-06-22 14:07:00 1 , 。restore,recover until time。
RMAN> restore database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting restore at 2018/06/22 16:44:24
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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/secure.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/db0_20180622.bak
channel ORA_DISK_1: piece handle=/u01/rman/db0_20180622.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2018/06/22 16:44:31
RMAN> recover database until time "to_date('2018-06-22 14:06:00','yyyy-mm-dd hh24:mi:ss')";
Starting recover at 2018/06/22 16:44:50
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 7 is already on disk as file /u01/arch/1_7_979475128.dbf
archived log for thread 1 with sequence 8 is already on disk as file /u01/arch/1_8_979475128.dbf
archived log for thread 1 with sequence 9 is already on disk as file /u01/arch/1_9_979475128.dbf
archived log for thread 1 with sequence 10 is already on disk as file /u01/arch/1_10_979475128.dbf
archived log for thread 1 with sequence 11 is already on disk as file /u01/arch/1_11_979475128.dbf
archived log for thread 1 with sequence 12 is already on disk as file /u01/arch/1_12_979475128.dbf
archived log file name=/u01/arch/1_7_979475128.dbf thread=1 sequence=7
archived log file name=/u01/arch/1_8_979475128.dbf thread=1 sequence=8
archived log file name=/u01/arch/1_9_979475128.dbf thread=1 sequence=9
archived log file name=/u01/arch/1_10_979475128.dbf thread=1 sequence=10
archived log file name=/u01/arch/1_11_979475128.dbf thread=1 sequence=11
archived log file name=/u01/arch/1_12_979475128.dbf thread=1 sequence=12
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018/06/22 16:44:51
RMAN> alter database open resetlogs;
database opened