ITPub博客

RMAN 完全恢复

原创 Oracle 作者:haoge0205 时间:2013-12-16 23:52:10 0 删除 编辑
OS:
ORACLE-LINUX 5.7

DB:
11.2.0.3.0


完全恢复


查看现有的数据文件
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/yoon/datafile/system.256.823151193
+DATA/yoon/datafile/sysaux.257.823151193
+DATA/yoon/datafile/undotbs1.258.823151193
+DATA/yoon/datafile/users.259.823151193
+DATA/yoon/datafile/undotbs2.264.823151401


做一个完全备份
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored


RMAN> backup as copy database ;

Starting backup at 2013:12:16 15:29:30
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=yoon1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/yoon/datafile/system.256.823151193
output file name=+FLUSH/yoon/datafile/system.261.834334171 tag=TAG20131216T152930 RECID=1 STAMP=834334197
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/yoon/datafile/sysaux.257.823151193
output file name=+FLUSH/yoon/datafile/sysaux.262.834334207 tag=TAG20131216T152930 RECID=2 STAMP=834334226
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/yoon/datafile/undotbs1.258.823151193
output file name=+FLUSH/yoon/datafile/undotbs1.263.834334231 tag=TAG20131216T152930 RECID=3 STAMP=834334234
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/yoon/datafile/undotbs2.264.823151401
output file name=+FLUSH/yoon/datafile/undotbs2.264.834334235 tag=TAG20131216T152930 RECID=4 STAMP=834334235
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/yoon/datafile/users.259.823151193
output file name=+FLUSH/yoon/datafile/users.265.834334237 tag=TAG20131216T152930 RECID=5 STAMP=834334237
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013:12:16 15:30:38

Starting Control File and SPFILE Autobackup at 2013:12:16 15:30:38
piece handle=+FLUSH/yoon/autobackup/2013_12_16/s_834334238.266.834334241 comment=NONE
Finished Control File and SPFILE Autobackup at 2013:12:16 15:30:41


创建一个表空间
SQL> create tablespace yoon datafile size 5m;

Tablespace created.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/yoon/datafile/system.256.823151193
+DATA/yoon/datafile/sysaux.257.823151193
+DATA/yoon/datafile/undotbs1.258.823151193
+DATA/yoon/datafile/users.259.823151193
+DATA/yoon/datafile/undotbs2.264.823151401
+DATA/yoon/datafile/yoon.268.834334445


创建表
SQL> create table yoon as select * from user_tables;

Table created.

SQL> select count(*) from yoon;

  COUNT(*)
----------
       971
      
关闭数据库删除文件,模拟灾难场景
SQL> !
[oracle@rac1 ~]$ srvctl stop database -d yoon

ASMCMD> rm -rf YOON.268.834334445


启动数据库
[oracle@rac1 ~]$ srvctl start database -d yoon 
PRCR-1079 : Failed to start resource ora.yoon.db
CRS-5017: The resource action "ora.yoon.db start" encountered the following error:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATA/yoon/datafile/yoon.268.834334445'
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/11.2.0/log/rac1/agent/crsd/oraagent_oracle/oraagent_oracle.log".

CRS-2674: Start of 'ora.yoon.db' on 'rac1' failed
CRS-2632: There are no more servers to try to place resource 'ora.yoon.db' on that would satisfy its placement policy
CRS-5017: The resource action "ora.yoon.db start" encountered the following error:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATA/yoon/datafile/yoon.268.834334445'
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/11.2.0/log/rac2/agent/crsd/oraagent_oracle/oraagent_oracle.log".


SQL> startup
ORA-03135: connection lost contact
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2228904 bytes
Variable Size            1023413592 bytes
Database Buffers          620756992 bytes
Redo Buffers                7118848 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATA/yoon/datafile/yoon.268.834334445'

不能用recover database; 因为这个数据文件根本没有备份


需要用alter database create datafile命令重建文件
SQL> alter database create datafile '+DATA/yoon/datafile/yoon.268.834334445';

Database altered.


alter database create datafile 6;


SQL> recover datafile 6;
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 6: '+DATA/yoon/datafile/yoon.268.834334445'
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATA/yoon/datafile/yoon.268.834334445'


ASMCMD> ls
SYSAUX.257.823151193
SYSTEM.256.823151193
UNDOTBS1.258.823151193
UNDOTBS2.264.823151401
USERS.259.823151193
YOON.268.834334961


发现源文件和新建的文件不同之处,因此:
SQL> alter database rename file '+DATA/yoon/datafile/yoon.268.834334445' to '+DATA/yoon/datafile/YOON.268.834334961';

Database altered.


SQL> recover datafile 6;
Media recovery complete.


SQL> alter database open;

Database altered.


SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/yoon/datafile/system.256.823151193
+DATA/yoon/datafile/sysaux.257.823151193
+DATA/yoon/datafile/undotbs1.258.823151193
+DATA/yoon/datafile/users.259.823151193
+DATA/yoon/datafile/undotbs2.264.823151401
+DATA/yoon/datafile/yoon.268.834334961

6 rows selected.

SQL> select count(*) from yoon;

  COUNT(*)
----------
       971

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28939273/viewspace-1063420/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-28

  • 博文量
    223
  • 访问量
    1611958