Monday, December 8, 2014

Restore Archive Logs to New Location using RMAN

Oracle up to 10g

When attempting to restore archive logs that are already located on disk using RMAN you’ll receive an error if the archivelogs are stored within ASM because until Oracle 11g shipped you could not use the OS copy or move command to retrieve them.

The solution is to use RMAN to copy them from ASM to an OS filesystem:

RMAN> copy archivelog ‘+psdisk1/ORCLSID/archivelog/2008_10_30/thread_1_seq_2.245.88866622′ to ‘/tmp/oraclearchive’;

You would have to repeat this command for each archive log to be copied or try the following solution:

RMAN> change archivelog from logseq=60 until logseq=70 uncatalog;

Once the archivelos have been successfully uncataloged you are now able to successfully restore the archive logs to a new location.

RMAN> run {
set archivelog destination to ‘/tmp’;
restore archivelog from logseq=60 until logseq=70;
}

Following the successful restore of the archivelogs you can then continue to recatalog the archivelogs back into the ASM diskgroup.

Example:

RMAN> catalog archivelog ‘+psdisk1/ORCLSID/archivelog/2008_10_30/thread_1_seq.60.245.888666222′;

How To Move Datafile from a File System to ASM
Up to 10g R2:

Moving a datafile from the file system can be achieved in two ways:

1. While the database is in shutdown or mount stage
2. While the database is running with the select tablespace offline

Moving an Oracle datafile is in mount state is performed in the following way:

1. Shutdown and mount the database

SQL> shutdown immediate;
SQL> startup mount;

Check disk space in the ASM diskgroup you want to copy the datafile to:

SQL> select file#, name, (bytes/1048576) File_size_MB from v$datafile;

export ORACLE_SID=+ASM

SQL> select name, state, total_mb, free_mb from v$asm_diskgroup;

$ rman target=/
RMAN> copy datafile 4 to ‘+psdisk2′;

Update the controlfile with the new location of the datafile:

$ rman target /
RMAN> switch datafile 4 to copy;

The file is now in the new location;

SQL> select name from v$datafile;

The database may now be opened.

While the Database is Running (with the selected tablespace offline)
In order to move a datafile on a running active database, the tablespace where the datafile resides must be placed offline first. Identify the tablespace which contains the datafile and offline that tablespace.

SQL> select tablespace_name, file_name from dba_data_files where file_id=4;
SQL> alter tablespace users offline;

After you have taken the tablespace offline you can execute the same steps above for copying the datafile to the ASM Diskgroup and then put the tablespace back online.

No comments:

Post a Comment

Followers