Sie sind auf Seite 1von 15

ASM HANDS-ON TRAINING

Lab 21 ASMCM Use And Options


Alejandro Vargas | Principal Support Consultant Oracle Advanced Customer Services

INDEX Summary.......................................................................................................................................................................2 Asmcmd -p....................................................................................................................................................................2 cp...................................................................................................................................................................................3 du...................................................................................................................................................................................5 find.................................................................................................................................................................................6 ls....................................................................................................................................................................................7 lsct.................................................................................................................................................................................8 md_backup and md_restore.......................................................................................................................................11 remap..........................................................................................................................................................................15 Other commands.........................................................................................................................................................15

1/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
Summary
On this lab we will review some of the useful set of commands provided by the ASM command line utility. Some of the asmcmd commands display information, these information is based on v$asm views, other commands actually make changes to the structure like mkdir or rm.

Asmcmd -p
Invoiking asmcmd with the p parameter enables showing the path at asmcmds prompt [oracle@asmxpt ~]$ asmcmd -p ASMCMD [+] > cd +DATADGER/SATI11/DATAFILE ASMCMD [+DATADGER/SATI11/DATAFILE] > ls SOE.270.679170079 SOEINDEX.271.679170087 SYSAUX.260.679144103 SYSTEM.259.679144027 UNDOTBS1.261.679144167 USERS.262.679144213

2/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
cp
To copy files from ASM to ASM or to ASM to File System or from File System to ASM. On this example we copy the controlfile to a backup directory ASMCMD> cd DATADGER/sati11/parameterfile ASMCMD> ls spfile.256.679143615 spfilesati11.ora ASMCMD> cp spfilesati11.ora /u01/app/oracle/BACKUP/sati11 copying +DATADGER/sati11/parameterfile/spfilesati11.ora -> /u01/app/oracle/BACKUP/sati11/spfilesati11.ora The cp command can be used also to copy files over the network, it accepts the following parameters -i Interactive, prompt before copy file or overwrite -f Force, if an existing destination file, remove it and try again without user interaction -r Recursive, copy forwarding sub-directories recursively On this example we make a backup of the whole database sati12 to FS, first we generate a script that contain copy commands. To generate the script we use from the OS prompt the asmcmd ls command with the full path top the datafile directory asmcmd ls DATADGCLN/sati11/datafile | awk '{print "asmcmd cp +DATADGCLN/sati11/datafile/"$1" /u01/app/oracle/BACKUP/sati12/"$1}' >asmcpfiles [oracle@asmxpt]$ mkdir /u01/app/oracle/BACKUP/sati12 [oracle@asmxpt sati12]$ asmcmd ls DATADGCLN/sati11/datafile | awk '{print "asmcmd cp 3/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
+DATADGCLN/sati11/datafile/"$1" /u01/app/oracle/BACKUP/sati12/"$1}' >asmcpfiles [oracle@asmxpt sati12]$ chmod 700 asmcpfiles [oracle@asmxpt sati12]$ ./asmcpfiles copying +DATADGCLN/sati11/datafile/SYSAUX.260.679144103 -> /u01/app/oracle/BACKUP/sati12/SYSAUX.260.679144103 copying +DATADGCLN/sati11/datafile/SYSTEM.259.679144027 -> /u01/app/oracle/BACKUP/sati12/SYSTEM.259.679144027 copying +DATADGCLN/sati11/datafile/UNDOTBS1.261.679144167 -> /u01/app/oracle/BACKUP/sati12/UNDOTBS1.261.679144167 copying +DATADGCLN/sati11/datafile/USERS.262.679144213 -> /u01/app/oracle/BACKUP/sati12/USERS.262.679144213 [oracle@asmxpt sati12]$ total 1971520 -rwx------ 1 oracle dba -rw-r----- 1 oracle dba -rw-r----- 1 oracle dba -rw-r----- 1 oracle dba -rw-r----- 1 oracle dba ls -l /u01/app/oracle/BACKUP/sati12 438 664477696 734011392 361766912 256581632 Feb Feb Feb Feb Feb 20 20 20 20 20 07:56 07:57 07:58 08:00 08:00 asmcpfiles SYSAUX.260.679144103 SYSTEM.259.679144027 UNDOTBS1.261.679144167 USERS.262.679144213

4/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
du
Display total space used for files on the current directory recursively. The output show two values, the first one is the total amount of data, and the second is this value multiplied by the number of mirrors, when using external redundancy both values will be the same. The H flag suppress the headers. Note that lsdg show the total and free space, while du shoe the used space and total space used by all mirrors if used. ASMCMD> lsdg
State MOUNTED MOUNTED MOUNTED Type EXTERN EXTERN EXTERN Rebal N N N Sector 512 512 512 Block 4096 4096 4096 AU 1048576 1048576 1048576 Total_MB 4094 4094 6141 Free_MB 1677 1482 2815 Req_mir_free_MB 0 0 0 Usable_file_MB 1677 1482 2815 Offline_disks 0 0 0 Name DATADGCLN/ DATADGER/ FRADG/

