Monday, September 14, 2020

How to Rename or Move Redo log files in Oracle

 

How to Rename or Move Redo log files in Oracle


It is possible to move/rename the online redo logs should the need arise. This document will detail the steps required to move/rename the online redo logs in an 12cR2 environment on Linux. These steps also apply to a 10g, and 11gR2 environment.


First we will verify the current location of the online redo log files :


SQL>
SQL>
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/redo03.log
/u01/app/oracle/oradata/ORCL/redo02.log
/u01/app/oracle/oradata/ORCL/redo01.log




We are going to move the online redo logs from /u01/app/oracle/oradata/ORCL/ to /u01/app/oracle/oradata/ORCL/redo/. The redo logs cannot be moved/renamed while the database is online. The database must be in a mount state to move/rename the online redo logs.


First we will shutdown the database and move the online redo logs to their new location :


SQL>
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@orakldba ~]$
[oracle@orakldba ~]$ mv /u01/app/oracle/oradata/ORCL/redo03.log /u01/app/oracle/oradata/ORCL/redo/redo03.log

[oracle@orakldba ~]$ mv /u01/app/oracle/oradata/ORCL/redo02.log /u01/app/oracle/oradata/ORCL/redo/redo02.log

[oracle@orakldba ~]$ mv /u01/app/oracle/oradata/ORCL/redo01.log /u01/app/oracle/oradata/ORCL/redo/redo01.log

[oracle@orakldba ~]$


Next we bring up the database into mount mode and issue ALTER DATABASE RENAME FILE statements to update the data dictionary and control files. The last thing we do is open the database.


SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area  536870912 bytes
Fixed Size                  8622776 bytes
Variable Size             448793928 bytes
Database Buffers           75497472 bytes
Redo Buffers                3956736 bytes
Database mounted.


SQL>
SQL>
SQL> alter database rename file '/u01/app/oracle/oradata/ORCL/redo03.log' to '/u01/app/oracle/oradata/ORCL/redo/redo03.log';

Database altered.


SQL>
SQL> alter database rename file '/u01/app/oracle/oradata/ORCL/redo02.log' to '/u01/app/oracle/oradata/ORCL/redo/redo02.log';

Database altered.


SQL>
SQL> alter database rename file '/u01/app/oracle/oradata/ORCL/redo01.log' to '/u01/app/oracle/oradata/ORCL/redo/redo01.log';

Database altered.


SQL>
SQL> alter database open;

Database altered.




We can see that the changes were made in the data dictionary by issuing the following query again.


SQL>
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL/redo/redo03.log
/u01/app/oracle/oradata/ORCL/redo/redo02.log
/u01/app/oracle/oradata/ORCL/redo/redo01.log

SQL>






I hope this article helped you. Your suggestions/feedback are most welcome.
Keep learning… Have a great day!!!

No comments:

Post a Comment