Skip to content
Home » Oracle Database » Copy File from ASM to Filesystem or ASM

Copy File from ASM to Filesystem or ASM

ASMCMD

ASM in Oracle 11g grid infrastructure has been improved a lot on the storage operations. For instance, the utility ASMCMD (ASM Command-Line) offers several new commands to operate with the storage and make DBA more easily control the storage, especially on copying files, the cp command. The syntax of cp is

cp [-i][-f][connect_str:]src_file [connect_str:]tgt_file

In the syntax description, "connect_str" is the ASM instance that you want to connect to. The format of the connection string is as:

user@host[.port_number].SID

Now, let's learn some cases from the simplest to the hardest.

  1. Among Disk Groups
  2. ASM to OS or Vice Versa
  3. From ASM to ASM

Between Disk Groups

If you want to copy files between disk groups, you can do this:

ASMCMD> cp +DATA/ORCLCDB/spfile +DATA2/TESTCDB/
copying +DATA/ORCLCDB/spfile -> +DATA2/TESTCDB/spfile

ASM to Filesystem or Vice Versa

1. Copy ASM to Filesystem

This is the easiest pattern of copying a file from ASM. Here we copy SPFILE out of ASM.

[grid@primary01 ~]$ asmcmd cp +DATA/ORCLCDB/spfile /tmp/
copying +DATA/ORCLCDB/spfile -> /tmp/spfile
[grid@primary01 ~]$ ll /tmp/spfile
-rw-r----- 1 grid oinstall 4608 Jan 22 16:15 /tmp/spfile

2. Copy Filesystem to ASM

Here we copy controlfile into ASM.

[grid@standby01 ~]$ asmcmd cp /tmp/standby.ctl +DATA/ORCLCDB/control01.ctl
copying /tmp/standby.ctl -> +DATA/ORCLCDB/control01.ctl
[grid@standby01 ~]$ asmcmd cp /tmp/standby.ctl +DATA/ORCLCDB/control02.ctl
copying /tmp/standby.ctl -> +DATA/ORCLCDB/control02.ctl
[grid@standby01 ~]$ asmcmd cp /tmp/standby.ctl +DATA/ORCLCDB/control03.ctl
copying /tmp/standby.ctl -> +DATA/ORCLCDB/control03.ctl
[grid@standby01 ~]$ asmcmd ls -l +DATA/ORCLCDB/control*.ctl
Type         Redund  Striped  Time             Sys  Name
CONTROLFILE  UNPROT  FINE     AUG 26 12:00:00  N    control01.ctl => +DATA/ORCLCDB/CONTROLFILE/Current.261.1078753717
CONTROLFILE  UNPROT  FINE     AUG 26 12:00:00  N    control02.ctl => +DATA/ORCLCDB/CONTROLFILE/Current.262.1078753717
CONTROLFILE  UNPROT  FINE     AUG 26 12:00:00  N    control03.ctl => +DATA/ORCLCDB/CONTROLFILE/Current.263.1078753717

In fact, copying a standby controlfile like the above is not a good practice, you should use RESTORE CONTROLFILE FROM of RMAN command at NOMOUNT state to copy the standby controlfile back to ASM.

From ASM to ASM

Now, let's demonstrate how to copy backup files from a remote ASM instance to local ASM with an example below:

[oracle@standby02 ~]$ asmcmd
ASMCMD> cp [email protected].+ASM2:+DATA/primdb/backupset/2013_01_23/nnndf0_tag20130123t100747_0.1111.805457271 +DATA/backup/database.bak
Enter password: **********
ASMCMD>

In the above statement, [email protected].+ASM2 is the connection string, in which, sys is the username, primary02-vip is the hostname, 1521 is the listener port, and +ASM2 is the instance sid.

Leave a Reply

Your email address will not be published. Required fields are marked *