ASMCMD> du Used_MB Mirror_used_MB 8193 8193 ASMCMD> du -H 8193 8193 ASMCMD> du DATADGCLN/ Used_MB Mirror_used_MB 2364 2364 ASMCMD> du DATADGER/ Used_MB Mirror_used_MB 2559 2559 ASMCMD> du FRADG/ Used_MB Mirror_used_MB 3270 3270

5/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
find
Find permit to display file names stored on ASM according to file type or name pattern, the file types that can be used for searching are the following ARCHIVELOG, AUTOBACKUP, BACKUPSET, CHANGETRACKING, CONTROLFILE, DATAFILE, ONLINELOG, PARAMETERFILE and TEMPFILE The following command locates all spfiles on all directories. ASM root directory is indicated by the plus sign + ASMCMD> find + *spfile* +DATADGCLN/SATI11/PARAMETERFILE/spfile.256.679143615 +DATADGCLN/SATI11/PARAMETERFILE/spfilesati11.ora +DATADGER/SATI11/PARAMETERFILE/spfile.256.679143615 +DATADGER/SATI11/PARAMETERFILE/spfilesati11.ora The following command find all controlfiles on all directories under the root directory ASMCMD> find -t CONTROLFILE + * +DATADGCLN/SATI11/CONTROLFILE/current.257.679143905 +DATADGCLN/SATI11/CONTROLFILE/current.258.679143907 +DATADGCLN/SATI12/CONTROLFILE/Current.270.679159021 +DATADGCLN/SATI12/CONTROLFILE/Current.271.679159021 +DATADGER/SATI11/CONTROLFILE/current.257.679143905 +DATADGER/SATI11/CONTROLFILE/current.258.679143907

6/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
ls
ls can be used the same way as the OS ls command to list files and directory. There are several useful flags that can be used together with ls ls -l displays striping and redundancy information ls -s displays file space information. ls -d displays information about the directory ls -r sort the output in reverse order ls -t sorts the output by timestamp ls -L displays information about the file that referenced by an alias ls -a displays the absolute path of aliases ls -g includes the INST_ID useful on a cluster environment ls -H Does not display column headings.

ASMCMD> ls DATADGER/sati11/datafile SOE.270.679170079 SOEINDEX.271.679170087 SYSAUX.260.679144103 SYSTEM.259.679144027 UNDOTBS1.261.679144167 USERS.262.679144213 ASMCMD> ls -l DATADGER/sati11/datafile Type Redund Striped Time DATAFILE UNPROT COARSE FEB 19 20:00:00 DATAFILE UNPROT COARSE FEB 19 20:00:00 DATAFILE UNPROT COARSE FEB 20 13:00:00 DATAFILE UNPROT COARSE FEB 19 20:00:00 DATAFILE UNPROT COARSE FEB 19 20:00:00 7/15

Sys Y Y Y Y Y

Name SOE.270.679170079 SOEINDEX.271.679170087 SYSAUX.260.679144103 SYSTEM.259.679144027 UNDOTBS1.261.679144167

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
DATAFILE UNPROT COARSE FEB 19 20:00:00 Y USERS.262.679144213 ASMCMD> ls -s DATADGER/sati11/datafile Block_Size Blocks Bytes Space Name 8192 8202 67190784 69206016 SOE.270.679170079 8192 5121 41951232 42991616 SOEINDEX.271.679170087 8192 89993 737222656 739246080 SYSAUX.260.679144103 8192 89601 734011392 736100352 SYSTEM.259.679144027 8192 53121 435167232 437256192 UNDOTBS1.261.679144167 8192 31321 256581632 257949696 USERS.262.679144213 ASMCMD> ls -ds DATADGER/sati11/datafile Block_Size Blocks Bytes Space Name datafile/

lsct
This command display the ASM clients, that is the databases that have files based on ASM and are connected to it. The diskgrpoup name is optional. Adding the g flag display the instance ID, that is useful on cluster environments. H suppress the headers
ASMCMD> lsct DATADGCLN DB_Name Status Software_Version Compatible_version Instance_Name Disk_Group sati12 CONNECTED 11.1.0.7.0 11.1.0.0.0 sati12 DATADGCLN ASMCMD> lsct -g DATADGCLN Instance_ID DB_Name Status Software_Version Compatible_version Instance_Name 1 sati12 CONNECTED 11.1.0.7.0 11.1.0.0.0 sati12 ASMCMD> lsct -gH 1 sati11 CONNECTED 11.1.0.7.0 11.1.0.0.0 sati11 1 sati11 CONNECTED 11.1.0.7.0 11.1.0.0.0 sati11 1 sati12 CONNECTED 11.1.0.7.0 11.1.0.0.0 sati12

