One datafile
~~~~~~~~~~~~
New Method :
----------
RMAN> REPORT SCHEMA;
RMAN> sql 'alter database datafile 5 offline';
RMAN> BACKUP AS COPY DATAFILE 4 FORMAT '+TEST';
RMAN> switch datafile 4 to COPY;
RMAN> REPORT SCHEMA;
Old Method :
----------
RMAN> report schema;
RMAN> sql 'alter database datafile 5 offline';
RMAN> copy datafile '+DG1/odb/datafile/t1.256.617493211' to '+DATA';
RMAN> switch datafile '+DG1/odb/datafile/t1.256.617493211' to COPY;
RMAN> report schema;
Or
SQL> ALTER DATABASE DATAFILE '+DG1/PRODDB/datafile/users.268.639139571' OFFLINE;
RMAN> COPY DATAFILE '+DG_D1/PRODDB/datafile/users.268.639139571' TO '+DG2';
Note the output filename path
SQL> ALTER DATABASE RENAME FILE '+DG1/PRODDB/datafile/users.268.639139571' TO '+DG2/PRODDB/datafile/users.260.640518077'
RMAN> SWITCH DATAFILE '+DG2/PRODDB/datafile/users.260.640518071' TO COPY;
SQL> RECOVER DATAFILE '+DG2/PRODDB/datafile/users.260.640518077';
SQL> ALTER DATABASE DATAFILE '+DG2/PRODDB/datafile/users.260.640518077' ONLINE;
Whole database
~~~~~~~~~~~~~~
SQL> alter system set db_create_file_dest=’+DATA’ scope=spfile;
SQL> alter system reset control_files scope=spfile sid=’*';
$ rman target /
RMAN> startup nomount
RMAN> restore controlfile from ‘/oradata/d01/control01.ctl’;
RMAN> alter database mount;
RMAN> backup as copy database format ‘+DATA’;
RMAN> switch database to copy;
RMAN> alter database open;
SQL> alter tablespace temp add tempfile size 500M;
Bkup files movement from ASM on one server to ASM on other server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SQL> create database link db1_to_db2 connect to system identified by oracle using ‘db2_tnsentry′;
SQL> exec dbms_file_transfer.put_file(‘db1_source_dir′,’users.260.778251563'′,’db2_dest_dir′,’users.260.77825156','db2_databasename')
11g method
~~~~~~~~~~
11g_ASMCMD> Cp [Srcfile] Username@Hostname.SID.Port:path
11g_ASMCMD> Cp +FRA/SID/ARCHIVELOG/Thread_1_seq_204982.1897.709557909 Sys@ORCL.+ASM: +FRA/SID/ARCHIVELOG/Thread_1_seq_204982
Move redologs to ASM
====================
SQL> alter system set db_create_online_log_dest_1=’+RECO’ scope=spfile;
SQL> alter system reset control_files scope=spfile sid=’*';
Let's say group 1 and group 2 is INACTIVE and group 3 is CURRENT (i.e required for recovery)
SQL> alter database drop logfile group 1; and then SQL> alter database add logfile group 1 size 50M;
SQL> alter database drop logfile group 2; and then SQL> alter database add logfile group 2 size 50M;
SQL> alter system switch logfile;
SQL> alter system checkpoint;
alter database drop logfile group 3; and then SQL> alter database add logfile group 3 size 50M;
Migrate all files to ASM using RMAN
1. Take full backup before starting
RMAN> startup mount
RMAN> backup database format '/u01/app/grid/backup_mgmtdb/rman_mgmtdb_%U' tag='bk_db_move_dg';
2. Move spfile
RMAN> restore spfile to ‘+dg1′';
RMAN> shutdown immediate;
RMAN> startup
3.Migrate control file :
SQL> show parameter control_file
SQL> alter system set controlfiles=’+dg1′,’+dg2′ scope=spfile;
SQL> shutdown immediate;
SQL> startup nomount;
RMAN> restore controlfile from ‘location shown in show parameter control_file command ’;
RMAN> startup mount
4.Migrate all datafiles:
SQL> shutdown immediate;
SQL> startup mount;
RMAN> backup as copy database format ‘+dg1′';
RMAN> switch database to copy;
RMAN> report schema;
5. Recreate temp files ( a or b )
a.RMAN> run {
SET NEWNAME FOR TEMPFILE 1 TO '+dg1';
SWITCH TEMPFILE ALL;
}
RMAN> startup or SQL> alter database open;
b. SQL> alter tablespace temp add tempfile size 500M;
6. Delete old files
RMAN> delete copy ;
~~~~~~~~~~~~
New Method :
----------
RMAN> REPORT SCHEMA;
RMAN> sql 'alter database datafile 5 offline';
RMAN> BACKUP AS COPY DATAFILE 4 FORMAT '+TEST';
RMAN> switch datafile 4 to COPY;
RMAN> REPORT SCHEMA;
RMAN> sql “alter tablespace tbspace offline”;
RMAN> copy datafile ‘/data1/tbspace_01.dbf’ to ‘+DATA’;
RMAN> sql “alter tablespace tbspace online”;
SQL> select name from v$datafile;
RMAN> copy datafile ‘/data1/tbspace_01.dbf’ to ‘+DATA’;
RMAN> sql “alter tablespace tbspace online”;
SQL> select name from v$datafile;
Old Method :
----------
RMAN> report schema;
RMAN> sql 'alter database datafile 5 offline';
RMAN> copy datafile '+DG1/odb/datafile/t1.256.617493211' to '+DATA';
RMAN> switch datafile '+DG1/odb/datafile/t1.256.617493211' to COPY;
RMAN> report schema;
Or
SQL> ALTER DATABASE DATAFILE '+DG1/PRODDB/datafile/users.268.639139571' OFFLINE;
RMAN> COPY DATAFILE '+DG_D1/PRODDB/datafile/users.268.639139571' TO '+DG2';
Note the output filename path
SQL> ALTER DATABASE RENAME FILE '+DG1/PRODDB/datafile/users.268.639139571' TO '+DG2/PRODDB/datafile/users.260.640518077'
RMAN> SWITCH DATAFILE '+DG2/PRODDB/datafile/users.260.640518071' TO COPY;
SQL> RECOVER DATAFILE '+DG2/PRODDB/datafile/users.260.640518077';
SQL> ALTER DATABASE DATAFILE '+DG2/PRODDB/datafile/users.260.640518077' ONLINE;
Whole database
~~~~~~~~~~~~~~
SQL> alter system set db_create_file_dest=’+DATA’ scope=spfile;
SQL> alter system reset control_files scope=spfile sid=’*';
$ rman target /
RMAN> startup nomount
RMAN> restore controlfile from ‘/oradata/d01/control01.ctl’;
RMAN> alter database mount;
RMAN> backup as copy database format ‘+DATA’;
RMAN> switch database to copy;
RMAN> alter database open;
SQL> alter tablespace temp add tempfile size 500M;
Bkup files movement from ASM on one server to ASM on other server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SQL> create database link db1_to_db2 connect to system identified by oracle using ‘db2_tnsentry′;
SQL> exec dbms_file_transfer.put_file(‘db1_source_dir′,’users.260.778251563'′,’db2_dest_dir′,’users.260.77825156','db2_databasename')
11g method
~~~~~~~~~~
11g_ASMCMD> Cp [Srcfile] Username@Hostname.SID.Port:path
11g_ASMCMD> Cp +FRA/SID/ARCHIVELOG/Thread_1_seq_204982.1897.709557909 Sys@ORCL.+ASM: +FRA/SID/ARCHIVELOG/Thread_1_seq_204982
Move redologs to ASM
====================
SQL> alter system set db_create_online_log_dest_1=’+RECO’ scope=spfile;
SQL> alter system reset control_files scope=spfile sid=’*';
Let's say group 1 and group 2 is INACTIVE and group 3 is CURRENT (i.e required for recovery)
SQL> alter database drop logfile group 1; and then SQL> alter database add logfile group 1 size 50M;
SQL> alter database drop logfile group 2; and then SQL> alter database add logfile group 2 size 50M;
SQL> alter system switch logfile;
SQL> alter system checkpoint;
alter database drop logfile group 3; and then SQL> alter database add logfile group 3 size 50M;
Migrate all files to ASM using RMAN
1. Take full backup before starting
RMAN> startup mount
RMAN> backup database format '/u01/app/grid/backup_mgmtdb/rman_mgmtdb_%U' tag='bk_db_move_dg';
2. Move spfile
RMAN> restore spfile to ‘+dg1′';
RMAN> shutdown immediate;
RMAN> startup
3.Migrate control file :
SQL> show parameter control_file
SQL> alter system set controlfiles=’+dg1′,’+dg2′ scope=spfile;
SQL> shutdown immediate;
SQL> startup nomount;
RMAN> restore controlfile from ‘location shown in show parameter control_file command ’;
RMAN> startup mount
4.Migrate all datafiles:
SQL> shutdown immediate;
SQL> startup mount;
RMAN> backup as copy database format ‘+dg1′';
RMAN> switch database to copy;
RMAN> report schema;
5. Recreate temp files ( a or b )
a.RMAN> run {
SET NEWNAME FOR TEMPFILE 1 TO '+dg1';
SWITCH TEMPFILE ALL;
}
RMAN> startup or SQL> alter database open;
b. SQL> alter tablespace temp add tempfile size 500M;
6. Delete old files
RMAN> delete copy ;