ORA-01157 is a common incident that happens when a DBA accidentally creates a datafile for a cluster database on the local file system of one of the nodes instead of creating on a shared file system or ASM. In this case, all instances other than the instance/node where fiel was locally created would report ORA-01157 and ORA-01110. Alert log file would show entires similar to the following.
Thu
May 03 03:52:58 2018 |
There are two ways to move this file to the
shared file system or ASM. First is by re-creating this datafile. I would
recommend you this method only if you have become aware of this mistake soon
after adding the datafile to the local file system of a RAC node. For example,
you realized your mistake within a few minutes or a couple of hours. In this
case, you may re-create your datafile on a shared file system or ASM (whatever
you are using) and perform recovery. If this datafile was created a few days
ago and then you realized the problem, I would suggest not use this method, but
a method I would explain later along with the reason of doing so
Recreating datafile on the correct location(Shared file system or ASM)
SQL>
select online_status,file_name,bytes from dba_data_files where file_id=15; |
Take datafile offline and recreate it to the correct location
SQL>
alter database datafile '/u01/app/oracle/product/12.2/db/dbs/mydata01.dbf''
offline; |
ORA-01136: specified size of file 207 (6400 blocks) is less than original size of 65536 blocks
You need to dspecify
exact size of dataile as returned in the first query above, otherwise you would
face ORA-01336 error. I tested this command in 12c without “size” clause, and
it worked perfectly fine. You need to use “size” clause in older than 12c
versions.
If you are using OMF
(Oracle managed files), you do not need to specify path after “as” clause as
Oracle already know where to create datafiles.
For ASM, only use ASM
diskgroup goroung without any path, after “as” clause.
SQL>
recover datafile 15; |
As I stated above, you could
use this method of recreating datafile only if you added datafile on local file
system very recently. If a couple of days or more have passed, this process
would need to restore all the archived log files since the datafile was created
and to recover the datafile. Therefore, if a lot of time has passed, create a copy
of this file on the shared file system or ASM using RMAN COPY command, and then
use RMAN SWITCH command to switch to copy. Following is the procedure to do
this.
SQL>
alter database datafile '/u01/app/oracle/product/12.2/db/dbs/mydata01.dbf''
offline; |
Copy datafile to the
shared file system or ASM. If you want to copy on ASM, you can use cp command
available in ASM. Copy to ASM would generated ASM compatible name of the
datafile.
Execute rename command, perform recovery and bring the file online.
SQL>
alter database rename file from '/u01/app/oracle/product/12.2/db/dbs/mydata01.dbf''
to ‘/u05/mydb/datafile/mydata01.dbf’; |
No comments:
Post a Comment