Disk_Group DATADGCLN DATADGER FRADG DATADGCLN

lsdsk 8/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
This command display the information related to ASM disks, there are several flags that can be used to control the output, they can be mixed to join in te output the columns contained displayed by each flag lsdsk -k display capacity information lsdsk -s display throughput and performance information. lsdsk -p display status information. lsdsk -t display time related information lsdsk -g includes INST_ID , useful on a cluster environment lsdsk -d restricts output to disks that belong to an specific group
Free_MB 841 OS_MB 2047 Name VOL1ER Failgroup VOL1ER Library Label UDID ASM Library-Generic Linux,version2.0.3(KABI_V2) VOLCLN1 Product UNKNOWN Redund Path ORCL:VOLCLN1

ASMCMD> lsdsk -k *VOLCLN1


Total_MB 2047

ASMCMD> lsdsk -s
Reads 167668 64299 157 1544 39 19237 18177 Write 108023 46999 21318 1498 487 21664 1155

Read_Errs 0 0 0 0 0 0 0

Write_Errs 0 0 0 0 0 0 0

Read_time 1099.812 670.528 1.446 40.869 .547 508.275 519.998

Write_Time 894.324 352.968 142.262 31.563 28.462 76.133 13.405

Bytes_Read 2914014208 1141705728 2504192 958976 159744 115082752 94441472

Bytes_Written 1302784000 517582848 139489280 51897856 52272128 96664576 13027328

Path ORCL:VOL1ER ORCL:VOL2ER ORCL:VOLBLK1 ORCL:VOLBLK3 ORCL:VOLBLK4 ORCL:VOLCLN1 ORCL:VOLCLN2

ASMCMD> lsdsk -p Group_Num Disk_Num 2 0 2 1 3 0 3 1 3 2 1 0 1 1

Incarn 3916047300 3916047301 3916047302 3916047303 3916047304 3916047298 3916047299

Mount_Stat CACHED CACHED CACHED CACHED CACHED CACHED CACHED

Header_Stat MEMBER MEMBER MEMBER MEMBER MEMBER MEMBER MEMBER

Mode_Stat ONLINE ONLINE ONLINE ONLINE ONLINE ONLINE ONLINE

State NORMAL NORMAL NORMAL NORMAL NORMAL NORMAL NORMAL

Path ORCL:VOL1ER ORCL:VOL2ER ORCL:VOLBLK1 ORCL:VOLBLK3 ORCL:VOLBLK4 ORCL:VOLCLN1 ORCL:VOLCLN2

9/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
ASMCMD> lsdsk -t Create_Date Mount_Date 18-FEB-09 19-FEB-09 18-FEB-09 19-FEB-09 12-FEB-09 19-FEB-09 12-FEB-09 19-FEB-09 18-FEB-09 19-FEB-09 18-FEB-09 19-FEB-09 18-FEB-09 19-FEB-09 Repair_Timer 0 0 0 0 0 0 0 Path ORCL:VOL1ER ORCL:VOL2ER ORCL:VOLBLK1 ORCL:VOLBLK3 ORCL:VOLBLK4 ORCL:VOLCLN1 ORCL:VOLCLN2

10/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
md_backup and md_restore
Useful to create a backup of the structure of a diskgroup that can be restored at any time or used to generate a script that can be used to rebuild a directory structure and redundancy related configuration. The metadata backup contains only definitions of directory structures and some configuration details but no data itself. It is useful to rebuild diskgroups before restoring a full backup. md_backup has 2 flags, -b backup file name and g diskgroup name md_restore has several flags that permit to control its behavior to trigger different actions like create diskgroups, or create only directories, or write the output to an sql script md_restore -b <use this backup_file>. md_restore -b <file> -t full : create disk group and restore metadata. md_restore -b <file> -t nodg : restore metadata only. md_restore -b <file> -t newdg -o old_name:new_name : create and rename disk group old_name to new_name md_restore -b <file> -f <name.sql> : write the sql commands that rebuild metada on the <name.sql> script. md_restore -b <file> -g <dskgrp> : restore only diskgroup <dskgrp>, if not used restore all dgs in the backup This example backup metadata off all diskgroups [oracle@asmxpt sati11]$ Disk group to be backed Disk group to be backed Disk group to be backed Current alias directory Current alias directory Current alias directory Current alias directory 11/15 asmcmd md_backup -b ./sati11_and_sati12_md_backup up: DATADGCLN up: DATADGER up: FRADG path: SATI12 path: SATI11/CONTROLFILE path: SATI12/CONTROLFILE path: SATI11

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current Current alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias alias directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory directory path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: path: SATI12/CHANGETRACKING SATI11/DATAFILE SATI11/TEMPFILE SATI11/ONLINELOG SATI11/PARAMETERFILE SATI11/DATAFILE SATI11/ONLINELOG SATI11/TEMPFILE SATI11/CONTROLFILE SATI11 SATI11/PARAMETERFILE SATI11/ARCHIVELOG/2009_02_18 SATI11/BACKUPSET SATI11 SATI12/BACKUPSET SATI12/ARCHIVELOG/2009_02_18 SATI11/AUTOBACKUP SATI12/ARCHIVELOG SATI12/BACKUPSET/2009_02_20 SATI11/CHANGETRACKING SATI11/BACKUPSET/2009_02_18 SATI12 SATI11/ARCHIVELOG/2009_02_17 SATI11/ARCHIVELOG SATI11/AUTOBACKUP/2009_02_18 SATI11/AUTOBACKUP/2009_02_12 SATI11/ARCHIVELOG/2009_02_20 SATI11/DATAFILE SATI11/ARCHIVELOG/2009_02_19 SATI11/BACKUPSET/2009_02_17

