- 浏览: 238619 次
最新评论
补充1:restore database和recover database的区别
restore 只是用备份来还原,recover是用archivelog或者online log
举例说明:
假设我时间点A,做了个备份,时间点B数据库挂了
restore database ;// 这个操作利用时间点A做的备份来还原,返回到时间点A
recover database ;//这个操作利用archivelog and online log做recover,从时间点A,推进到时间点B
restore 是转储 也是還原被损坏文件(RMAN经常用)
recover 是恢复 通过redo log & archive log恢复
补充2:rman模拟故障恢复过程(所有spfile、controlfile、datafile均丢失)-前提是数据库故障前有rman备份
1)RMAN> show all;
CONFIGURE CONTROLFILE AUTOBACKUP ON; ---控制文件备份的同时,会自动备份参数文件
SQL> select dbid from v$database; --1669126943
2)先给数据库做个备份:
RMAN> backup database format '/orabak/whole_%d_%U';
Starting backup at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/oradata/tinadb/sysaux01.dbf
input datafile file number=00001 name=/u01/oradata/tinadb/system01.dbf
input datafile file number=00005 name=/u01/oradata/tinadb/ts_tina01.dbf
input datafile file number=00003 name=/u01/oradata/tinadb/undotbs01.dbf
input datafile file number=00004 name=/u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 18-DEC-15
channel ORA_DISK_1: finished piece 1 at 18-DEC-15
piece handle=/orabak/whole_TINADB_0vqp4nrf_1_1 tag=TAG20151218T143214 comment=NONE ---注意这行,可以看到备份集的具体名称和tag标签
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
Finished backup at 18-DEC-15
Starting Control File and SPFILE Autobackup at 18-DEC-15
piece handle=/u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp comment=NONE
--注意这行,我们可以看到控制文件和spfile都自动备份了,因为我配置了CONFIGURE CONTROLFILE AUTOBACKUP ON;
Finished Control File and SPFILE Autobackup at 18-DEC-15
[root@oratest orabak]# cd /orabak
[root@oratest orabak]# ll
-rw-r-----. 1 oracle oinstall 1238605824 Dec 18 14:32 whole_TINADB_0vqp4nrf_1_1
[root@oratest orabak]# cd /u01/oracle/TINADB/autobackup/2015_12_18/
[root@oratest 2015_12_18]# ll
-rw-r-----. 1 oracle oinstall 10158080 Dec 18 14:32 o1_mf_s_898785171_c77b4mv5_.bkp
3)模拟spfile,controlfile,datafile全部都丢失
SQL> shutdown immediate;
删除文件:
[oracle@oratest dbs]$ cd /u01/oracle/dbs/
[oracle@oratest dbs]$ rm -f pfiletinadb.ora spfiletinadb.ora
[oracle@oratest dbs]$ cd /u01/oradata/tinadb/
[oracle@oratest dbs]$ rm -f *.dbf redo*.log control01.ctl
[root@oratest test]# cd /u01/fast_recovery_area/tinadb/
[root@oratest tinadb]# rm -f control02.ctl
4)以oracle默认的参数文件init.ora启动后,恢复spfile
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/oracle/dbs/inittinadb.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 158662656 bytes
Fixed Size 2226456 bytes
Variable Size 92276456 bytes
Database Buffers 58720256 bytes
Redo Buffers 5439488 bytes
RMAN> set dbid=1669126943 --一定要设置dbid才行
executing command: SET DBID
RMAN> restore spfile from autobackup;
Starting restore at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151218
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151217
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151216
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151215
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151214
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151213
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151212
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/18/2015 15:20:27
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
由于使用的默认参数文件启动,如果更改过autobackup的位置或格式(allocate或format),
恢复时就会找不到路径,可以从警告日志找到autobackup的位置,用日志号最新一个恢复参数文件
RMAN> restore spfile from '/u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp';
---刚刚备份时生成的那个controlfile和spfile的备份
Starting restore at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 18-DEC-15
5)以新生成的spfile启动库并恢复控制文件
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> set dbid=1669126943
executing command: SET DBID
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 520096072 bytes
Database Buffers 1560281088 bytes
Redo Buffers 5173248 bytes
RMAN> restore controlfile from autobackup;
Starting restore at 18-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
recovery area destination: /u01/oracle/
database name (or database unique name) used for search: TINADB
channel ORA_DISK_1: AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151218
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/oradata/tinadb/control01.ctl
output file name=/u01/fast_recovery_area/tinadb/control02.ctl --还是原来的那两个目录
Finished restore at 18-DEC-15
6)恢复库
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database; --利用之前的全备恢复到备份的时刻状态
Starting restore at 18-DEC-15
using channel ORA_DISK_1
skipping datafile 1; already restored to file /u01/oradata/tinadb/system01.dbf
skipping datafile 2; already restored to file /u01/oradata/tinadb/sysaux01.dbf
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 00003 to /u01/oradata/tinadb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/tinadb/ts_tina01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/whole_TINADB_0vqp4nrf_1_1
channel ORA_DISK_1: piece handle=/orabak/whole_TINADB_0vqp4nrf_1_1 tag=TAG20151218T143214
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 18-DEC-15
RMAN> recover database; ---利用归档和在线日志回复数据库到最新状态
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 109 is already on disk as file /u01/oracle/TINADB/archivelog/1_109_898687982.dbf
archived log for thread 1 with sequence 110 is already on disk as file /u01/oracle/TINADB/archivelog/1_110_898687982.dbf
archived log file name=/u01/oracle/TINADB/archivelog/1_109_898687982.dbf thread=1 sequence=109
archived log file name=/u01/oracle/TINADB/archivelog/1_110_898687982.dbf thread=1 sequence=110
unable to find archived log
archived log thread=1 sequence=111
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/18/2015 15:39:45
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 111 and starting SCN of 1889531
可见,出现此错误的原因是恢复需要的日志记录在控制文件或恢复目录中找不到。解决方法分两种情况:
1.如果相关的日志存在且可用的话,就将此日志记录添加到控制文件或恢复目录中。
2.如果相关的日志已经被删除了或不可用了,那么就按照错误的提示scn将数据库恢复到此scn,本案例是2292709。
也就是说此时数据库只能进行不完全恢复了,在打开数据库时得使用resetlogs打开。
RMAN> recover database until scn 1889531;
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-DEC-15
RMAN> alter database open resetlogs;
database opened
整个过程恢复完成!!!
补充3:rman恢复数据库到某一个指定时刻---基于归档日志
1)当前正常环境
SQL> select * from tina.salgrade;
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
RMAN> crosscheck archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_5_898789368.dbf RECID=101 STAMP=898791906
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_6_898789368.dbf RECID=102 STAMP=898791928
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_7_898789368.dbf RECID=103 STAMP=898792550
Crosschecked 3 objects
SQL> select current_timestamp from dual;
CURRENT_TIMESTAMP
--------------------------------------------
18-DEC-15 16.35.09.058343 PM +08:00
SQL> alter system archive log current;
System altered.
2)误操作
SQL> drop table tina.salgrade; ---16:35之后进行的操作
Table dropped.
SQL> select * from tina.salgrade;
select * from tina.salgrade *
ERROR at line 1:
ORA-00942: table or view does not exist
3)利用归档日志,回退到操作之前
启动库到mount状态
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 520096072 bytes
Database Buffers 1560281088 bytes
Redo Buffers 5173248 bytes
Database mounted.
回退:
RMAN> run{
set until time "to_date('2015-12-18 16:35','yyyy-mm-dd hh24:mi')";
restore database;
recover database;
}2> 3> 4> 5>
executing command: SET until clause
Starting restore at 18-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 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 00002 to /u01/oradata/tinadb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/tinadb/ts_tina01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/tinadb/db_0_tinadb_13qp4tpm_1_1
channel ORA_DISK_1: piece handle=/orabak/tinadb/db_0_tinadb_13qp4tpm_1_1 tag=TAG20151218T161342
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
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/oradata/tinadb/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/tinadb/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/tinadb/db_0_tinadb_14qp4tpm_1_1
channel ORA_DISK_1: piece handle=/orabak/tinadb/db_0_tinadb_14qp4tpm_1_1 tag=TAG20151218T161342 --先去读取最近一次的全备
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 18-DEC-15
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 5 is already on disk as file /u01/oracle/TINADB/archivelog/1_5_898789368.dbf
archived log for thread 1 with sequence 6 is already on disk as file /u01/oracle/TINADB/archivelog/1_6_898789368.dbf
archived log for thread 1 with sequence 7 is already on disk as file /u01/oracle/TINADB/archivelog/1_7_898789368.dbf
channel ORA_DISK_1: starting archived log restore to default destination ---开始恢复归档日志。
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_DISK_1: reading from backup piece /orabak/arch19qp4ts7_41_1
channel ORA_DISK_1: piece handle=/orabak/arch19qp4ts7_41_1 tag=TAG20151218T161501
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/oracle/TINADB/archivelog/1_3_898789368.dbf thread=1 sequence=3
archived log file name=/u01/oracle/TINADB/archivelog/1_4_898789368.dbf thread=1 sequence=4
archived log file name=/u01/oracle/TINADB/archivelog/1_5_898789368.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-DEC-15
SQL> alter database open resetlogs;
Database altered.
SQL> select * from tina.salgrade; --数据果然回来了。
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
SQL> alter system switch logfile;
System altered.
完成!
restore 只是用备份来还原,recover是用archivelog或者online log
举例说明:
假设我时间点A,做了个备份,时间点B数据库挂了
restore database ;// 这个操作利用时间点A做的备份来还原,返回到时间点A
recover database ;//这个操作利用archivelog and online log做recover,从时间点A,推进到时间点B
restore 是转储 也是還原被损坏文件(RMAN经常用)
recover 是恢复 通过redo log & archive log恢复
补充2:rman模拟故障恢复过程(所有spfile、controlfile、datafile均丢失)-前提是数据库故障前有rman备份
1)RMAN> show all;
CONFIGURE CONTROLFILE AUTOBACKUP ON; ---控制文件备份的同时,会自动备份参数文件
SQL> select dbid from v$database; --1669126943
2)先给数据库做个备份:
RMAN> backup database format '/orabak/whole_%d_%U';
Starting backup at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/oradata/tinadb/sysaux01.dbf
input datafile file number=00001 name=/u01/oradata/tinadb/system01.dbf
input datafile file number=00005 name=/u01/oradata/tinadb/ts_tina01.dbf
input datafile file number=00003 name=/u01/oradata/tinadb/undotbs01.dbf
input datafile file number=00004 name=/u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 18-DEC-15
channel ORA_DISK_1: finished piece 1 at 18-DEC-15
piece handle=/orabak/whole_TINADB_0vqp4nrf_1_1 tag=TAG20151218T143214 comment=NONE ---注意这行,可以看到备份集的具体名称和tag标签
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
Finished backup at 18-DEC-15
Starting Control File and SPFILE Autobackup at 18-DEC-15
piece handle=/u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp comment=NONE
--注意这行,我们可以看到控制文件和spfile都自动备份了,因为我配置了CONFIGURE CONTROLFILE AUTOBACKUP ON;
Finished Control File and SPFILE Autobackup at 18-DEC-15
[root@oratest orabak]# cd /orabak
[root@oratest orabak]# ll
-rw-r-----. 1 oracle oinstall 1238605824 Dec 18 14:32 whole_TINADB_0vqp4nrf_1_1
[root@oratest orabak]# cd /u01/oracle/TINADB/autobackup/2015_12_18/
[root@oratest 2015_12_18]# ll
-rw-r-----. 1 oracle oinstall 10158080 Dec 18 14:32 o1_mf_s_898785171_c77b4mv5_.bkp
3)模拟spfile,controlfile,datafile全部都丢失
SQL> shutdown immediate;
删除文件:
[oracle@oratest dbs]$ cd /u01/oracle/dbs/
[oracle@oratest dbs]$ rm -f pfiletinadb.ora spfiletinadb.ora
[oracle@oratest dbs]$ cd /u01/oradata/tinadb/
[oracle@oratest dbs]$ rm -f *.dbf redo*.log control01.ctl
[root@oratest test]# cd /u01/fast_recovery_area/tinadb/
[root@oratest tinadb]# rm -f control02.ctl
4)以oracle默认的参数文件init.ora启动后,恢复spfile
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/oracle/dbs/inittinadb.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 158662656 bytes
Fixed Size 2226456 bytes
Variable Size 92276456 bytes
Database Buffers 58720256 bytes
Redo Buffers 5439488 bytes
RMAN> set dbid=1669126943 --一定要设置dbid才行
executing command: SET DBID
RMAN> restore spfile from autobackup;
Starting restore at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151218
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151217
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151216
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151215
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151214
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151213
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151212
channel ORA_DISK_1: no AUTOBACKUP in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/18/2015 15:20:27
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece
由于使用的默认参数文件启动,如果更改过autobackup的位置或格式(allocate或format),
恢复时就会找不到路径,可以从警告日志找到autobackup的位置,用日志号最新一个恢复参数文件
RMAN> restore spfile from '/u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp';
---刚刚备份时生成的那个controlfile和spfile的备份
Starting restore at 18-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 18-DEC-15
5)以新生成的spfile启动库并恢复控制文件
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> set dbid=1669126943
executing command: SET DBID
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 520096072 bytes
Database Buffers 1560281088 bytes
Redo Buffers 5173248 bytes
RMAN> restore controlfile from autobackup;
Starting restore at 18-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
recovery area destination: /u01/oracle/
database name (or database unique name) used for search: TINADB
channel ORA_DISK_1: AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20151218
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/oracle/TINADB/autobackup/2015_12_18/o1_mf_s_898785171_c77b4mv5_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/oradata/tinadb/control01.ctl
output file name=/u01/fast_recovery_area/tinadb/control02.ctl --还是原来的那两个目录
Finished restore at 18-DEC-15
6)恢复库
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database; --利用之前的全备恢复到备份的时刻状态
Starting restore at 18-DEC-15
using channel ORA_DISK_1
skipping datafile 1; already restored to file /u01/oradata/tinadb/system01.dbf
skipping datafile 2; already restored to file /u01/oradata/tinadb/sysaux01.dbf
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 00003 to /u01/oradata/tinadb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/tinadb/ts_tina01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/whole_TINADB_0vqp4nrf_1_1
channel ORA_DISK_1: piece handle=/orabak/whole_TINADB_0vqp4nrf_1_1 tag=TAG20151218T143214
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 18-DEC-15
RMAN> recover database; ---利用归档和在线日志回复数据库到最新状态
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 109 is already on disk as file /u01/oracle/TINADB/archivelog/1_109_898687982.dbf
archived log for thread 1 with sequence 110 is already on disk as file /u01/oracle/TINADB/archivelog/1_110_898687982.dbf
archived log file name=/u01/oracle/TINADB/archivelog/1_109_898687982.dbf thread=1 sequence=109
archived log file name=/u01/oracle/TINADB/archivelog/1_110_898687982.dbf thread=1 sequence=110
unable to find archived log
archived log thread=1 sequence=111
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/18/2015 15:39:45
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 111 and starting SCN of 1889531
可见,出现此错误的原因是恢复需要的日志记录在控制文件或恢复目录中找不到。解决方法分两种情况:
1.如果相关的日志存在且可用的话,就将此日志记录添加到控制文件或恢复目录中。
2.如果相关的日志已经被删除了或不可用了,那么就按照错误的提示scn将数据库恢复到此scn,本案例是2292709。
也就是说此时数据库只能进行不完全恢复了,在打开数据库时得使用resetlogs打开。
RMAN> recover database until scn 1889531;
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-DEC-15
RMAN> alter database open resetlogs;
database opened
整个过程恢复完成!!!
补充3:rman恢复数据库到某一个指定时刻---基于归档日志
1)当前正常环境
SQL> select * from tina.salgrade;
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
RMAN> crosscheck archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_5_898789368.dbf RECID=101 STAMP=898791906
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_6_898789368.dbf RECID=102 STAMP=898791928
validation succeeded for archived log
archived log file name=/u01/oracle/TINADB/archivelog/1_7_898789368.dbf RECID=103 STAMP=898792550
Crosschecked 3 objects
SQL> select current_timestamp from dual;
CURRENT_TIMESTAMP
--------------------------------------------
18-DEC-15 16.35.09.058343 PM +08:00
SQL> alter system archive log current;
System altered.
2)误操作
SQL> drop table tina.salgrade; ---16:35之后进行的操作
Table dropped.
SQL> select * from tina.salgrade;
select * from tina.salgrade *
ERROR at line 1:
ORA-00942: table or view does not exist
3)利用归档日志,回退到操作之前
启动库到mount状态
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 2087780352 bytes
Fixed Size 2229944 bytes
Variable Size 520096072 bytes
Database Buffers 1560281088 bytes
Redo Buffers 5173248 bytes
Database mounted.
回退:
RMAN> run{
set until time "to_date('2015-12-18 16:35','yyyy-mm-dd hh24:mi')";
restore database;
recover database;
}2> 3> 4> 5>
executing command: SET until clause
Starting restore at 18-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 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 00002 to /u01/oradata/tinadb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/tinadb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/tinadb/ts_tina01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/tinadb/db_0_tinadb_13qp4tpm_1_1
channel ORA_DISK_1: piece handle=/orabak/tinadb/db_0_tinadb_13qp4tpm_1_1 tag=TAG20151218T161342
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
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/oradata/tinadb/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/tinadb/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /orabak/tinadb/db_0_tinadb_14qp4tpm_1_1
channel ORA_DISK_1: piece handle=/orabak/tinadb/db_0_tinadb_14qp4tpm_1_1 tag=TAG20151218T161342 --先去读取最近一次的全备
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 18-DEC-15
Starting recover at 18-DEC-15
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 5 is already on disk as file /u01/oracle/TINADB/archivelog/1_5_898789368.dbf
archived log for thread 1 with sequence 6 is already on disk as file /u01/oracle/TINADB/archivelog/1_6_898789368.dbf
archived log for thread 1 with sequence 7 is already on disk as file /u01/oracle/TINADB/archivelog/1_7_898789368.dbf
channel ORA_DISK_1: starting archived log restore to default destination ---开始恢复归档日志。
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_DISK_1: reading from backup piece /orabak/arch19qp4ts7_41_1
channel ORA_DISK_1: piece handle=/orabak/arch19qp4ts7_41_1 tag=TAG20151218T161501
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/oracle/TINADB/archivelog/1_3_898789368.dbf thread=1 sequence=3
archived log file name=/u01/oracle/TINADB/archivelog/1_4_898789368.dbf thread=1 sequence=4
archived log file name=/u01/oracle/TINADB/archivelog/1_5_898789368.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-DEC-15
SQL> alter database open resetlogs;
Database altered.
SQL> select * from tina.salgrade; --数据果然回来了。
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
SQL> alter system switch logfile;
System altered.
完成!
发表评论
-
ETL工具--kettle简介
2016-02-24 11:21 0oracle ETL工具---数据迁移 常用的有:OWB(o ... -
oracle 游标实例
2015-12-31 17:23 1199oracle游标 游标-----内存 ... -
10053事件分析
2015-12-25 17:37 7821)10053介绍: 10053 事件是oracle 提供的用 ... -
oracle绑定变量学习
2015-12-25 17:01 1586绑定变量(binding variable) ... -
oracle 绑定变量
2015-12-24 17:26 0关键词: 绑定变量(binding variable),共享池 ... -
oracle插入大量数据
2015-12-23 17:35 1411oracle插入大量数据 1.生 ... -
ORA-03113:end-of-file on communication channel
2015-12-23 14:32 1139测试上面的一个库 plsql报错:shared memory ... -
oracle分区表【转】
2015-12-23 14:20 433oracle分区表 1.表空间及 ... -
迁移数据文件到ASM【转】
2015-12-23 11:53 7661.迁移数据文件到ASM 1) ... -
adrci命令
2015-12-23 11:46 3048一、adrci说明 在oracle11g中,dump ... -
用户+角色+权限
2015-12-21 17:58 891角色与用户权限的学习 ... -
oracle database link
2015-12-21 17:08 872目前我的数据库里只有tinadb一个实例,要创建db link ... -
oracle回收站
2015-12-21 14:22 426oracle回收站 1.drop table books; ... -
使用nid修改sid和dbname
2015-12-21 15:29 761如非必要,不建议在生产库上对dbid进行修改 1、修改dbi ... -
rman命令学习-tina(下)
2015-12-18 16:07 1152五、rman删除 delete命令 删除相关的 ... -
rman命令学习-tina(上)
2015-12-18 16:06 874RMAN学习-tina rman的功能非常强大,下面我们来一 ... -
oracle profile介绍
2015-12-16 17:34 620profile文件的介绍: Oracle系统中的profi ... -
oracle缩小表空间
2015-12-18 16:59 1755oracle缩小表空间: oracle常用的此类命令Alte ... -
oracle数据库的启动和关闭【转】
2015-12-16 15:02 1131数据库的启动和关闭 Or ... -
oracle的主要进程
2015-12-16 14:21 1180[size=small]oracle的主要进程 Oracle实 ...
相关推荐
Oracle 11g R2 Rman备份与恢复_刘耀龙的博客-CSDN博客_rman备份
【数据迁移1】Oracle 10gR2 rman异机恢复实验(FS-RAW)(截图).pdf
【数据迁移2】 Oracle 10gR2 rman异机恢复实验(FS-FS)(截图).pdf
这是自己亲手研究完oracle 的rman备份后写的备份和恢复方案
【实验目的】 1. 了解Oracle数据库备份和恢复的类型 2. 掌握使用RMAN进行备份数据库和恢复数据库的基本方法
Oracle数据库RMAN备份与恢复.pdf
Oracle11g利用rman创建物理standby实验配置指南.pdfOracle11g利用rman创建物理standby实验配置指南.pdfOracle11g利用rman创建物理standby实验配置指南.pdfOracle11g利用rman创建物理standby实验配置指南.pdfOracle11...
《Oracle Database 11g RMAN备份与恢复》主要内容简介:《Oracle Database 11g RMAN备份与恢复》提供了在硬件、软件、操作发生故障时保护数据库的详细信息。详细解释了如何配置数据库,创建精确的归档以及如何执行...
《Oracle Database 11g RMAN备份与恢复》PDF版本下载
【RMAN】RMAN跨版本恢复(中)--大版本异机恢复【RMAN】RMAN跨版本恢复(中)--大版本异机恢复【RMAN】RMAN跨版本恢复(中)--大版本异机恢复
第一篇 进入RMAN 1 1.1 连接本地数据库 1 1.2 连接远程数据库 1 第二篇 RMAN常用命令 1 ...7.3 查看RMAN恢复目录的数据 34 7.4 使用存储脚步 34 7.5向恢复目录中添加rman备份 34 7.6 恢复目录管理 34
Oracle-RMAN增量备份恢复测试记录
Oracle RMAN增量备份恢复测试记录
Oracle数据库RMAN备份与恢复技术!
顶级DBA漫谈Oracle Rman备份与恢复
oracle第三次上机实验,用RMAN备份和恢复数据库。。。
【RMAN】RMAN跨版本恢复(上)--小版本异机恢复.pdf【RMAN】RMAN跨版本恢复(上)--小版本异机恢复.pdf【RMAN】RMAN跨版本恢复(上)--小版本异机恢复.pdf
rman的备份与恢复 , 常见操作 1、切换服务器归档模式,如果已经是归档模式可跳过此步: %sqlplus /nolog (启动sqlplus) SQL> conn / as sysdba (以DBA身份连接数据库) SQL> shutdown immediate; (立即关闭数据库) ...
Oracle Database 11g RMAN备份与恢复,中文完整版