In this post we'll consider some examples of ASMCMD usage.
First of all, we should bring an ASM instance up.
[oracle@localhost ~]$ cat do_asm
export ORACLE_SID=+ASM
export ORACLE_BASE=/u01/app/oracle/product/11.1.0
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/asm
[oracle@localhost ~]$ source ~/do_asm
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ASM instance started
Total System Global Area 284565504 bytes
Fixed Size 1299428 bytes
Variable Size 258100252 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> exit
Further, we'll consider different types of asmcmd command usage.
1. Enter ASMCMD:
[oracle@localhost ~]$ asmcmd
ASMCMD>
2. To list files/diskgroups in the current directory:
ASMCMD> ls
DATA/
DG_RECOV/
the same, but using wildcard(s):
ASMCMD> ls /*/*
+DATA/MYASMDB/ARCHIVELOG/2011_09_10/:
thread_1_seq_10.303.761509543
thread_1_seq_11.308.761510355
thread_1_seq_12.313.761511001
thread_1_seq_4.270.761501055
thread_1_seq_5.277.761503847
thread_1_seq_6.284.761503927
thread_1_seq_7.293.761504137
thread_1_seq_8.294.761504141
thread_1_seq_9.298.761507015
Current.260.760123743
Current.261.760123739
SYSAUX.257.760123487
SYSTEM.256.760123483
TEMP.268.760123809
UNDOTBS1.258.760123489
USERS.259.760123489
group_1.262.760123749
group_1.263.760123751
group_2.264.760123759
group_2.265.760123761
group_3.266.760123763
group_3.267.760123763
spfile.269.760123983
ASMCMD>
3. To navigate ASM directory:
ASMCMD> cd DATA/
ASMCMD> cd ..
4. To see the path of the current ASM directory:
ASMCMD> pwd
+DATA/MYASMDB
5. To create ASM directories:
ASMCMD> ls
MYASMDB/
STANDBY1/
ASMCMD> mkdir MyTest1
ASMCMD> ls
MYASMDB/
MyTest1/
STANDBY1/
ASMCMD>
6. The directories names are case insensitive:
ASMCMD> cd MYT*
ASMCMD> pwd
+DATA/MyTest1
ASMCMD>
7. To remove ASM directory:
ASMCMD> rm MYTEST1
ASMCMD> ls
MYASMDB/
STANDBY1/
ASMCMD>
8. List files and display their size and some extended information:
ASMCMD> ls -ls
Type Redund Striped Time Sys Block_Size Blocks Bytes Space Name
DATAFILE UNPROT COARSE SEP 10 18:00:00 Y 8192 73337 600776704 601882624 SYSAUX.257.760123487
DATAFILE UNPROT COARSE SEP 10 18:00:00 Y 8192 88321 723525632 725614592 SYSTEM.256.760123483
DATAFILE UNPROT COARSE SEP 10 18:00:00 Y 8192 5121 41951232 42991616 UNDOTBS1.258.760123489
DATAFILE UNPROT COARSE SEP 10 18:00:00 Y 8192 641 5251072 6291456 USERS.259.760123489
9. Search the specified directory and all subdirectories in the ASM directory tree for the supplied name:
ASMCMD> find +DATA control*
+DATA/MYASMDB/CONTROLFILE/
+DATA/STANDBY1/CONTROLFILE/
ASMCMD>
ASMCMD> find -t CONTROLFILE +data *
+data/MYASMDB/CONTROLFILE/Current.260.760123743
+data/MYASMDB/CONTROLFILE/Current.261.760123739
+data/STANDBY1/CONTROLFILE/cf1
+data/STANDBY1/CONTROLFILE/current.271.761503123
+data/STANDBY1/CONTROLFILE/current.272.761503687
ASMCMD>
The -t flag tells to search for particular type of file(s), for example, CONTROLFILE.
The values for -t flag can be found in the type column of the V$ASM_FILE dictionary view.
10. Copy within ASM directory tree:
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfilemyasmdb.ora
ASMCMD> pwd
+DATA/MYASMDB
ASMCMD> cp +DATA/MYASMDB/spfilemyasmdb.ora +DATA/MYASMDB/copy_spfilemyasmdb.ora
source +DATA/MYASMDB/spfilemyasmdb.ora
target +DATA/MYASMDB/copy_spfilemyasmdb.ora
copying file(s)...
file, +DATA/myasmdb/copy_spfilemyasmdb.ora, copy committed.
ASMCMD> ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
copy_spfilemyasmdb.ora
spfilemyasmdb.ora
ASMCMD>
11. External copy, from ASM to OS filesystem:
ASMCMD> cp +DATA/MYASMDB/spfilemyasmdb.ora /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora
source +DATA/MYASMDB/spfilemyasmdb.ora
target /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora
copying file(s)...
file, /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora, copy committed.
ASMCMD> exit
[oracle@localhost ~]$ ll /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora
-rw-r----- 1 oracle oinstall 3584 Mon dd hh:mm /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora
[oracle@localhost ~]$
12. The opposite way, copy from OS filesystem to ASM will not work:
ASMCMD> cp /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora +DATA/MYASMDB/asm_copy_spfilemyasmdb.ora
source /u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora
target +DATA/MYASMDB/asm_copy_spfilemyasmdb.ora
ASMCMD-08012: can not determine file type for file->'/u01/app/oracle/product/11.1.0/asm/dbs/os_copy_spfilemyasmdb.ora'
ORA-15056: additional error message
ORA-19762: invalid file type DGGetFileAttr20
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 207
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD>
No comments:
Post a Comment