SQL> alter tablespace SYSAUX add datafile ' +DATA' size 100m;
Tablespace altered.
-----above i have given space before diskgroup name. this way datafile will create inside '$ORACLE_HOME/dba'
SQL> select NAME,FILE# from v$datafile where FILE#='43';
NAME
--------------------------------------------------------------------------------
FILE#
----------
/XXX/oracle/database/11.2.0/dbs/ +DATA
43
------- Above we can see new datafile name is '/XXX/oracle/database/11.2.0/dbs/ +DATA' now we are sure it's abnormal behavior .
-- check some more detail using Praveen sql -
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
/XXX/oracle/database/11.2.0/dbs/ +DATA
MONDAY 21-OCT-13 01:57:20 ONLINE
SYSAUX
---now i can sure we have same situation as corp_bsm2 have . let fix this now ,
Makeing 43 datafile ID offline.
SQL> alter database datafile 43 offline;
Database altered.
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS tablespace name
--------------------------------------------------- ------- ------------------------------
43
/XXX/oracle/database/11.2.0/dbs/ +DATA
MONDAY 21-OCT-13 01:57:20 RECOVER SYSAUX
-- After keeping data file offline it went RECOVER mode,
SQL>
----Connect to target database using RMAN , (Here catalog connection not required) Then take a copy of that datafile into '+DATA' DG.
RMAN> backup as copy datafile 43 format '+DATA';
Starting backup at 21-OCT-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=105 instance=XXX2 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=123 instance=XXX2 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00043 name=/XXX/oracle/database/11.2.0/dbs/ +DATA
output file name=+DATA/XXX/datafile/sysaux.831.829361111 tag=TAG20131021T020510 RECID=1 STAMP=829361111
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 21-OCT-13
---Now wrongly created datafile got plugged into ASM storage, lets update controlfile with new datafile location.
RMAN> switch datafile 43 to copy;
datafile 43 switched to datafile copy "+DATA/XXX/datafile/sysaux.831.829361111"
Ctl file also updated .
SQL> select name from v$datafile where file#=43;
NAME
--------------------------------------------------------------------------------
+DATA/XXX/datafile/sysaux.831.829361111
SQL>
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
+DATA/XXX/datafile/sysaux.831.829361111
MONDAY 21-OCT-13 01:57:20 RECOVER
SYSAUX
-- now recover datafile ,
SQL> recover datafile 43;
Media recovery complete.
-- keep again datafile to online/normal mode
SQL> alter database datafile 43 online;
Database altered.
-- At last check dafile status .
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
+DATA/XXX/datafile/sysaux.831.829361111
MONDAY 21-OCT-13 01:57:20 ONLINE
SYSAUX
SQL>
Now we can manually remove that old datafile located in $ORACLE_HOME/dbs directory.
Tablespace altered.
-----above i have given space before diskgroup name. this way datafile will create inside '$ORACLE_HOME/dba'
SQL> select NAME,FILE# from v$datafile where FILE#='43';
NAME
--------------------------------------------------------------------------------
FILE#
----------
/XXX/oracle/database/11.2.0/dbs/ +DATA
43
------- Above we can see new datafile name is '/XXX/oracle/database/11.2.0/dbs/ +DATA' now we are sure it's abnormal behavior .
-- check some more detail using Praveen sql -
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
/XXX/oracle/database/11.2.0/dbs/ +DATA
MONDAY 21-OCT-13 01:57:20 ONLINE
SYSAUX
---now i can sure we have same situation as corp_bsm2 have . let fix this now ,
Makeing 43 datafile ID offline.
SQL> alter database datafile 43 offline;
Database altered.
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS tablespace name
--------------------------------------------------- ------- ------------------------------
43
/XXX/oracle/database/11.2.0/dbs/ +DATA
MONDAY 21-OCT-13 01:57:20 RECOVER SYSAUX
-- After keeping data file offline it went RECOVER mode,
SQL>
----Connect to target database using RMAN , (Here catalog connection not required) Then take a copy of that datafile into '+DATA' DG.
RMAN> backup as copy datafile 43 format '+DATA';
Starting backup at 21-OCT-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=105 instance=XXX2 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=123 instance=XXX2 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00043 name=/XXX/oracle/database/11.2.0/dbs/ +DATA
output file name=+DATA/XXX/datafile/sysaux.831.829361111 tag=TAG20131021T020510 RECID=1 STAMP=829361111
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 21-OCT-13
---Now wrongly created datafile got plugged into ASM storage, lets update controlfile with new datafile location.
RMAN> switch datafile 43 to copy;
datafile 43 switched to datafile copy "+DATA/XXX/datafile/sysaux.831.829361111"
Ctl file also updated .
SQL> select name from v$datafile where file#=43;
NAME
--------------------------------------------------------------------------------
+DATA/XXX/datafile/sysaux.831.829361111
SQL>
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
+DATA/XXX/datafile/sysaux.831.829361111
MONDAY 21-OCT-13 01:57:20 RECOVER
SYSAUX
-- now recover datafile ,
SQL> recover datafile 43;
Media recovery complete.
-- keep again datafile to online/normal mode
SQL> alter database datafile 43 online;
Database altered.
-- At last check dafile status .
SQL> select d.file#,d.name "file name",to_char(d.CREATION_TIME,'DAYDD-MON-YY HH:MI:ss'),d.STATUS,t.NAME "tablespace name" from v$datafile d,v$tablespace t where d.FILE#=43 and d.TS#=t.TS#;
FILE#
----------
file name
--------------------------------------------------------------------------------
TO_CHAR(D.CREATION_TIME,'DAYDD-MON-YYHH:MI:SS') STATUS
--------------------------------------------------- -------
tablespace name
------------------------------
43
+DATA/XXX/datafile/sysaux.831.829361111
MONDAY 21-OCT-13 01:57:20 ONLINE
SYSAUX
SQL>
Now we can manually remove that old datafile located in $ORACLE_HOME/dbs directory.
No comments:
Post a Comment