Here I am going to share the possible methods of copy DB related files (datafiles,backup pieces, Archived log files) from ASM storage to regular file system storage(non-ASM).
Many cases you might be required to copy ths files from ASM diskgroup to normal file system.Like,If your primary DB is using ASM and standby is on normal file system, some times you may need to manually copy the archived log fies to standby and register them. Or you may be migrating your daabase from ASM to non-ASM and vice versa.
Method1:(From 11g)
From 11g the asmcmd cp command allows files to be copied between ASM and local or remote destinations. The summary usage is shown below.
cp [-ifr] <[\@connect_identifier:]src> <[\@connect_identifier:]tgt>
Example:
ASMCMD> ls -lt
Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE DEC 31 13:00:00 Y userdata01.256.739191187
ASMCMD> cp userdata01.256.739191187 /u01/datafiles/userdata01.dbf
copying +dg1/testdb/datafile/ userdata01.256.739191187 -> /u01/datafiles/userdata01.dbf
ASMCMD>
[oracle]$ ls -lrt
total 525208
-rw-r—– 1 oracle oinstall 314580992 Dec 31 13:17 userdata01.dbf
Method2:
Using copy command:SQL> select file_name,status from dba_data_files where file_id=8;
FILE_NAME STATUS
————————————————– ———
+DG1/testdb/datafile/ts1.256.739204397 AVAILABLE
Recovery Manager: Release 11.2.0.1.0 – Production on Fri Dec 31 14:34:15 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: TESTDB (DBID=2521935115)
using target database control file instead of recovery catalog
RMAN> copy datafile 8 to ‘/u01/datafiles/ts1.dbf’;
Starting backup at 31-DEC-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+DG1/testdb/datafile/ts1.256.739204397
output file name=/u01/datafiles/ts1.dbf tag=TAG20101231T143435 RECID=7 STAMP=739204478
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 31-DEC-10
RMAN>
[oracle@dhcppc1 datafiles]$ ls -lrt
total 525208
-rw-r—– 1 oracle dba 314580992 Dec 31 14:40 ts1.dbf
To copy the archived log files from ASM to non-ASM
Take RMAN backup of required archive log files to temp location
run {
allocate channel ch1 type disk format '/tmp/arc_%U';
backup archivelog from logseq 250 until logseq 301 thread 1
}
cd /tmp
Then, one can restore archive logs that are already located on a filesystem using restore command:
run {
set archivelog destination to '/tmp';
restore archivelog all;
}
Method3: Using DBMS_FILE_TRANSFER package:
Create DB dirtectories and connect DB instance
SQL> create directory ASM_DIR as ‘+DG1/testdb/datafile/’;
Directory created.
SQL> create directory TARGET_DIR as ‘/u01/datafiles/’;
Directory created.
SQL> BEGIN
dbms_file_transfer.copy_file(source_directory_object =>
‘ASM_DIR’, source_file_name => ‘ts1.256.739191187′,
destination_directory_object => ‘TARGET_DIR’,
destination_file_name => ‘ts1.dbf’);
END;
/
SQL> !ls -lrt /u01/datafiles/
total 307512
-rw-r—– 1 oracle dba 314580992 Dec 31 13:12 ts1.dbf
or
exec DBMS_FILE_TRANSFER.COPY_FILE('ASM_DIR','thread_1_seq_132551.4311.811375563','TARGET_DIR','w071u_1_132551_490438739.dbf');
No comments:
Post a Comment