查看现有的数据文件

SQL> select name from v$datafile;

NAME
————————————————–
+DATA1/orcl/datafile/system.256.821610633
+DATA1/orcl/datafile/undotbs1.258.821610641
+DATA1/orcl/datafile/sysaux.257.821610637
+DATA1/orcl/datafile/users.259.821610643
+DATA1/orcl/datafile/example.264.821610823
+DATA1/orcl/datafile/undotbs2.265.821611385

6 rows selected.

RMAN> crosscheck copy;
RMAN> delete expired copy;

做一个完全备份
RMAN> run{
2> CONFIGURE CONTROLFILE AUTOBACKUP ON;
3> configure controlfile autobackup format for device type disk to '/backup/orcl/autobackup_control_%F';
4> backup as copy db_file_name_convert=('+data1/orcl','/backup/orcl') database;
5> }

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

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'backup/orcl/autobackup_control_%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/orcl/autobackup_control_%F';
new RMAN configuration parameters are successfully stored

Starting backup at 30-JUL-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=+DATA1/orcl/datafile/system.256.821610633
output filename=/backup/orcl/datafile/system.256.821610633 tag=TAG20130730T140326 recid=14 stamp=822146675
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=+DATA1/orcl/datafile/sysaux.257.821610637
output filename=/backup/orcl/datafile/sysaux.257.821610637 tag=TAG20130730T140326 recid=15 stamp=822146742
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+DATA1/orcl/datafile/example.264.821610823
output filename=/backup/orcl/datafile/example.264.821610823 tag=TAG20130730T140326 recid=16 stamp=822146763
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=+DATA1/orcl/datafile/undotbs1.258.821610641
output filename=/backup/orcl/datafile/undotbs1.258.821610641 tag=TAG20130730T140326 recid=17 stamp=822146771
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=+DATA1/orcl/datafile/undotbs2.265.821611385
output filename=/backup/orcl/datafile/undotbs2.265.821611385 tag=TAG20130730T140326 recid=18 stamp=822146783
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+DATA1/orcl/datafile/users.259.821610643
output filename=/backup/orcl/datafile/users.259.821610643 tag=TAG20130730T140326 recid=19 stamp=822146788
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 30-JUL-13

Starting Control File and SPFILE Autobackup at 30-JUL-13
piece handle=/backup/orcl/autobackup_control_c-1349391482-20130730-02 comment=NONE
Finished Control File and SPFILE Autobackup at 30-JUL-13

备份完后添加数据文件
SQL> create tablespace test datafile size 2m;

Tablespace created.

SQL> alter tablespace users add datafile size 3m;

Tablespace altered.

SQL> select name from v$datafile;

NAME
——————————————————————————–
+DATA1/orcl/datafile/system.256.821610633               
+DATA1/orcl/datafile/undotbs1.258.821610641           
+DATA1/orcl/datafile/sysaux.257.821610637              
+DATA1/orcl/datafile/users.259.821610643                
+DATA1/orcl/datafile/example.264.821610823            
+DATA1/orcl/datafile/undotbs2.265.821611385           
+DATA1/orcl/datafile/test.277.822146855
+DATA1/orcl/datafile/users.278.822146889

8 rows selected.

插入一些数据
sqlplus scott/oracle
SQL> create table tb_test as select * from v$session;

Table created.

SQL> select count(*) from tb_test;

  COUNT(*)
———-
        31

进入asm删除刚创建的两个数据文件  
ASMCMD> rm TEST.277.822146855
ASMCMD> rm USERS.278.822146889

SQL> startup
ORACLE instance started.

Total System Global Area  201326592 bytes
Fixed Size                  1272792 bytes
Variable Size             109052968 bytes
Database Buffers           88080384 bytes
Redo Buffers                2920448 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 – see DBWR trace file
ORA-01110: data file 7: '+DATA1/orcl/datafile/test.277.822146855'
由于是在备份之后创建的所以restore不回来,遇到这种情况 需要使用alter database create datafile 命令重建文件,使用这个命令时不需要指定数据文件所属的表空间,也不用指定数据文件大小,因为这些属性在控制文件中都有记录  

根据文件号重建这两个文件
SQL> alter database create datafile 7;
Database altered.
SQL> alter database create datafile 8;
Database altered.

SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01110: data file 7: '+DATA1/orcl/datafile/test.277.822146855'
ORA-01157: cannot identify/lock data file 7 – see DBWR trace file
ORA-01110: data file 7: '+DATA1/orcl/datafile/test.277.822146855'
因为recover只能在已有的物理文件上进行恢复,已经删除 没有这个文件,新建的文件名字不同无法识别

修改文件名更新控制文件
SQL> alter database rename file '+DATA1/orcl/datafile/test.277.822146855' to '+DATA1/orcl/datafile/TEST.278.822147787';
Database altered.
SQL> alter database rename file '+DATA1/orcl/datafile/users.278.822146889' to '+DATA1/orcl/datafile/USERS.277.822147797';
Database altered. 

由于redo和归档都在可以重演整个过程恢复
SQL> recover datafile 7;
Media recovery complete.
SQL> recover datafile 8;
Media recovery complete.
SQL> alter database open;

Database altered. 
 




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

only 1 comment untill now

  1. crawlspace@bayaderka.lightest” rel=”nofollow”>.…

    thanks for information!!…

Add your comment now

无觅相关文章插件