12/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
These command backups metadata of each database diskgroup separately [oracle@asmxpt sati11]$ Disk group to be backed Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory [oracle@asmxpt sati11]$ Disk group to be backed Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory Current alias directory asmcmd md_backup -b ./sati11_md_backup -g 'DATADGER' up: DATADGER path: SATI11/TEMPFILE path: SATI11/CONTROLFILE path: SATI11/DATAFILE path: SATI11 path: SATI11/ONLINELOG path: SATI11/PARAMETERFILE asmcmd md_backup -b ./sati12_md_backup -g 'DATADGCLN' up: DATADGCLN path: SATI12 path: SATI11/CONTROLFILE path: SATI12/CONTROLFILE path: SATI11 path: SATI12/CHANGETRACKING path: SATI11/DATAFILE path: SATI11/TEMPFILE path: SATI11/ONLINELOG path: SATI11/PARAMETERFILE

We cannot restore the metadata now that we have actual data on our diskgroups but we can write the commands to a script [oracle@asmxpt sati11]$ asmcmd md_restore -b ./sati12_md_backup -f ./sati12_md_backup.sql Current Diskgroup being restored: DATADGCLN [oracle@asmxpt sati11]$ cat ./sati12_md_backup.sql
create diskgroup DATADGCLN EXTERNAL redundancy disk 'ORCL:VOLCLN1' name VOL1ER size 2047M disk

13/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
'ORCL:VOLCLN2' name VOL2ER size 2047M ; alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR*/DATADGCLN alter alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add alter diskgroup /*ASMCMD AMBR */ DATADGCLN add template ASM_STALE attributes (UNPROTECTED COARSE); template FLASHBACK attributes (UNPROTECTED FINE); template CONTROLFILE attributes (UNPROTECTED FINE); template BACKUPSET attributes (UNPROTECTED COARSE); template XTRANSPORT attributes (UNPROTECTED COARSE); template DATAGUARDCONFIG attributes (UNPROTECTED COARSE); template ARCHIVELOG attributes (UNPROTECTED COARSE); template AUTOBACKUP attributes (UNPROTECTED COARSE); template ONLINELOG attributes (UNPROTECTED FINE); template DUMPSET attributes (UNPROTECTED COARSE); template DATAFILE attributes (UNPROTECTED COARSE); template TEMPFILE attributes (UNPROTECTED COARSE); template CHANGETRACKING attributes (UNPROTECTED COARSE); template PARAMETERFILE attributes (UNPROTECTED COARSE); directory '+DATADGCLN/SATI11'; directory '+DATADGCLN/SATI12'; directory '+DATADGCLN/SATI11/ONLINELOG'; directory '+DATADGCLN/SATI11/DATAFILE'; directory '+DATADGCLN/SATI11/CONTROLFILE'; directory '+DATADGCLN/SATI11/TEMPFILE'; directory '+DATADGCLN/SATI11/PARAMETERFILE'; directory '+DATADGCLN/SATI12/CONTROLFILE'; directory '+DATADGCLN/SATI12/CHANGETRACKING';

14/15

ASM HANDS-ON TRAINING


Lab 21 ASMCM Use And Options
remap
This command permit to repair blocks when there is a read IO error. It will not repair physical corruption. (We will not try this command on the lab) The syntax is : remap <disk_group_name> <disk_name> <block_range> Example : remap DATADG ORCL:VOL21 5000-5999

Other commands
There are other commands that we will not test in this lab: rm to remove files like the os rm command, mkalias/rmalias to create/remove aliases for files and directories, mkdir create directories, rm also remove directories, help display all commands available and help <command> display help on specific commands

End of Lab21

15/15

Das könnte Ihnen auch gefallen