--备份全库
rman target /
RMAN>backup database plus
archivelog;
--删除物理文件
[oracle@rhel6 ora11g]$ cd
$ORACLE_HOME/dbs
[oracle@rhel6 dbs]$
ls
hc_DBUA0.dat initora11g.ora lkORA11G peshm_DBUA0_0 peshm_ora11g_0
spfileora11g.ora
hc_ora11g.dat
lkDUMMY orapwora11g
peshm_DUMMY_0
snapcf_ora11g.f
[oracle@rhel6 dbs]$ rm
spfileora11g.ora
[oracle@rhel6 dbs]$ rm
initora11g.ora
--shutdown+startup
试验用,正式库不要使用
SYS@ora11g>startup
force
ORA-01078: failure in
processing system parameters
LRM-00109: could not open
parameter file
'/u01/oracle/product/11.2.0/dbs/initora11g.ora'
--切换到nomount状态
RMAN> startup nomount
force;
startup failed: ORA-01078:
failure in processing system parameters
LRM-00109: could not open
parameter file
'/u01/oracle/product/11.2.0/dbs/initora11g.ora'
starting Oracle instance
without parameter file for retrieval of spfile
Oracle instance
started
Total System Global Area
159019008 bytes
Fixed Size 1335192
bytes
Variable Size
75497576 bytes
Database Buffers
79691776 bytes
Redo Buffers 2494464 bytes
--尝试用自动备份恢复
RMAN> set
DBID=32980040
executing command: SET
DBID
RMAN> restore spfile from
autobackup;
Starting restore at 2018-02-06
23:27:24
using channel
ORA_DISK_1
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180206
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180205
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180204
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180203
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180202
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180201
channel ORA_DISK_1: looking for
AUTOBACKUP on day: 20180131
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 02/06/2018 23:27:26
RMAN-06172: no AUTOBACKUP found
or specified handle is not a valid copy or piece
--上述报错为找到文件,那么我们查下参数
RMAN> show controlfile
autobackup;
using target database control
file instead of recovery catalog
RMAN configuration parameters
for database with db_unique_name DUMMY are:
CONFIGURE CONTROLFILE
AUTOBACKUP OFF; # default
--既然如此,我们找下包含参数文件的备份文件
[oracle@rhel6 2018_02_06]$
pwd
/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_06
[oracle@rhel6 2018_02_06]$ ls
-lrt
total 1708836
-rw-r----- 1 oracle oinstall
616095744 Feb 6 22:45
o1_mf_nnndf_TAG20180206T224432_f7mhtk0g_.bkp
-rw-r----- 1 oracle oinstall
55453696 Feb 6 23:16
o1_mf_annnn_TAG20180206T231602_f7mkollp_.bkp
-rw-r----- 1 oracle oinstall
1076559872 Feb 6 23:17
o1_mf_nnndf_TAG20180206T231609_f7mkotgl_.bkp
-rw-r----- 1 oracle oinstall
10752 Feb
6 23:17
o1_mf_annnn_TAG20180206T231746_f7mkrvcl_.bkp
--尝试一个文件恢复
RMAN> restore spfile from
'/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_06/o1_mf_annnn_TAG20180206T231746_f7mkrvcl_.bkp';
Starting restore at 2018-02-06
23:39:46
allocated channel:
ORA_DISK_1
channel ORA_DISK_1: SID=19
device type=DISK
channel ORA_DISK_1: restoring
spfile from AUTOBACKUP
/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_06/o1_mf_annnn_TAG20180206T231746_f7mkrvcl_.bkp
RMAN-00571:
===========================================================
RMAN-00569: ===============
ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571:
===========================================================
RMAN-03002: failure of restore
command at 02/06/2018 23:39:47
ORA-19870: error while
restoring backup piece
/u01/oracle/flash_recovery_area/ORA11G/backupset/2018_02_06/o1_mf_annnn_TAG20180206T231746_f7mkrvcl_.bkp
ORA-19626: backup set type is
archived log - can not be processed by this
conversation
--接着尝试其他文件(之前备份的文件)
RMAN> restore spfile from
'/u01/oracle/flash_recovery_area/ORA11G/autobackup/2018_02_06/o1_mf_s_967414346_f7mfyckg_.bkp';
Starting restore at 2018-02-06
23:53:23
using channel
ORA_DISK_1
channel ORA_DISK_1: restoring
spfile from AUTOBACKUP
/u01/oracle/flash_recovery_area/ORA11G/autobackup/2018_02_06/o1_mf_s_967414346_f7mfyckg_.bkp
channel ORA_DISK_1: SPFILE
restore from AUTOBACKUP complete
Finished restore at 2018-02-06
23:53:24
--开启数据库
RMAN> startup
force;
Oracle instance
started
database mounted
database opened
Total System Global Area
234344448 bytes
Fixed Size 1335696
bytes
Variable Size
150998640 bytes
Database Buffers
79691776 bytes
Redo Buffers 2318336 bytes
SYS@ora11g>select open_mode
from v$database;
OPEN_MODE
--------------------
READ WRITE
--其他
RMAN> CONFIGURE CONTROLFILE
AUTOBACKUP ON;
old RMAN configuration
parameters:
CONFIGURE CONTROLFILE
AUTOBACKUP OFF;
new RMAN configuration
parameters:
CONFIGURE CONTROLFILE
AUTOBACKUP ON;
new RMAN configuration
parameters are successfully stored
RMAN> show controlfile
autobackup;
RMAN configuration parameters
for database with db_unique_name ORA11G are:
CONFIGURE CONTROLFILE
AUTOBACKUP ON;
RMAN>backup database include
current controlfile spfile plus archivelog delete
input;
SYS@ora11g>alter database
backup controlfile to trace;
SYS@ora11g>alter database
backup controlfile to trace as
'/home/oracle/qinctl.bak'