Thursday, June 6, 2013

Rename the Datafile on Primary and Standby Database

Recently I encountered an issue over my Production Environment where I was unable to rename the datafile on Standby Database.
While trying to take the Tablespace OFFLINE, oracle was throwing me error as " ORA-16000: database open for read-only access".

Following are the steps which I had performed to Rename the datafiles over Primary as well as Standby databases.

At Primary Database.

SQL> SHOW PARAMETER STANDBY_FILE_MANAGEMENT
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      AUTO

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;
System altered.

Now take the tablespace offline.
SQL> ALTER TABLESPACE XYZ OFFLINE;
Tablespace altered.

Rename the datafile through server level.
# mv /d3/u01/oradata/DB1/ABC_04.dbf /d3/u02/oradata/DB1/ABC_04.dbf

Rename the datafile through database sql prompt.
ALTER DATABASE RENAME FILE '/d3/u01/oradata/DB1/ABC_04.dbf' TO '/d3/u02/oradata/DB1/ABC_04.dbf';

Now bring the tablespace ONLINE.
SQL> ALTER TABLESPACE XYZ ONLINE;

At Standby Database.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;
System altered.

Shut down the database. 
SQL> SHUT IMMEDIATE;

Rename the datafile at OS level.
# mv /d3/u01/oradata/DB1/ABC_04.dbf /d3/u02/oradata/DB1/ABC_04.dbf

Start the standby databse in mount mode.
SQL> STARTUP MOUNT;

Rename the datafile through database level.
ALTER DATABASE RENAME FILE '/d3/u01/oradata/DB1/ABC_04.dbf' TO '/d3/u02/oradata/DB1/ABC_04.dbf';

Open the Standby Database .
SQL> ALTER DATABASE OPEN;

Start the standby managed recovery process.
SQL>RECOVER MANAGED STANDBY DATABASE DISCONNECT;

Now bring back the parameter setting to AUTO both on Primary and Standby databases.
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

Thanks for your time. Cheers!!!

2 comments: