How to resolve datafile location error when omitted "+" when adding datafile in a tablespace in +DG_DATA diskgroup and it mistakenly added it to the filesystem.
Problem: Omitted "+" when adding datafile in a tablespace in +DG_DATA diskgroup and it mistakenly added it to the filesystem.
below is the command that created the problem:
alter tablespace SYSAUX add datafile 'DG_DATA' size 500m autoextend on next 5G maxsize 30G;
select file_id, file_name, bytes, online_status from dba_data_files where tablespace_name = 'SYSAUX';
system@ORA01 > select file_id, file_name, bytes, online_status from dba_data_files where tablespace_name = 'SYSAUX';
FILE_ID FILE_NAME BYTES ONLINE_STA
---------- ---------------------------------------------------------------------- ---------- ----------
2 +DG_ORA/ora01/ora_sysaux 1.0737E+10 ONLINE
33 +DG_ORA/ora01/ora_sysaux2.dbf 1.0737E+10 ONLINE
34 +DG_ORA/ora01/ora_sysaux3.dbf 3221225472 ONLINE
35 +DG_ORA/ora01/ora_sysaux4.dbf 3221225472 ONLINE
36 +DG_ORA/ora01/ora_sysaux5.dbf 3221225472 ONLINE
37 +DG_ORA/ora01/ora_sysaux6.dbf 3221225472 ONLINE
38 +DG_ORA/ora01/ora_sysaux7.dbf 3221225472 ONLINE
39 +DG_ORA/ora01/ora_sysaux1.dbf 5368709120 ONLINE
40 /oracle/app/product/11.2.0.4/db/dbs/DG_DATA 2097152 ONLINE
41 +DG_ORA/ora01/ora_sysaux8.dbf 5368709120 ONLINE
10 rows selected.
1. Find out the exact file name, file location, size and file number:
select file_id, file_name, bytes, online_status from dba_data_files where tablespace_name = 'SYSAUX';
SQL> select file_id, file_name, bytes, online_status from dba_data_files where tablespace_name = 'SYSAUX';
FILE_ID FILE_NAME BYTES ONLINE_
---------- ---------------------------------------------------------------------- ---------- -------
2 +DG_ORA/ora01/ora_sysaux 1.0737E+10 ONLINE
33 +DG_ORA/ora01/ora_sysaux2.dbf 1.0737E+10 ONLINE
34 +DG_ORA/ora01/ora_sysaux3.dbf 3221225472 ONLINE
35 +DG_ORA/ora01/ora_sysaux4.dbf 3221225472 ONLINE
36 +DG_ORA/ora01/ora_sysaux5.dbf 3221225472 ONLINE
37 +DG_ORA/ora01/ora_sysaux6.dbf 3221225472 ONLINE
38 +DG_ORA/ora01/ora_sysaux7.dbf 3221225472 ONLINE
39 +DG_ORA/ora01/ora_sysaux1.dbf 5368709120 ONLINE
40 /oracle/app/product/11.2.0.4/db/dbs/DG_DATA 2097152 ONLINE
41 +DG_ORA/ora01/ora_sysaux8.dbf 5368709120 ONLINE
10 rows selected.
select file_id, file_name, online_status from dba_data_files where file_id=40;
FILE_ID FILE_NAME ONLINE_
---------- ---------------------------------------------------------------------- -------
40 /oracle/app/product/11.2.0.4/db/dbs/DG_DATA ONLINE
2. Put the datafile offline
SQL> alter database datafile 40 offline;
Database altered.
SQL>
3. Recreate the datafile on the shared storage, please note that you need to do this on the node where the physical file resides
and you need to specify the size retrieved in step 1
SQL> alter database create datafile '/oracle/app/product/11.2.0.4/db/dbs/DG_DATA' as '+DG_DATA' size 2097152;
encounter this error:
SQL> alter database create datafile '/oracle/app/product/11.2.0.4/db/dbs/DG_DATA' as '+DG_DATA' size 2097152;
alter database create datafile '/oracle/app/product/11.2.0.4/db/dbs/DG_DATA' as '+DG_DATA' size 2097152
*
ERROR at line 1:
ORA-01136: specified size of file 40 (256 blocks) is less than original size of 64000 blocks
ORA-01110: data file 40: '/oracle/app/product/11.2.0.4/db/dbs/DG_DATA'
SQL>
NB: if you encounter above error, just increase the size small, in this case, the size was 2mb and I increased it to 500m and it worked fine.
this work:
SQL> alter database create datafile '/oracle/app/product/11.2.0.4/db/dbs/DG_DATA' as '+DG_DATA' size 500m;
Database altered.
SQL>
4. Recover the datafile
SQL> recover datafile 40;
Media recovery complete.
SQL>
5. Place the datafile back online
SQL> alter database datafile 40 online;
Database altered.
SQL>
Note: In some specific or particular case the end-user might copy the physical file by mistake again to another physical location on the same or another node. When perfoming the solution there is no risk in data lost between the different versions of the physical files because the 'alter database create datafile ', always recovers starting from the online redolog that was current at the moment the datafile was created originally, so it doesn't matter what happend with the datafile in between as long as we have all the archive logs since the datafile creation.
SQL> select file_id, file_name, bytes, online_status from dba_data_files where tablespace_name = 'SYSAUX';
FILE_ID FILE_NAME BYTES ONLINE_
---------- ---------------------------------------------------------------------- ---------- -------
2 +DG_ORA/ora01/ora_sysaux 1.0737E+10 ONLINE
33 +DG_ORA/ora01/ora_sysaux2.dbf 1.0737E+10 ONLINE
34 +DG_ORA/ora01/ora_sysaux3.dbf 3221225472 ONLINE
35 +DG_ORA/ora01/ora_sysaux4.dbf 3221225472 ONLINE
36 +DG_ORA/ora01/ora_sysaux5.dbf 3221225472 ONLINE
37 +DG_ORA/ora01/ora_sysaux6.dbf 3221225472 ONLINE
38 +DG_ORA/ora01/ora_sysaux7.dbf 3221225472 ONLINE
39 +DG_ORA/ora01/ora_sysaux1.dbf 5368709120 ONLINE
40 +DG_DATA/ora01/datafile/sysaux.277.1125845945 2097152 ONLINE
41 +DG_ORA/ora01/ora_sysaux8.dbf 5368709120 ONLINE
10 rows selected.
SQL>
Comments
Post a Comment