问题2:假如依次做了几次这样的备份:
a、全备
b、level 0
c、全备
d、level 1
做完这几次备份后,如果恢复,rman是从哪个备份集开始restore?recover的时候用到哪些备份集?
[root@redhat ~]# su - oracle
[oracle@redhat ~]$ sqlplus /nolog
SQL> conn scott/tiger
Connected.
SQL> select count(*) from test;
COUNT(*)
----------
524288
SQL> truncate table test;
Table truncated.
SQL> commit;
Commit complete.
SQL> exit
[oracle@redhat ~]$ ./bin/full.sh
piece handle=/bak/full_43_1 tag=TAG20100714T201849 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:55
Finished backup at 14-JUL-10
[oracle@redhat ~]$ sqlplus /nolog
SQL> conn scott/tiger
Connected.
SQL> insert into test select * from emp;
16 rows created.
SQL> /
3072 rows created.
SQL> select count(*) from test;
COUNT(*)
----------
6144
SQL> commit;
Commit complete.
SQL> exit
[oracle@redhat ~]$ ./bin/level_0.sh
piece handle=/bak/level_0_45_1 tag=TAG20100714T202047 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:55
Finished backup at 14-JUL-10
[oracle@redhat ~]$ sqlplus /nolog
SQL> conn scott/tiger
Connected.
SQL> select count (*) from test;
COUNT(*)
----------
6144
SQL> insert into test select * from test;
….
SQL> select count(*) from test;
COUNT(*)
----------
24576
SQL> exit
[oracle@redhat ~]$ ./bin/full.sh
channel a2: starting piece 1 at 14-JUL-10
channel a2: finished piece 1 at 14-JUL-10
piece handle=/bak/full_47_1 tag=TAG20100714T202239 comment=NONE
channel a2: backup set complete, elapsed time: 00:01:05
Finished backup at 14-JUL-10
[oracle@redhat ~]$ sqlplus /nolog
SQL> conn scott/tiger
Connected.
SQL> select count(*) from test;
COUNT(*)
----------
24576
SQL> insert into test select * from test;
…
SQL> select count(*) from test;
COUNT(*)
----------
196608
SQL> commit;
Commit complete.
SQL> exit
[oracle@redhat ~]$ ./bin/level_1.sh
channel d1: starting piece 1 at 14-JUL-10
channel d1: finished piece 1 at 14-JUL-10
piece handle=/bak/level_1_49_1 tag=TAG20100714T202445 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:36
Finished backup at 14-JUL-10
[oracle@redhat ~]$ ./bin/arch.sh
piece handle=/bak/archbak/arc_51_1.arc tag=TAG20100714T202549 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 14-JUL-10
[oracle@redhat ~]$ sqlplus /nolog
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
[oracle@redhat ~]$ cd /u01/app/oracle/oradata/ORCL/datafile
[oracle@redhat datafile]$ ll
总用量 913696
-rw-r----- 1 oracle oinstall 104865792 7月 14 20:26 o1_mf_example_63v43w1p_.dbf
-rw-r----- 1 oracle oinstall 262152192 7月 14 20:26 o1_mf_sysaux_63v43w0o_.dbf
-rw-r----- 1 oracle oinstall 503324672 7月 14 20:26 o1_mf_system_63v43vyq_.dbf
-rw-r----- 1 oracle oinstall 20979712 7月 14 18:11 o1_mf_temp_63v3bb9n_.tmp
-rw-r----- 1 oracle oinstall 31465472 7月 14 20:26 o1_mf_undotbs1_63v43w_.dbf
-rw-r----- 1 oracle oinstall 32776192 7月 14 20:26 o1_mf_users_63v43w3j_.dbf
[oracle@redhat datafile]$ rm *.dbf
[oracle@redhat ORCL]$ ll datafile/
总用量 80
-rw-r----- 1 oracle oinstall 20979712 7月 14 18:11 o1_mf_temp_63v3bb9n_.tmp
[oracle@redhat ORCL]$ sqlplus /nolog
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1:
'/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_63v43vyq_.dbf'
SQL> exit
[oracle@redhat ORCL]$ rman target /
RMAN> restore database;
Starting restore at 14-JUL-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_63v43vyq_.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_63v43w_.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_63v43w0o_.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_63v43w3j_.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_63v43w1p_.dbf
channel ORA_DISK_1: reading from backup piece /bak/full_47_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/bak/full_47_1 tag=TAG20100714T202239
channel ORA_DISK_1: restore complete, elapsed time: 00:00:57
Finished restore at 14-JUL-10
RMAN> recover database;
Starting recover at 14-JUL-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_63vcgh4t_.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_63vcghc1_.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_63vcgh6j_.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_63vcgh9p_.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_63vcgh7r_.dbf
channel ORA_DISK_1: reading from backup piece /bak/level_1_49_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/bak/level_1_49_1 tag=TAG20100714T202445
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 14-JUL-10
RMAN> exit
Recovery Manager complete.
[oracle@redhat ORCL]$ sqlplus /nolog
SQL> conn /as sysdba
Connected.
SQL> alter database open;
Database altered.
SQL> conn scott/tiger
SQL> select count (*) from test;
COUNT(*)
----------
196608
文中用到脚本:
[oracle@redhat bin]$ cat full.sh
#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0.2/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
date
rman target /<<EOF
run
{ allocate channel a2 type disk;
backup
format '/bak/full_%s_%p'
(database);
}
exit
EOF
date
[oracle@redhat bin]$ cat level_0.sh
#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0.2/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
date
rman target /<<EOF
run
{ allocate channel d1 type disk;
backup incremental level=0
format '/bak/level_0_%s_%p'
(database);
}
exit
EOF
date
[oracle@redhat bin]$ cat level_1.sh
#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0.2/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
date
rman target /<<EOF
run
{ allocate channel d1 type disk;
backup incremental level=1
format '/bak/level_1_%s_%p'
(database);
}
exit
EOF
date
总结:如果level0 和 level1之间做了full,那么restore时rman自动使用之间的full进行restore,之后recover时使用level1进行recover。。
rman实验(一)
今天做两个实验,两个都是朋友问的问题。
问题1:假如做了3次全备,full1,full2,full3,其中full3是最近做的备份,但是最近做的这次full3的备份集不能用了,问:能从前一次的备份集恢复到现在吗?
本文通过实验详细解释了Oracle RMAN在不同备份类型(全备、level0、level1)下的备份与恢复流程,包括如何从特定备份集开始恢复数据库及在恢复后的数据恢复过程。
2085

被折叠的 条评论
为什么被折叠?



