Refer
p://satya-dba.blogspot.qa/2010/02/asmcmd-10g-11g.html
asmcmd utility in Oracle
Automatic Storage Management (ASM) Command line utility (ASMCMD), introduced with Oracle Database 10g release 2.
Managing ASM through SQL interfaces, in Oracle Database 10g Release 1, posed a challenge for administrators who were not very familiar with SQL and preferred a more conventional command line interface. From Oracle Database 10g Release 2, we have an option to manage the ASM files by using ASMCMD, a powerful and easy to use command line tool.
In Oracle Database 10g Release 1, ASM diskgroups are not visible outside the database for regular file system administration tasks such as copying and creating directories. From Oracle Database 10g Release 2, we can transfer the files from ASM to locations outside of the diskgroups via FTP and through a web browser using HTTP.
(From 11.2.0) ASMCMD is used to
start/stop ASM instances
create or alter or drop diskgroups
mount or dismount diskgroups
list the contents, statistics and attributes of diskgroups, and files on them
backup and restore the metadata of diskgroups
create and remove directories, templates and aliases
managing volumes
make online or offline the disks/failure groups
can rebalance the diskgroups
repair physical blocks
copy the files between the diskgroups and OS
backup and restore of SP file
add/remove/modify/list users from password file
add/remove/modify/list templates
manipulate diskstring
create/modify/remove ASM users, groups
change ASM file permissions, owners and groups
display space utilization
perform searches
ASMCMD has equivalent commands for all the SQL commands that can be performed through SQL*Plus.
ASMCMD is included in the installation of the Oracle Database software (from 10g Release 2), no separate setup is required.
We can’t see the files stored in the ASM instance using standard UNIX commands like ls. We need to use asmcmd. The asmcmd command line interface is very similar to standard UNIX/Linux commands, but it only manages files at the OS level. The asmcmd utility supports all common Linux commands. The idea of this tool is to make administering the ASM files similar to administering standard OS files.
Invoking asmcmd
To start using ASMCMD, you must log in as a user that has SYSASM or SYSDBA privileges through OS authentication. The environmental variables ORACLE_HOME and ORACLE_SID must be set to the ASM instance. Ensure that $ORACLE_HOME/bin is in PATH environment variable. You must have ASM configured on the machine and started, and the ASM diskgroups are mounted.
The default value of the ASM SID for a single instance database is +ASM. In Real Application Clusters (RAC) environments, the default value of the ASM SID on any node is +ASMnode# (+ASM1, +ASM2, ...).
$ export ORACLE_SID=+ASM
To enter in interactive mode, type asmcmd, which brings up the ASM command prompt.
$ asmcmd
ASMCMD>
To run a specific ASMCMD command, non interactively, we can type
$ asmcmd command arguments
We can specify -p option with the asmcmd command to include current directory path in the ASMCMD prompt.
$ asmcmd -p
ASMCMD [+] > cd dgroup1/hrms
ASMCMD [+dgroup1/hrms] >
We can specify -a option to choose the type of connection, either SYSASM or SYSDBA. From 11g, the SYSASM privilege is preferred & default.
$ asmcmd -a sysasm or asmcmd -a sysdba
We can specify -V option when starting asmcmd to displays the asmcmd version number. This is from 11g.
$ asmcmd -V
asmcmd version 11.1.0.6.0
We can specify -v option when starting asmcmd to displays the additional information. This is from 11g.
$ asmcmd -v
ASM Filenames & Directories
Pathnames within ASMCMD, can use either the forward slash (/) as in UNIX or the backward slash (\) as in Windows, they're interchangeable. Also, we can use either the UNIX wildcard "*" to match any string in a pathname, or its SQL equivalent, "%".
Filenames are not case sensitive, but are case retentive, that is, ASMCMD retains the case of the directory that you entered.
The fully qualified filename represents a hierarchy of directories in which the plus sign (+) represent the root directory. We can also create our own directories as subdirectories of the system-generated directories using the ALTER DISKGROUP command or with the ASMCMD mkdir command. Those directories can have subdirectories, and we can navigate the hierarchy of both system-generated directories and user-created directories with the cd command.
When we run an ASMCMD command that accepts a filename or directory name as an argument, we can use the name as either an absolute path or a relative path.
An absolute path refers to the full path of a file or directory. An absolute path begins with a plus sign (+) followed by a diskgroup name, followed by subsequent directories in the directory tree. The absolute path includes directories until the file or directory is reached. A fully qualified filename is an example of an absolute path to a file.
Using an absolute path enables the command to access the file or directory regardless of where the current directory is set. The following rm command uses an absolute path for the filename:
ASMCMD [+] > rm +dgroup1/hrms/datafile/users.280.555341999
A relative path includes only the part of the filename or directory name that is not part of the current directory. That is, the path to the file or directory is relative to the current directory.
ASMCMD [+dgroup1/hrms/DATAFILE] > ls -l undotbs1.267.557429239
Paths to directories can also be relative and we can use the pseudo-directories "." and ".." in place of a directory name. The wildcard characters * and % match zero or more characters anywhere within an absolute or relative path, which saves typing of the full directory or file name. These two wildcard characters behave identically.
Alias
As in UNIX, we can create alias names for files listed in the diskgroup. Aliases are user-friendly filenames that are references or pointers to system-generated filenames. Aliases are similar to symbolic links in UNIX flavors. ASM's auto generated names can be a bit strange, so creating aliases makes working with ASM files with ASMCMD easier. Aliases simplify ASM filename administration. We can create aliases with an ALTER DISKGROUP command or with the mkalias ASMCMD command.
An alias has at a minimum the diskgroup name as part of its complete path. We can create aliases at the diskgroup level or in any system-generated or user-created subdirectory. The following are examples of aliases:
+dgroup1/ctl1.f
+dgroup1/crm/ctl1.f
+dgroup1/mydir/ctl1.f
If you run the ASMCMD ls (list directory) with the -l flag, each alias is listed with the system-generated file to which the alias refers.
ctl1.f => +dgroup2/hrms/CONTROLFILE/Current.256.541956473
We can run the ASMCMD utility in either interactive or non interactive mode.
ASMCMD in Interactive Mode
The interactive mode of the ASMCMD utility provides an environment like shell or SQL*Plus, where we are prompted to enter ASMCMD commands.
To run ASMCMD in interactive mode:
1. Enter the following at the OS command prompt:
$ asmcmd
Oracle displays an ASMCMD command prompt as follows:
ASMCMD>
2. Enter an ASMCMD command and press Enter. The command runs and displays its output, and then ASMCMD prompts for the next command.
3. Continue entering ASMCMD commands. Enter the command exit to exit ASMCMD.
ASMCMD in Non Interactive Mode
In non interactive mode, you run a single ASMCMD command by including the command and command arguments on the command line that invokes ASMCMD. ASMCMD runs the command, generates output, and then exits. The non interactive mode is especially useful for running scripts.
To run ASMCMD in non interactive mode, where command is any valid ASMCMD command and arguments is a list of command flags and arguments, at the command prompt enter the following:
$ asmcmd command arguments
$ asmcmd ls -l
State Type Rebal Unbal Name
MOUNTED NORMAL N N DG_GROUP1/
MOUNTED NORMAL N N DG_GROUP2/
$ asmcmd lsdg ASM_DG_FRA
$ asmcmd mkdir +data/hrms/archives
$ asmcmd md_restore -b /u01/app/oracle/BACKUP/asm_md_backup -t nodg
Oracle 10g (Release 2) commands
cd command
Changes to a specified directory. We can go up or down the hierarchy of the current directory tree by providing a directory argument to the cd command.
cd dir_name
dir_name may be specified as either an absolute path or a relative path, including the . and .. pseudo-directories and wildcards.
ASMCMD [+dgroup2/crm] > cd +dgroup1/hrms
ASMCMD [+dgroup1/hrms] > cd DATAFILE
ASMCMD [+dgroup1/hrms/DATAFILE] > cd ..
ASMCMD [+]> cd +dgroup1/sample/C*
If a wildcard pattern matches only one directory when using wildcard characters with cd, then cd changes the directory to that destination. If the wildcard pattern matches multiple directories, then ASMCMD does not change the directory but instead returns an error.
pwd command
Displays the absolute path of the current directory.
pwd
ASMCMD> pwd
help command
Displays the syntax of a command and description of the command parameters.
help [command] or ? [command]
If you do not specify a value for command, then the help command lists all of the ASMCMD commands and general information about using the ASMCMD utility.
ASMCMD> help
ASMCMD> help lsct
ASMCMD> ?
ASMCMD> ? mkgrp
du command
Displays the total space used for files in the specified directory and in the entire directory tree under the directory.
du [-H] [dir_name]
The -H flag suppresses column headings from the output.
This command is similar to the du -s command on UNIX flavors. If you do not specify dir_name, then information about the current directory is displayed. dir_name can contain wildcard characters.
ASMCMD [+dgroup1/prod] > du
Used_MB Mirror_used_MB
1251 2507
Used_MB - The total space used in the directory, this value does not include mirroring.
Mirror_used_MB - This value includes mirroring.
For example, if a normal redundancy diskgroup contains 100 MB of data, then assuming that each file in the diskgroup is 2way mirrored, Used_MB is 100 MB and Mirror_used_MB is 200 MB.
ASMCMD> du TEMPFILE
Used_MB Mirror_used_MB
24582 24582
In this case, Used_MB & Mirror_used_MB are the same, because the diskgroups are not mirrored.
ASMCMD [+ASM_DG_DATA/CRM] > du -H DATAFILE/
98203 98203
find command
Displays the absolute paths of all occurrences of the specified name pattern (can have wildcards) in a specified directory and its subdirectories.
find [-t type] dir_name name_pattern
find [--type type] dir_name name_pattern (Oracle 11g R2 syntax)
type can be (these are the type values from the type column of the V$ASM_FILE)
CONTROLFILE,DATAFILE,ONLINELOG,ARCHIVELOG,TEMPFILE,BACKUPSET,PARAMETERFILE,DATAGUARDCONFIG,FLASHBACK,CHANGETRACKING,DUMPSET,AUTOBACKUP,XTRANSPORT
This command searches the specified directory and all subdirectories under it in the directory tree for the supplied name_pattern. The value that you use for name_pattern can be a directory name or a filename.
ASMCMD> find +dgroup1 undo*
+dgroup1/crm/DATAFILE/UNDOTBS1.258.555341963
+dgroup1/crm/DATAFILE/UNDOTBS1.272.557429239
ASMCMD> find -t CONTROLFILE +dg_data/hrms *
+dg_data/hrms/CONTROLFILE/Current.260.555342185
+dg_data/hrms/CONTROLFILE/Current.261.555342183
ASMCMD [+] > find --type CONTROLFILE +data/devdb *
+data/devdb/CONTROLFILE/Current.260.691577263
ls command
Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all diskgroups from the V$ASM_DISKGROUP_STAT (default) or V$ASM_DISKGROUP.
ls [-lsdrtLacgH] [name]
ls [-lsdtLacgH] [--reverse] [--permission] [pattern] (11g R2 syntax)
name can be a filename or directory name, can include wildcards.
If name is a directory name, then ASMCMD lists the contents of the directory and depending on flag settings, ASMCMD also lists information about each directory member. Directories are listed with a trailing forward slash (/) to distinguish them from files.
If name is a filename, then ASMCMD lists the file and depending on the flag settings, ASMCMD also lists information about the file.
Flag Description
(none) Displays only filenames and directory names.
-l Displays extended file information, including striping and redundancy information and whether the file was system-generated (indicated by Y under the SYS column) or user-created (as in the case of an alias, indicated by N under the SYS column). Note that not all possible file attributes or diskgroup attributes are included.
-s Displays file space information.
-d If the value for the name argument is a directory, then ASMCMD displays information about that directory, rather than the directory contents. Typically used with another flag, such as the -l flag.
-r or
--reverse Reverses the sort order of the listing.
-t Sorts the listing by timestamp.
-L If the value for the name argument is an alias, then ASMCMD displays information about the file that it references. Typically used with another flag, such as the -l flag.
-a For each listed file, displays the absolute path of the alias that references it.
-c Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specified.
-g Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output.
-H Suppresses column headings.
--permission Shows the permissions of a file (V$ASM_FILE.permission, V$ASM_FILE.owner, V$ASM_FILE.usergroup, V$ASM_ALIAS.name).
pattern Name of a file, directory, or pattern.
If you specify all of the flags, then the command shows a union of their attributes, with duplicates removed. To see the complete set of column values for a file or a diskgroup, query the V$ASM_FILE and V$ASM_DISKGROUP.
ASMCMD [+dgroup1/sample/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963
ASMCMD [+dgroup1/sample/DATAFILE] > ls -l
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE APR 18 19:16:07 Y EXAMPLE.269.555342243
DATAFILE MIRROR COARSE MAY 09 22:01:28 Y SYSAUX.257.555341961
DATAFILE MIRROR COARSE APR 19 19:16:24 Y SYSTEM.256.555341961
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
DATAFILE MIRROR COARSE APR 18 19:16:07 Y USERS.259.555341963
ASMCMD [+dgroup1/sample/DATAFILE] > ls -lt
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE MAY 09 22:01:28 Y SYSAUX.257.555341961
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
DATAFILE MIRROR COARSE APR 19 19:16:24 Y SYSTEM.256.555341961
DATAFILE MIRROR COARSE APR 18 19:16:07 Y USERS.259.555341963
DATAFILE MIRROR COARSE APR 18 19:16:07 Y EXAMPLE.269.555342243
ASMCMD [+] > ls --permission +data/prod/datafile
User Group Permission Name
rw-rw-rw- EXAMPLE.265.691577295
rw-rw-rw- SYSAUX.257.691577149
rw-rw-rw- SYSTEM.256.691577149
rw-rw-rw- UNDOTBS1.258.691577151
rw-rw-rw- USERS.259.691577151
ASMCMD [+dgroup1/sample/DATAFILE] > ls -l undo*
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE MAY 05 12:28:42 Y UNDOTBS1.258.555341963
DATAFILE MIRROR COARSE MAY 04 17:27:34 Y UNDOTBS1.272.557429239
ASMCMD [+dgroup1/sample/DATAFILE] > ls -s
Block_Size Blocks Bytes Space Name
8192 12801 104865792 214958080 EXAMPLE.269.555342243
8192 48641 398467072 802160640 SYSAUX.257.555341961
8192 61441 503324672 101187584 SYSTEM.256.555341961
8192 6401 52436992 110100480 UNDOTBS1.258.555341963
8192 12801 104865792 214958080 UNDOTBS1.272.557429239
8192 641 5251072 12582912 USERS.259.555341963
ASMCMD [+dgroup1] > ls +dgroup1/sample
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfilesample.ora
ASMCMD [+dgroup1] > ls -l +dgroup1/sample
Type Redund Striped Time Sys Name
Y CONTROLFILE/
Y DATAFILE/
Y ONLINELOG/
Y PARAMETERFILE/
Y TEMPFILE/
N spfilesample.ora=>+dgroup1/sample/PARAMETERFILE/spfile.270.555342443
ASMCMD [+dgroup1] > ls -r +dgroup1/sample
spfilesample.ora
TEMPFILE/
PARAMETERFILE/
ONLINELOG/
DATAFILE/
CONTROLFILE/
ASMCMD [+dgroup1] > ls -lL example_df2.f
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE APR 27 11:04 N example_df2.f => +dgroup1/sample/DATAFILE/EXAMPLE.271.556715087
ASMCMD [+dgroup1] > ls -a +dgroup1/sample/DATAFILE/EXAMPLE.271.556715087
+dgroup1/example_df2.f => EXAMPLE.271.556715087
ASMCMD [+dgroup1] > ls -lH +dgroup1/sample/PARAMETERFILE
PARAMETERFILE MIRROR COARSE MAY 04 21:48 Y spfile.270.555342443
If you enter ls +, then the command returns information about all diskgroups, including information about whether the diskgroups are mounted.
ASMCMD [+dgroup1] > ls -l +
State Type Rebal Unbal Name
MOUNTED NORMAL N N DGROUP1/
MOUNTED HIGH N N DGROUP2/
MOUNTED EXTERN N N DGROUP3/
ASMCMD [+USERDG2/prod] > ls -l
Type Redund Striped Time Sys Name
- - - - Y CONTROLFILE/
- - - - Y DATAFILE/
- - - - Y ONLINELOG/
- - - - Y TEMPFILE/
- - - - N control01.ctl => +USERDG2/prod/CONTROLFILE/Current.260.573852215
- - - - N control02.ctl => +USERDG2/prod/CONTROLFILE/Current.261.573852215
- - - - N control03.ctl => +USERDG2/prod/CONTROLFILE/Current.262.573852215
- - - - N example01.dbf => +USERDG2/prod/DATAFILE/UNKNOWN.267.573852295
- - - - N redo01.log => +USERDG2/prod/ONLINELOG/group_1.263.573852243
- - - - N redo02.log => +USERDG2/prod/ONLINELOG/group_2.264.573852249
- - - - N redo03.log => +USERDG2/prod/ONLINELOG/group_3.265.573852255
- - - - N sysaux01.dbf => +USERDG2/prod/DATAFILE/SYSAUX.257.573852115
- - - - N system01.dbf => +USERDG2/prod/DATAFILE/SYSTEM.256.573852113
- - - - N temp01.dbf => +USERDG2/prod/TEMPFILE/TEMP.266.573852277
- - - - N undotbs01.dbf => +USERDG2/prod/DATAFILE/UNDOTBS1.258.573852115
- - - - N users01.dbf => +USERDG2
The Sys column, immediately to the left of the Name column, shows if the file or directory was created by the ASM system. Because the CONTROLFILE directory is not a real file but an alias, the attributes of the alias, such as size, free space, and redundancy, shown in the first few columns of the output are null.
The following examples illustrate the use of wildcards.
ASMCMD> ls +dgroup1/mydir1/d*
data1.f
dummy.f
ASMCMD> ls +group1/sample/*
+dgroup1/sample/CONTROLFILE/:
Current.260.555342185
Current.261.555342183
+dgroup1/sample/DATAFILE/:
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.272.557429239
USERS.259.555341963
+dgroup1/sample/ONLINELOG/:
group_1.262.555342191
group_1.263.555342195
group_2.264.555342197
group_2.265.555342201
+dgroup1/sample/PARAMETERFILE/:
spfile.270.555342443
+dgroup1/sample/TEMPFILE/:
TEMP.268.555342229
lsct command
Lists information about current ASM clients (from V$ASM_CLIENT). A client, is a database or Oracle ASM Dynamic Volume Manager (Oracle ADVM), uses diskgroups that are managed by the ASM instance to which ASMCMD is currently connected.
lsct [-gH] [disk_group]
Flag Description
(none) Displays information about current ASM clients from V$ASM_CLIENT.
-g Selects from GV$ASM_CLIENT. GV$ASM_CLIENT.INST_ID is included in the output.
-H Suppresses column headings.
An ASM instance serves as a storage container; it's not a database by itself. Other databases use the space in the ASM instance for datafiles, control files, and so on.
How do you know how many databases are using an ASM instance?
ASMCMD [+DG1_FRA] > lsct
DB_Name Status Software_Version Compatible_version Instance_Name
PROD CONNECTED 10.2.0.1.0 10.2.0.1.0 PROD
REP CONNECTED 10.2.0.1.0 10.2.0.1.0 REP
ASMCMD [+] > lsct flash (in 11g)
DB_Name Status Software_Version Compatible_version Instance_Name Group_Name
TESTDB CONNECTED 11.2.0.1.0 11.2.0.1.0 TESTDB FLASH
SQL equivalent for lsct command is:
SQL> SELECT * FROM V$ASM_CLIENT;
lsdg command
Lists all diskgroups and their attributes from V$ASM_DISKGROUP_STAT (default) or V$ASM_DISKGROUP. The output also includes notification of any current rebalance operation for a diskgroup. If a diskgroup is specified, then lsdg returns only information about that diskgroup.
lsdg [-gcH] [disk_group]
lsdg [-gH] [--discovery] [pattern] (11.2.0 syntax)
If group is specified, then information about only that diskgroup is listed.
Flag Description
(none) Displays all the diskgroup attributes.
-c or --discovery Selects from V$ASM_DISKGROUP or GV$ASM_DISKGROUP if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.
-g Selects from GV$ASM_DISKGROUP_STAT or GV$ASM_DISKGROUP if the -c or --discovery flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output. The REBAL column of the GV$ASM_OPERATION is also included in the output.
-H Suppresses column headings.
pattern Returns only information about the specified diskgroup or diskgroups that match the supplied pattern.
To see the complete set of attributes for a diskgroup, use the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP.
Attribute Name Description
State State of the diskgroup (BROKEN, CONNECTED, DISMOUNTED, MOUNTED, QUIESCING, and UNKNOWN).
Type Diskgroup redundancy (NORMAL, HIGH, EXTERN).
Rebal Y if a rebalance operation is in progress.
Sector Sector size in bytes.
Block Block size in bytes.
AU Allocation unit size in bytes.
Total_MB Size of the diskgroup in MB.
Free_MB Free space in the diskgroup in MB, without redundancy, from V$ASM_DISKGROUP.
Req_mir_free_MB Amount of space that must be available in the diskgroup to restore full redundancy after the most severe failure that can be tolerated by the diskgroup. This is the REQUIRED_MIRROR_FREE_MB column from V$ASM_DISKGROUP.
Usable_file_MB Amount of free space, adjusted for mirroring, that is available for new files, from V$ASM_DISKGROUP.
Offline_disks Number of offline disks in the diskgroup. Offline disks are eventually dropped.
Name Diskgroup name.
Voting_files Specifies whether the diskgroup contains voting files (Y or N).
ASMCMD [+] > lsdg dgroup2
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED NORMAL N 512 4096 1048576 206 78 0 39 0 dgroup2
The following example lists the attributes of the dg_data diskgroup (in 11.2.0).
ASMCMD [+] > lsdg dg_data
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED NORMAL N 512 4096 4194304 12288 8835 1117 3859 0 N DG_DATA
SQL equivalent for lsdg command is:
SQL> SELECT * FROM V$ASM_DISKGROUP;
SQL> SELECT * FROM V$ASM_DISKGROUP_STAT;
mkalias command
Creates an alias for specified system-generated filename.
mkalias file alias
alias must be in the same diskgroup as the system-generated file. Only one alias is permitted for each ASM file.
ASMCMD [+dgroup1/sample/DATAFILE] > mkalias SYSAUX.257.555341961 sysaux.f
SQL equivalent for mkalias command is:
SQL> ALTER DISKGROUP dg_name ADD ALIAS user_alias FOR file;
mkdir command
Creates ASM directories under the current directory.
mkdir dir_name [dir_name...]
The current directory can be created by the system or by the user. You cannot create a directory at the root (+) level, which is a diskgroup.
ASMCMD [+dgroup1] > mkdir subdir1 subdir2
SQL equivalent for mkdir command is:
SQL> ALTER DISKGROUP dg_name ADD DIRECTORY dir_name[, dir_name ...];
rm command
Deletes specified ASM files and directories.
rm [-rf] name [name]...
Flag Description
-f Force, remove it without user interaction.
-r Recursive, remove sub-directories also.
If name is a file or alias (can contain wildcard characters), then the rm command can delete the file or alias, only if it is not currently in use by a client database.
If name is a directory, then the rm command can delete it only if it is empty (unless the -r flag is used) and it is not a system-generated directory.
If name is an alias, then the rm command deletes both the alias and the file to which the alias refers.
For example, if we have an alias,
+dg1/dir1/file.alias => +dg/orcl/DATAFILE/System.256.146589651
then running the
rm -r +dg1/dir1
command removes the +dg1/dir1/file.alias as well as +dg/orcl/DATAFILE/System.256.146589651.
To delete only an alias and retain the file that the alias references, use the rmalias command.
If you use a wildcard, the rm command deletes all of the matches except nonempty directories, unless you use the -r flag. To recursively delete, use the -r flag. This enables you to delete a nonempty directory, including all files and directories in it and in the entire directory tree underneath it. If you use the -r flag or a wildcard character, then the rm command prompts you to confirm the deletion before proceeding, unless you specify the -f flag. When using the -r flag, either the system-generated file or the alias must be present in the directory in which you run the rm command.
ASMCMD [+dgroup1/sample/DATAFILE] > rm alias293.f
ASMCMD> rm -rf +dg/orcl/DATAFILE
ASMCMD> rm -rf fradg/*
SQL equivalents for rm command are:
SQL> ALTER DISKGROUP dg_name DROP FILE ...;
SQL> ALTER DISKGROUP dg_name DROP DIRECTORY ...;
rmalias command
Deletes the specified aliases, retaining the files that the aliases reference.
rmalias [-r] alias [alias]...
To recursively delete, use the -r flag. This enables you to delete all of the aliases in the current directory and in the entire directory tree beneath the current directory. If any user-created directories become empty as a result of deleting aliases, they are also deleted. Files and directories created by the system are not deleted.
ASMCMD [+dgroup1/orcl/DATAFILE] > rmalias sysaux.f
ASMCMD > rmalias –r +dgroup1/orcl/ARCHIVES
SQL equivalent for rmalias command is:
SQL> ALTER DISKGROUP dg_name DELETE ALIAS user_alias;
exit command
Exits ASMCMD and returns control to the OS command prompt.
exit
ASMCMD> exit
Oracle 11g Release1 commands
cp command
Used to copy files between ASM diskgroups on local instances to and from remote instances. The local ASM instance must be either the source or the target. The file copy cannot be between remote instances. We can also use this command to copy files from ASM diskgroups to the OS.
cp [-ifr] [\@connect_identifier:]src_fname [\@connect_identifier:]tgt_fname
cp [-ifr] [\@connect_identifier:]src_fnameN[, src_fnameN+1…] [\@connect_identifier:]tgt_directory
Flag Description
-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.
The connect_identifier parameter is not required for a local instance copy, which is default. In case of a remote instance copy, we need to specify the connect_identifier and ASM prompts for a password in a non-echoing prompt. The connect_identifier is in the form of:
user_name@host_name[.port_number].SID
The user_name, host_name, and SID are required. The default port number is 1521.
src_fname(s) - Source file name to copy from. Enter either the fully qualified file name, or the ASM alias.
tgt_fname - A user alias for the created target file name or alias directory name.
tgt_directory - A target alias directory within an ASM diskgroup. The target directory must exist, otherwise the file copy returns an error.
The format of copied files is portable between Little-Endian and Big-Endian systems, if the files exist in an ASM diskgroup. ASM automatically converts the format when it writes the files. For copying non-ASM files from or to an ASM diskgroup, you can copy the files to a different endian platform and then use one of the commonly used utilities to convert the file.
ASMCMD [+] > cp +DG1/vdb.ctf1 /backups/vdb.ctf1
copying file(s)...
source +DG1/vdb.ctf1
target /backups/vdb.ctf1
file, /backups/vdb.ctf1, copy committed.
ASMCMD [+DG3/prod/DATAFILE] > cp warehouse.dbf /tmp
copying file(s)...
source +DG3/prod/DATAFILE/warehouse.dbf
target /tmp/warehouse.dbf
file, /tmp/warehouse.dbf, copy committed.
ASMCMD [+] > cp +DATA/db11g/datafile/users.273.661514191 /tmp/users.dbf
ASMCMD [+] > cp +DATA1/db11g/datafile/users.273.661514191 +DATA2/db11g/datafile/users.f
md_backup command
Creates a backup file containing metadata for one or more diskgroups. By default, all the mounted diskgroups are included in the backup file which is saved in the current working directory. If the name of the backup file is not specified, ASM names the file AMBR_BACKUP_INTERMEDIATE_FILE. Here AMBR stands for ASM Managed Backup Recovery.
md_backup [-b location_of_backup] [-g dgname [-g dgname...]]
md_backup [-b location_of_backup] [-g dgname[, dgname...]]
Flag Description
-b Specifies the location in which you want to store the intermediate backup file.
-g Specifies the diskgroup name that needs to be backed up.
This example backs up all of the mounted diskgroups and creates the backup in the current working directory.
ASMCMD > md_backup
The following example creates a backup of diskgroup asmdsk1 and asmdsk2. The backup will be saved in the /tmp/dgbackup100221 file.
ASMCMD > md_backup –b /tmp/dgbackup100221 –g admdsk1 –g asmdsk2
ASMCMD > md_backup -b /u01/backup/backup.txt -g dg_fra,dg_data
md_restore command
This command restores a diskgroup metadata backup.
md_restore -b backup_file [-li] [-t (full)|nodg|newdg] [-f sql_script_file] [-g 'dg_name,dg_name,...'] [-o 'old_dg_name:new_dg_name,...']
md_restore backup_file [--silent]
[--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]']
[-S sql_script_file] [-G 'diskgroup [,diskgroup...]'] (11g R2 syntax)
Flag Description
-b Reads the metadata information from backup_file.
-l Prints the messages to a file.
-i or --silent If md_restore encounters an error, it will stop. Specifying this flag ignores any errors.
-t Specifies the type of diskgroup to be created:
full - Create diskgroup and restore metadata.
nodg - Restore metadata only.
newdg - Create diskgroup with a different name and restore metadata, -o is required to rename.
-f or -S Write SQL commands to sql_script_file instead of executing them.
-g or -G Select the diskgroups to be restored. If no diskgroups are defined, then all diskgroups will be restored.
-o Rename diskgroup old_dg_name to new_dg_name.
ASMCMD> md_restore -b /tmp/backup.txt -t full -g data
ASMCMD> md_restore –t newdg –of override.txt –i backup_file
Example restores the diskgroup asmdsk1 from the backup script and creates a copy.
ASMCMD> md_restore –t full –g asmdsk1 –i backup_file
Example takes an existing diskgroup asmdsk6 and restores its metadata.
ASMCMD> md_restore –t nodg –g asmdsk6 –i backup_file
Example restores diskgroup asmdsk1 completely but the new diskgroup that is created is called asmdsk2.
ASMCMD> md_restore –t newdg -o 'asmdsk1:asmdsk2' –i backup_file
Example restores from the backup file after applying the overrides defined in the file override.txt.
ASMCMD> md_restore –t newdg –of override.txt –i backup_file
Example restores the diskgroup data from the backup script and creates a copy.
ASMCMD [+] > md_restore –-full –G data –-silent /tmp/dgbackup20090714
Example takes an existing diskgroup data and restores its metadata.
ASMCMD [+] > md_restore –-nodg –G data –-silent /tmp/dgbackup20090714
Example restores diskgroup data completely but the new diskgroup that is created is called data2.
ASMCMD [+] > md_restore –-newdg -o 'data:data2' --silent /tmp/dgbackup20090714
Example restores from the backup file after applying the overrides defined in the override.sql script file.
ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714
ASMCMD> md_restore -b dg7.backup -t full -f cr8_dg7.sql
lsdsk command
List the disks that are visible to ASM, using V$ASM_DISK_STAT (default) or V$ASM_DISK.
lsdsk [-ksptcgHI] [-d diskgroup_name] [pattern]
lsdsk [-kptgMHI] [-G diskgroup] [--member|--candidate]
[--discovery] [--statistics] [pattern] (11g R2 syntax)
Flag Description
(none) Displays PATH column of V$ASM_DISK.
-k Displays TOTAL_MB, FREE_MB, OS_MB, NAME, FAILGROUP, LIBRARY, LABEL, UDID, PRODUCT, REDUNDANCY, and PATH columns of V$ASM_DISK.
-s or --statistics Displays READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and PATH columns of V$ASM_DISK.
-p Displays GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, and PATH columns of V$ASM_DISK.
-t Displays CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and PATH columns of V$ASM_DISK.
-g Selects from GV$ASM_DISK_STAT or GV$ASM_DISK if the -c flag is also specified. GV$ASM_DISK.INST_ID is included in the output.
-c Selects from V$ASM_DISK or GV$ASM_DISK, if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.
-H Suppresses column headings.
-I Scans disk headers for information rather than extracting the information from an ASM instance. This option forces the non-connected mode.
-d or -G Restricts results to only those disks that belong to the group specified by diskgroup_name.
--discovery Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This option is always enabled if the Oracle ASM instance is version 10.1 or earlier. This flag is disregarded if lsdsk is running in non-connected mode.
-M Displays the disks that are visible to some but not all active instances. These are disks that, if included in a diskgroup, cause the mount of that diskgroup to fail on the instances where the disks are not visible.
--candidate Restricts results to only disks having membership status equal to CANDIDATE.
--member Restricts results to only disks having membership status equal to MEMBER.
pattern Returns only information about the specified disks that match the supplied pattern.
The k, s, p, and t flags modify how much information is displayed for each disk. If any combinations of the flags are specified, then the output shows the union of the attributes associated with each flag.
pattern restricts the output to only disks that matches the pattern specified.
ASMCMD> lsdsk -d DG_DATA -k
ASMCMD> lsdsk -g -t -d DATA1 *_001
This command can run in connected or non-connected mode. The connected mode is always attempted first. The -I option forces the non-connected mode.
In connected mode, ASMCMD uses dynamic views to retrieve disk information.
In non-connected mode, ASMCMD scans disk headers to retrieve disk information, using an ASM disk string to restrict the discovery set. This is not supported on Windows.
ASMCMD> lsdsk -k -d ASM_DG_DATA *_001
ASMCMD> lsdsk -sp -d ASM_DG_FRA *_001
ASMCMD> lsdsk -Ik
ASMCMD> lsdsk -t -d ASM_DG_IDX *_001
ASMCMD> lsdsk -Ct -d ASM_DG_DATA *_001
The first and second examples list information about disks in the data diskgroup.
ASMCMD [+] > lsdsk -t -G data
Create_Date Mount_Date Repair_Timer Path
13-JUL-09 13-JUL-09 0 /devices/diska1
13-JUL-09 13-JUL-09 0 /devices/diska2
13-JUL-09 13-JUL-09 0 /devices/diskb1
13-JUL-09 13-JUL-09 0 /devices/diskb2
ASMCMD [+] > lsdsk -p -G data /devices/diska*
Group_Num Disk_Num Incarn Mount_Stat Header_Stat Mode_Stat State Path
1 0 2105454210 CACHED MEMBER ONLINE NORMAL /devices/diska1
1 1 2105454199 CACHED MEMBER ONLINE NORMAL /devices/diska2
1 2 2105454205 CACHED MEMBER ONLINE NORMAL /devices/diska3
The third example lists information about candidate disks.
ASMCMD [+] > lsdsk --candidate -p
Group_Num Disk_Num Incarn Mount_Stat Header_Stat Mode_Stat State Path
0 5 2105454171 CLOSED CANDIDATE ONLINE NORMAL /devices/diske1
0 25 2105454191 CLOSED CANDIDATE ONLINE NORMAL /devices/diske2
0 18 2105454184 CLOSED CANDIDATE ONLINE NORMAL /devices/diske3
SQL equivalent for lsdsk command is:
SQL> SELECT * FROM V$ASM_DISK;
SQL> SELECT * FROM V$ASM_DISK_STAT;
remap command
Repairs range of physical blocks on a disk. The remap command only repairs blocks that have read disk I/O errors. It does not repair blocks that contain corrupted contents, whether those blocks can be read or not. The command assumes a physical block size of 512 bytes and supports all allocation unit sizes (1MB to 64MB).
It reads the blocks from a good copy of an ASM mirror and rewrites them to an alternate location on disk if the blocks on the original location cannot be read properly.
remap diskgroup_name disk_name block_range
Flag Description
diskgroup_name Name of the diskgroup in which a disk must be repaired.
disk_name Name of the disk that must be repaired.
block_range Range of physical blocks to repair, in the format: starting_number-ending_number
The following example repairs blocks 4500 through 5599 for disk DATA_001 in diskgroup DISK_GRP_DATA.
ASMCMD> remap DISK_GRP_DATA DATA_001 4500-5599
The following example repairs blocks 7200 through 8899 for disk largedisk_2 in diskgroup DISK_GRP_GRA.
ASMCMD> remap DISK_GRP_FRA largedisk_2 7200-8899
Oracle 11g Release2 commands
From 11g release 2, ASMCMD utility can also do
startup and shutdown of ASM instances.
Managing diskgroups (create, mount, alter, drop).
File access control (like OS, ugo and rwx ...).
User management.
Template management.
Volume management.
ASMCMD Instance Management Commands
startup command
Starts up an Oracle ASM instance.
startup [--nomount] [--restrict] [--pfile pfile_name]
Flag Description
(default) Will mount diskgroups and enables Oracle ADVM volumes.
--nomount Specifies no mount operation.
--restrict Specifies restricted mode.
--pfile Oracle ASM initialization parameter file.
The following is an example of the startup command that starts the Oracle ASM instance without mounting diskgroups and uses the asm_init.ora initialization parameter file.
ASMCMD> startup --nomount --pfile asm_init.ora
SQL equivalent for startup command is:
SQL> STARTUP ... ;
shutdown command
Shuts down an Oracle ASM instance.
shutdown [--abort|--immediate]
Flag Description
(default) normal shutdown.
--abort Shut down aborting all existing operations.
--immediate Shut down immediately.
Oracle strongly recommends that you shut down all database instances that use the Oracle ASM instance and dismount all file systems mounted on Oracle ASM Dynamic Volume Manager (Oracle ADVM) volumes before attempting to shut down the Oracle ASM instance with the abort (--abort) option.
The first example performs a shutdown of the Oracle ASM instance with normal action.
ASMCMD [+] > shutdown
The second example performs a shut down with immediate action
ASMCMD [+] > shutdown –-immediate
The third example performs a shut down that aborts all existing operations.
ASMCMD [+] > shutdown --abort
SQL equivalent for shutdown command is:
SQL> SHUTDOWN ... ;
dsset command
Sets the discovery diskstring value that is used by the Oracle ASM instance and its clients. The specified diskstring must be valid for existing mounted diskgroups. The updated value takes effect immediately.
dsset [--normal] [--parameter] [--profile [--force]] diskstring
Flag Description
--normal Sets the discovery string in the Grid Plug and Play (GPnP) profile and in the Oracle ASM instance. The update occurs after the Oracle ASM instance has successfully validated that the specified discovery string has discovered all the necessary diskgroups and voting files. This command fails if the instance is not using a server parameter file (SPFILE).
This is the default setting.
--profile [--force] Specifies the discovery diskstring that is pushed to the GPnP profile without any validation by the Oracle ASM instance, ensuring that the instance can discover all the required diskgroups. The update is guaranteed to be propagated to all the nodes that are part of the cluster.
If --force is specified, the specified diskstring is pushed to the local GPnP profile without any synchronization with other nodes in the cluster. This command option updates only the local profile file. This option should only be used for recovery. The command fails if the Oracle Clusterware stack is running.
--parameter Specifies that the diskstring is updated in memory after validating that the discovery diskstring discovers all the current mounted diskgroups and voting files. The diskstring is not persistently recorded in either the SPFILE or the GPnP profile.
diskstring Specifies the value for the discovery diskstring.
The following example uses dsset to set the current value of the discovery diskstring in the GPnP profile.
ASMCMD [+] > dsset /devices/disk*
dsget command
Retrieves the discovery diskstring value that is used by the Oracle ASM instance and its clients.
dsget [[--normal] [--profile [--force]] [--parameter]]
Flag Description
--normal Retrieves the discovery string from the Grid Plug and Play (GPnP) profile and the one that is set in the Oracle ASM instance. It returns one row each for the profile and parameter setting. This is the default setting.
--profile [--force] Retrieves the discovery string from the GPnP profile. If --force is specified, retrieves the discovery string from the local GPnP profile.
--parameter Retrieves the ASM_DISKSTRING parameter setting of the Oracle ASM instance.
The following example uses dsget to retrieve the current discovery diskstring value from the GPnP profile and the ASM_DISKSTRING parameter.
ASMCMD [+] > dsget
profile: /devices/disk*
parameter: /devices/disk*
lspwusr command
List the current users from the local Oracle ASM password file.
lspwusr [-H]
-H Suppresses column headers from the output.
ASMCMD [+] > lspwusr
Username sysdba sysoper sysasm
SYS TRUE TRUE TRUE
ASMSNMP TRUE FALSE FALSE
ASMCMD [+] > lspwusr -H
SYS TRUE TRUE TRUE
Satya TRUE TRUE FALSE
orapwusr command
Add, drop, or modify an Oracle ASM password file user. The command requires the SYSASM privilege to run. A user logged in as SYSDBA cannot change its password using this command.
orapwusr {{ {--add | --modify [--password]}
[--privilege {sysasm|sysdba|sysoper}] } | --delete} user
Flag Description
--add Adds a user to the password file. Also prompts for a password.
--delete Drops a user from the password file.
--modify Changes a user in the password file.
--privilege Sets the role for the user. The options are sysasm, sysdba, and sysoper.
--password Prompts for and then changes the password of a user.
user Name of the user to add, drop, or modify.
orapwusr attempts to update passwords on all nodes in a cluster.
This example adds the Satya to the Oracle ASM password file with the role of the user set to SYSASM.
ASMCMD [+] > orapwusr --add --privilege sysasm Satya
ASMCMD [+] > lspwusr
Username sysdba sysoper sysasm
SYS TRUE TRUE TRUE
Satya TRUE TRUE TRUE
spset command
Sets the location of the Oracle ASM SPFILE in the Grid Plug and Play (GPnP) profile.
spset location
The following is an example of the spset command that sets the location of the Oracle ASM SPFILE command in the dg_data diskgroup.
ASMCMD> spset +DG_DATA/asm/asmparameterfile/asmspfile.ora
spget command
Retrieves the location of the Oracle ASM SPFILE from the Grid Plug and Play (GPnP) profile.
spget
The location retrieved by spget is the location in the GPnP profile, but not always the location of the SPFILE currently used. For example, the location could have been recently updated by spset or spcopy with the -u option on an Oracle ASM instance that has not been restarted. After the next restart of the Oracle ASM, this location point to the ASM SPFILE currently is being used.
The following is an example of the spget command that retrieves and displays the location of the SPFILE from the GPnP profile.
ASMCMD [+] > spget
+DATA/asm/asmparameterfile/registry.253.691575633
spbackup command
Backs up an Oracle ASM SPFILE. spbackup does not affect the GPnP profile.
spbackup source destination
The backup file that is created is not a special file type and is not identified as a SPFILE. This file cannot be copied with spcopy. To copy this backup file, use the ASMCMD cp command.
The first example backs up the Oracle ASM SPFILE from one operating system location to another.
ASMCMD> spbackup /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/bakspfileASM.ora
The second example backs up the SPFILE from an operating system location to the data/bakspfileASM.ora diskgroup.
ASMCMD> spbackup /u01/oracle/dbs/spfile+ASM.ora +DG_DATA/bakspfileASM.ora
spcopy command
Copies an Oracle ASM SPFILE from source to destination. To use spcopy to copy an Oracle ASM SPFILE into a diskgroup, the diskgroup attribute COMPATIBLE.ASM must be set to 11.2 or greater.
spcopy [-u] source destination
-u updates the Grid Plug and Play (GPnP) profile. We can also use spset to update the GPnP profile.
Note the following about the use of spcopy:
spcopy can copy an Oracle ASM SPFILE from a diskgroup to a different diskgroup or to an operating system file.
spcopy can copy an Oracle ASM SPFILE from an operating system file to a diskgroup or to an operating system file.
spcopy can copy an Oracle ASM SPFILE when the SPFILE is being used by an open Oracle ASM instance.
After copying the SPFILE, you must restart the instance with the SPFILE in the new location to use that SPFILE. When the Oracle ASM instance is running with the SPFILE in the new location, you can remove the source SPFILE.
The first example copies the Oracle ASM SPFILE from one operating system location to another.
ASMCMD> spcopy /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/testspfileASM.ora
The second example copies the SPFILE from an operating system location to the data diskgroup and updates the GPnP profile.
ASMCMD> spcopy -u /u01/oracle/dbs/spfile+ASM.ora +DATA/testspfileASM.ora
spmove command
Moves an Oracle ASM SPFILE from source to destination and automatically updates the GPnP profile. To use spmove to move an Oracle ASM SPFILE into a diskgroup, the diskgroup attribute COMPATIBLE.ASM must be set to 11.2 or greater.
spmove source destination
Note the following about the use of spmove:
spmove can move an Oracle ASM SPFILE when the open instance is using a PFILE or a different SPFILE. After moving the SPFILE, you must restart the instance with the SPFILE in the new location to use that SPFILE.
spmove cannot move an Oracle ASM SPFILE when the SPFILE is being used by an open Oracle ASM instance.
The first example moves the Oracle ASM SPFILE from one operating system location to another.
ASMCMD> spmove /u01/oracle/dbs/spfile+ASM.ora /u01/oracle/dbs/testspfileASM.ora
The second example moves the SPFILE from an operating system location to the data diskgroup.
ASMCMD> spmove /u01/oracle/dbs/spfile+ASM.ora +DATA/testspfileASM.ora
lsop command
Lists the current operations on diskgroups or Oracle ASM instance, from V$ASM_OPERATION.
lsop
ASMCMD [+] > lsop
Group_Name Dsk_Num State Power
DG_DATA REBAL WAIT 2
ASMCMD [+] > lsop
Group_Name Dsk_Num State Power
DG_FRA REBAL REAP 3
SQL equivalent for lsop command is:
SQL> SELECT * FROM V$ASM_OPERATION
ASMCMD File Access Control Commands
mkusr command
Adds a valid operating system user to a diskgroup. Only users authenticated as SYSASM can run this command.
mkusr diskgroup user
The following example adds the asmdba2 user to the dg_fra diskgroup.
ASMCMD [+] > mkusr dg_fra asmdba2
SQL equivalent for mkusr command is:
SQL> ALTER DISKGROUP disk_group ADD USER 'user_name';
lsusr command
Lists Oracle ASM users in a diskgroup.
lsusr [-Ha] [-G diskgroup] [pattern]
Flag Description
-H Suppresses column headings.
-a List all users and the diskgroups to which the users belong.
-G Limits the results to the specified diskgroup name.
pattern Displays the users that match the pattern expression.
The example lists users in the asm_dg_data diskgroup and also shows the OS user Id assigned to the user.
ASMCMD [+] > lsusr -G asm_dg_data
User_Num OS_ID OS_Name
3 1001 oradba
1 1021 asmdba1
2 1022 asmdba2
ASMCMD [+] > lsusr -G asm_dg_fra asm*
User_Num OS_ID OS_Name
1 1021 asmdba1
2 1022 asmdba2
SQL equivalent for lsusr command is:
SQL> SELECT * FROM V$ASM_USER;
passwd command
Changes the password of a user. The command requires the SYSASM privilege to run.
passwd user
The user is first prompted for the current password, then the new password. An error will be raised if the user does not exist in the Oracle ASM password file.
ASMCMD [+] > passwd asmdba2
Enter old password (optional):
Enter new password: ******
rmusr command
Deletes an OS user from a diskgroup. Only a user authenticated as SYSASM can run this command.
rmusr [-r] diskgroup user
-r removes all files in the diskgroup that the user owns at the same time that the user is removed.
The following is an example to remove the asmdba2 user from the dg_data2 diskgroup.
ASMCMD [+] > rmusr dg_data2 asmdba2
SQL equivalent for rmusr command is:
SQL> ALTER DISKGROUP disk_group DROP USER 'user_name';
mkgrp command
Creates a new Oracle ASM user group. We can optionally specify a list of users to be included as members of the new user group. User group name can have maximum 30 characters.
mkgrp diskgroup usergroup [user] [user...]
This example creates the asm_data user group in the dg_data diskgroup and adds the asmdba1 and asmdba2 users to the user group.
ASMCMD [+] > mkgrp dg_data asm_data asmdba1 asmdba2
ASMCMD [+] > mkgrp dg_fra asm_fra
SQL equivalent for mkgrp command is:
SQL> ALTER DISKGROUP disk_group ADD USERGROUP 'usergroup_name';
SQL> ALTER DISKGROUP disk_group ADD USERGROUP 'usergroup_name' WITH MEMBER 'user_names';
lsgrp command
Lists all Oracle ASM user groups.
lsgrp [-Ha] [-G diskgroup] [pattern]
Flag Description
-H Suppresses column headings.
-a Lists all columns.
-G Limits the results to the specified diskgroup name.
pattern Displays the user groups that match the pattern expression.
The following example displays a subset of information about the user groups whose name matches the asm% pattern.
ASMCMD [+] > lsgrp asm%
DG_Name Grp_Name Owner
DG_FRA asm_fra grid
DG_DATA asm_data grid
The second example displays all information about all the user groups.
ASMCMD [+] > lsgrp –a –G DG_DATA
DG_Name Grp_Name Owner Members
DG_DATA asm_data grid asmdba1 asmdba2
SQL equivalent for lsgrp command is:
SQL> SELECT * FROM V$ASM_USERGROUP;
rmgrp command
Removes a user group from a diskgroup. The command must be run by the owner of the group and also requires the SYSASM privilege to run.
rmgrp diskgroup usergroup
Removing a group might leave some files without a valid group. To ensure that those files have a valid group, explicitly update those files to a valid group.
The following is an example of the rmgrp command that removes the asm_data user group from the dg_data diskgroup.
ASMCMD [+] > rmgrp dg_data asm_data
SQL equivalent for rmgrp command is:
SQL> ALTER DISKGROUP disk_group DROP USERGROUP 'usergroup_name';
grpmod command
Adds or removes OS users to and from an existing Oracle ASM user group. Only the owner of the user group can use this command. The command requires the SYSASM privilege to run. This command accepts an OS user name or multiple user names separated by spaces. The OS users are typically owners of a database instance home.
grpmod {--add | --delete} diskgroup usergroup user [user...]
Flag Description
--add Specifies to add users to the user group.
--delete Specifies to delete users from the user group.
usergroup Name of the user group.
user Name of the user to add or remove from the user group.
The following example adds the asmdba1 and asmdba2 users to the asm_fra user group of the dg_fra diskgroup.
ASMCMD [+] > grpmod –-add dg_fra asm_fra asmdba1 asmdba2
The second example removes the asmdba2 user from the asm_data user group of the dg_data diskgroup.
ASMCMD [+] > grpmod –-delete dg_data asm_data asmdba2
SQL equivalent for grpmod command is:
SQL> ALTER DISKGROUP disk_group MODIFY USERGROUP 'usergroup_name' ADD MEMBER 'user_name';
SQL> ALTER DISKGROUP disk_group MODIFY USERGROUP 'usergroup_name' DROP MEMBER 'user_name';
groups command
Lists all the user groups to which the specified user belongs.
groups diskgroup user
ASMCMD [+] > groups dg9 asmdba1
asm_data
SQL equivalent for groups command is:
SQL> SELECT * FROM V$ASM_USERGROUP_MEMBER;
chmod command
Changes permissions of a file or list of files. This command accepts a file name or multiple file names separated by spaces. The specified files must be closed.
chmod mode file [file ...]
mode can be one of the following forms:
{ugo|ug|uo|go|u|g|o|a} {+|-} {r|w|rw}
a specifies permissions for all users, u specifies permissions for the owner/user of the file, g specifies the group permissions, and o specifies permissions for other users.
{0|4|6} {0|4|6} {0|4|6}
The first digit specifies owner permissions, the second digit specifies group permissions, and the third digit specifies other permissions.
Flag Description
6 Read write permissions
4 Read only permissions
0 No permissions
u Owner permissions, used with r or w
g Group permissions, used with r or w
o Other user permissions, used with r or w
a All user permissions, used with r or w
+ Add a permission, used with r or w
- Removes a permission, used with r or w
r Read permission
w Write permission
file Name of a file
We can only set file permissions to read-write, read-only, and no permissions. We cannot set file permissions to write-only.
ASMCMD [+fra/orcl/archivelog/flashback] > chmod ug+rw log_7.264.684968167 log_8.265.684972027
ASMCMD [+fra/orcl/archivelog/flashback] > chmod 640 log_7.264.684968167 log_8.265.684972027
To view the permissions on a file, use the ASMCMD ls command with the --permission option.
ASMCMD [+] > ls --permission +fra/orcl/archivelog/flashback
User Group Permission Name
grid asm_fra rw-r----- log_7.264.684968167
grid asm_fra rw-r----- log_8.265.684972027
ASMCMD> chmod ug+rw +data/hrms/Controlfile/Current.175.654892547
SQL equivalent for chmod command is:
SQL> ALTER DISKGROUP disk_group SET PERMISSION OWNER=read write, GROUP=read only, OTHER=none FOR FILE '..path..';
chown command
Changes the owner of a file or list of files. This command accepts a file name or multiple file names separated by spaces. The specified files must be closed. Only the Oracle ASM administrator can use this command.
chown user[:usergroup ] file [file ...]
user typically refers to the user that owns the database instance home. Oracle ASM File Access Control uses the OS name to identify a database.
ASMCMD [+fra/orcl/archivelog/flashback] > chown asmdba1 log_7.264.684968167 log_8.265.684972027
ASMCMD [+fra/orcl/archivelog/flashback] > chown asmdba1:asm_fra log_9.264.687650269
ASMCMD> chown oracle1:asm_users +data/hrms/Controlfile/Current.175.654892547
SQL equivalent for chown command is:
SQL> ALTER DISKGROUP disk_group SET OWNERSHIP OWNER='user_name', GROUP='usergroup_name' FOR FILE '..path..';
chgrp command
Changes the Oracle ASM user group of a file or list of files. This command accepts a file name or multiple file names separated by spaces. Only the file owner or the Oracle ASM administrator can use this command. If the user is the file owner, then he must also be either the owner or a member of the group for this command to succeed.
chgrp usergroup file [file ...]
ASMCMD [+] > chgrp asm_data +data/orcl/controlfile/Current.260.684924747
ASMCMD [+fra/orcl/archivelog/flashback] > chgrp asm_fra log_7.264.684968167 log_8.265.684972027
ASMCMD Diskgroup Management Commands
mkdg command
Creates a diskgroup based on an XML configuration file which specifies the name of the diskgroup, redundancy, attributes, and paths of the disks that form the diskgroup.
mkdg {config_file.xml | 'contents_of_xml_file'}
Flag Description
config_file Name of the XML file that contains the configuration for the new diskgroup. mkdg searches for the XML file in the directory where ASMCMD was started unless a path is specified.
contents_of_xml_file The XML script enclosed in single quotations.
Redundancy is an optional parameter; the default is normal redundancy. For some types of redundancy, disks are required to be gathered into failure groups. In the case that failure groups are not specified for a diskgroup, each disk in the diskgroup belongs to its own failure group.
It is possible to set some diskgroup attribute values during diskgroup creation. Some attributes, such as AU_SIZE and SECTOR_SIZE, can be set only during diskgroup creation.
The default diskgroup compatibility settings are 10.1 for Oracle ASM compatibility, 10.1 for database compatibility, and no value for Oracle ADVM compatibility.
Tags for mkdg XML Configuration File
diskgroup
name diskgroup name
redundancy normal, external, high
failure group
name failure group name
disk
name disk name
path disk path
size size of the disk to add
attribute
name attribute name
value attribute value
The following is an example of an XML configuration file for mkdg. The configuration file creates a diskgroup named dg_data with normal redundancy. Two failure groups, fg1 and fg2, are created, each with two disks identified by associated disk strings. The diskgroup compatibility attributes are all set to 11.2.
The first example executes mkdg with an XML configuration file in the directory where ASMCMD was started.
ASMCMD [+] > mkdg data_config.xml
The second example executes mkdg using information on the command line.
ASMCMD [+] > mkdg ' '
SQL equivalent for mkdg command is:
SQL> CREATE DISKGROUP diskgroup_name ... ;
chdg command
Changes a diskgroup (adds disks, drops disks, or rebalances) based on an XML configuration file.
chdg {config_file.xml | 'contents_of_xml_file'}
Flag Description
config_file Name of the XML file that contains the changes for the diskgroup. chdg searches for the XML file in the directory where ASMCMD was started unless a path is specified.
contents_of_xml_file The XML script enclosed in single quotations.
The modification includes adding or deleting disks from an existing diskgroup, and the setting rebalance power level. The power level can set from 0 to the maximum of 11, the same values as the ASM_POWER_LIMIT initialization parameter.
When adding disks to a diskgroup, the diskstring must be specified in a format similar to the ASM_DISKSTRING initialization parameter.
The failure groups are optional parameters. The default causes every disk to belong to a its own failure group.
Dropping disks from a diskgroup can be performed through this operation. An individual disk can be referenced by its Oracle ASM disk name. A set of disks that belong to a failure group can be specified by the failure group name.
We can resize a disk inside a diskgroup with chdg. The resize operation fails if there is not enough space for storing data after the resize.
Tags for the chdg XML Configuration Template
update disk clause (add/delete disks/failure groups)
name diskgroup to change
power power to perform rebalance
items to add are placed here
items to drop are placed here
failure group
name failure group name
disk
name disk name
path disk path
size size of the disk to add
The following is an example of an XML configuration file for chdg. This XML file alters the diskgroup named data. The failure group fg1 is dropped and the disk data_0001 is also dropped. The /dev/disk8 disk is added to failure group fg2. The rebalance power level is set to 4.
The following are examples of the chdg command with the configuration file or configuration information on the command line.
ASMCMD [+] > chdg data_config.xml
ASMCMD [+] > chdg '
'
SQL equivalent for chdg command is:
SQL> ALTER DISKGROUP diskgroup_name ... ;
dropdg command
Drops an existing diskgroup. The diskgroup cannot be mounted on multiple nodes.
dropdg [-r] [-f] diskgroup
Flag Description
-f Force the operation. Only applicable if the diskgroup cannot be mounted.
-r Recursive, include contents.
diskgroup Name of diskgroup to drop.
The first example forces the drop of the diskgroup dg_data, including any data in the diskgroup.
ASMCMD [+] > dropdg -r -f dg_data
The second example drops the diskgroup dg_fra, including any data in the diskgroup.
ASMCMD [+] > dropdg -r dg_fra
SQL equivalent for dropdg command is:
SQL> DROP DISKGROUP diskgroup_name ... ;
chkdg command
Checks or repairs the metadata of a diskgroup. chkdg checks the metadata of a diskgroup for errors and optionally repairs the errors.
chkdg [--repair] diskgroup
The following is an example of the chkdg command used to check and repair the dg_data diskgroup.
ASMCMD [+] > chkdg --repair dg_data
SQL equivalent for chkdg command is:
SQL> ALTER DISKGROUP diskgroup_name CHECK ... ;
mount command
Will mount the specified diskgroups. This operation mounts one or more diskgroups. A diskgroup can be mounted with or without force or restricted options.
mount [--restrict] {[-a] | [-f] diskgroup[,diskgroup,...]}
Flag Description
--restrict Mounts in restricted mode.
-a Mounts all diskgroups.
-f Forces the mount operation.
diskgroup Name of the diskgroup.
The following are examples of the mount command showing the use of the force, restrict, and all options.
ASMCMD [+] > mount -f data
ASMCMD [+] > mount --restrict data
ASMCMD [+] > mount -a
SQL equivalent for mount command is:
SQL> ALTER DISKGROUP diskgroup_name MOUNT;
umount command
Will dismount the specified diskgroup.
umount {-a | [-f] diskgroup}
Flag Description
-a Dismounts all mounted diskgroups. These disk groups are listed in the output of the V$ASM_DISKGROUP view.
-f Forces the dismount operation.
diskgroup Name of the diskgroup.
The first example dismounts all diskgroups mounted on the Oracle ASM instance.
ASMCMD [+] > umount -a
The second example forces the dismount of the data disk group.
ASMCMD [+] > umount -f data
SQL equivalent for umount command is:
SQL> ALTER DISKGROUP diskgroup_name DISMOUNT;
offline command
Offline disks or failure groups that belong to a diskgroup.
offline -G diskgroup {-F failgroup|-D disk} [-t {minutes|hours}]
Flag Description
-G Diskgroup name.
-F Failure group name.
-D Specifies a single disk name.
-t Specifies the time before the specified disk is dropped as nm or nh, where m specifies minutes and h specifies hours. The default unit is hours.
When a failure group is specified, this implies all the disks that belong to it should be offlined.
The first example offlines the failgroup1 failure group of the dg_data diskgroup.
ASMCMD [+] > offline -G dg_data -F failgroup1
The second example offlines the data_0001 disk of the dg_data diskgroup with a time of 1.5 hours before the disk is dropped.
ASMCMD [+] > offline -G dg_data -D data_0001 -t 1.5h
SQL equivalent offline command is:
SQL> ALTER DISKGROUP diskgroup_name OFFLINE ...;
online command
Online all disks, a single disk, or a failure group that belongs to a diskgroup.
online {[-a] -G diskgroup|-F failgroup|-D disk} [-w]
Flag Description
-a Online all offline disks in the diskgroup.
-G Diskgroup name.
-F Failure group name.
-D Disk name.
-w Wait option. Causes ASMCMD to wait for the diskgroup to be rebalanced before returning control to the user. The default is not waiting.
When a failure group is specified, this implies all the disks that belong to it should be onlined.
The first example onlines all disks in the failgroup1 failure group of the dg_data diskgroup with the wait option enabled.
ASMCMD [+] > online -G dg_data -F failgroup1 -w
The second example onlines the data_0001 disk in the dg_data diskgroup.
ASMCMD [+] > online -G dg_data -D data_0001
SQL equivalent online command is:
SQL> ALTER DISKGROUP diskgroup_name ONLINE ...;
rebal command
Rebalances a diskgroup. The power level can be set from 0 to 11. A value of 0 disables rebalancing. If the rebalance power is not specified, the value defaults to the setting of the ASM_POWER_LIMIT initialization parameter.
rebal [--power power_value] [-w] diskgroup
Flag Description
--power Power setting (0 to 11).
-w Wait option. Causes ASMCMD to wait for the diskgroup to be rebalanced before returning control to the user. The default is not waiting.
diskgroup Diskgroup name.
The following example rebalances the dg_fra diskgroup with a power level set to 6.
ASMCMD [+] > rebal --power 6 dg_fra
We can determine if a rebalance operation is occurring with the ASMCMD lsop command.
ASMCMD [+] > lsop
Group_Name Dsk_Num State Power
FRA REBAL RUN 6
SQL equivalent rebal command is:
SQL> ALTER DISKGROUP diskgroup_name REBALANCE POWER n;
iostat command
Will display I/O statistics of disks in mounted ASM diskgroups, by using V$ASM_DISK_IOSTAT.
iostat [-etH] [--io] [--region] [-G diskgroup] [interval]
Flag Description
-e Displays error statistics (Read_Err, Write_Err).
-t Displays time statistics (Read_Time, Write_Time).
-H Suppresses column headings.
--io Displays information in number of I/Os, instead of bytes.
--region Displays information for cold and hot disk regions (Cold_Reads, Cold_Writes, Hot_Reads, Hot_Writes).
-G Displays statistics for the diskgroup name.
interval Refreshes the statistics display based on the interval value (seconds). Use Ctrl-C to stop the interval display.
To see the complete set of statistics for a diskgroup, use the V$ASM_DISK_IOSTAT view.
Attribute Name Description
Group_Name Name of the diskgroup.
Dsk_Name Name of the disk.
Reads Number of bytes read from the disk. If the --io option is entered, then the value is displayed as number of I/Os.
Writes Number of bytes written from the disk. If the --io option is entered, then the value is displayed as number of I/Os.
Cold_Reads Number of bytes read from the cold disk region. If the --io option is entered, then the value is displayed as number of I/Os.
Cold_Writes Number of bytes written from the cold disk region. If the --io option is entered, then the value is displayed as number of I/Os.
Hot_Reads Number of bytes read from the hot disk region. If the --io option is entered, then the value is displayed as number of I/Os.
Hot_Writes Number of bytes written from the hot disk region. If the --io option is entered, then the value is displayed as number of I/Os.
Read_Err Number of failed I/O read requests for the disk.
Write_Err Number of failed I/O write requests for the disk.
Read_Time I/O time (in hundredths of a second) for read requests for the disk if the TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).
Write_Time I/O time (in hundredths of a second) for write requests for the disk if the TIMED_STATISTICSinitialization parameter is set to TRUE (0 if set to FALSE).
If a refresh interval is not specified, the number displayed represents the total number of bytes or I/Os. If a refresh interval is specified, then the value displayed (bytes or I/Os) is the difference between the previous and current values, not the total value.
The first example displays disk I/O statistics for the data diskgroup in total number of bytes.
ASMCMD> iostat -G DG_DATA
Group_Name Disk_Name Reads Writes
DG_DATA DATA_0010 58486 29183
DG_DATA DATA_0011 4860 18398
The second example displays disk I/O statistics for the data diskgroup in total number of I/O operations.
ASMCMD [+] > iostat --io -G data
Group_Name Dsk_Name Reads Writes
DATA DATA_0000 2801 34918
DATA DATA_0001 58301 35700
DATA DATA_0002 3320 36345
ASMCMD> iostat -t
Group_Name Disk_Name Reads Writes Read_Time Write_Time
FRA DATA_0099 54601 38411 441.234546 672.694266
SQL equivalent for iostat command is:
SQL> SELECT * FROM V$ASM_DISK_IOSTAT;
setattr command
setattr command will change an attribute of a diskgroup.
setattr -G disk_group attribute_name attribute_value
ASMCMD> setattr -G DG_ASM_FRA compatible.asm 11.2.0.0.0
ASMCMD> setattr -G DG_ASM_DATA compatible.rdbms 11.1.0.0.0
ASMCMD> setattr -G DG_ASM_DATA au_size 2M
SQL equivalent for setattr command is:
SQL> ALTER DISKGROUP disk_group SET ATTRIBUTE attribute_name=attribute_value;
lsattr command
List attributes of a diskgroup, from V$ASM_ATTRIBUTE.
lsattr [-G diskgroup] [-Hlm] [pattern]
Flag Description
-G Diskgroup name.
-H Suppresses column headings.
-l Display names with values.
-m Displays additional information, such as the RO and Sys columns.
pattern Display the attributes that contain pattern expression.
The RO (read-only) column identifies those attributes that can only be set when a diskgroup is created. The Sys column identifies those attributes that are system-created.
ASMCMD> lsattr -l -G DG_ASM_FRA
Name Value
access_control.enabled FALSE
access_control.umask 066
au_size 1048576
cell.smart_scan_capable FALSE
compatible.asm 11.2.0.0.0
compatible.rdbms 10.1.0.0.0
disk_repair_time 3.6h
sector_size 512
ASMCMD> setattr -G DG_ASM_FRA compatible.rdbms 11.2.0.0.0
ASMCMD> lsattr -l -G DG_ASM_FRA
Name Value
access_control.enabled FALSE
access_control.umask 066
au_size 1048576
cell.smart_scan_capable FALSE
compatible.asm 11.2.0.0.0
compatible.rdbms 11.2.0.0.0
disk_repair_time 3.6h
sector_size 512
ASMCMD [+] > lsattr -l -G fra %compat*
Name Value
compatible.asm 11.2.0.0.0
compatible.rdbms 10.1.0.0.0
SQL equivalent for lsattr command is:
SQL> SELECT * FROM V$ASM_ATTRIBUTE;
lsod command
Lists the open ASM disks.
lsod [-H] [-G diskgroup] [--process process_name] [pattern]
Flag Description
-H Suppresses column header information from the output.
-G Specifies the diskgroup that contains the open disks.
--process Specifies a pattern to filter the list of processes.
pattern Specifies a pattern to filter the list of disks.
The rebalance operation (RBAL) opens a disk both globally and locally so the same disk may be listed twice in the output for the RBAL process.
The first example lists the open devices associated with the data diskgroup and the LGWR process.
ASMCMD [+] > lsod -G data --process LGWR
Instance Process OSPID Path
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska3
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskb3
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diskd1
The second example lists the open devices associated with the LGWR process for disks that match the diska pattern.
ASMCMD [+] > lsod --process LGWR diska
Instance Process OSPID Path
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska1
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska2
1 oracle@dadvmn0652 (LGWR) 26593 /devices/diska3
ASMCMD Template Management Commands
mktmpl command
Adds a template to a diskgroup.
mktmpl -G diskgroup [--striping {coarse|fine}]
[--redundancy {high|mirror|unprotected}] [--primary {hot|cold}]
[--secondary {hot|cold}] template
Flag Description
-G Name of the diskgroup.
--striping Striping specification, either coarse or fine.
--redundancy Redundancy specification, either high, mirror, or unprotected.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region.
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold region.
template Name of the template to create.
The following example adds temp_mc template to the dg_data diskgroup. The new template has the redundancy set to mirror and the striping set to coarse.
ASMCMD [+] > mktmpl -G dg_data --redundancy mirror --striping coarse temp_mc
SQL equivalent for mktmpl command is:
SQL> ALTER DISKGROUP disk_group ADD TEMPLATE template_name ...;
lstmpl command
Lists all templates or the templates for a specified diskgroup.
lstmpl [-Hl] [-G diskgroup] [pattern]
Flag Description
-H Suppresses column headings.
-l Displays all details.
-G Specifies diskgroup name.
pattern Displays the templates that match pattern expression.
The example lists all details of the templates in the dg_data diskgroup.
ASMCMD [+] > lstmpl -l -G dg_data
Group_Name Group_Num Name Stripe Sys Redund PriReg MirrReg
DG_DATA 1 ARCHIVELOG COARSE Y MIRROR COLD COLD
DG_DATA 1 ASMPARAMETERFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 AUTOBACKUP COARSE Y MIRROR COLD COLD
DG_DATA 1 BACKUPSET COARSE Y MIRROR COLD COLD
DG_DATA 1 CHANGETRACKING COARSE Y MIRROR COLD COLD
DG_DATA 1 CONTROLFILE FINE Y HIGH COLD COLD
DG_DATA 1 DATAFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 DATAGUARDCONFIG COARSE Y MIRROR COLD COLD
DG_DATA 1 DUMPSET COARSE Y MIRROR COLD COLD
DG_DATA 1 FLASHBACK COARSE Y MIRROR COLD COLD
DG_DATA 1 MYTEMPLATE FINE N HIGH COLD COLD
DG_DATA 1 OCRFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 ONLINELOG COARSE Y MIRROR COLD COLD
DG_DATA 1 PARAMETERFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 TEMPFILE COARSE Y MIRROR COLD COLD
DG_DATA 1 XTRANSPORT COARSE Y MIRROR COLD COLD
SQL equivalent for lstmpl command is:
SQL> SELECT * FROM V$ASM_TEMPLATE;
chtmpl command
Changes the attributes of a template.
chtmpl -G diskgroup { [--striping {coarse|fine}]
[--redundancy {high|mirror|unprotected}] [--primary {hot|cold}]
[--secondary {hot|cold}]} template
Flag Description
-G Name of the diskgroup.
--striping Striping specification, either coarse or fine.
--redundancy Redundancy specification, either high, mirror, or unprotected.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region.
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold region.
template Name of the template to change.
At least one of these options is required: --striping, --redundancy, --primary, or --secondary.
The following example updates temp_hf template of the dg_fra diskgroup. The redundancy attribute is set to high and the striping attribute is set to fine.
ASMCMD [+] > chtmpl -G dg_fra --redundancy high --striping fine temp_hf
SQL equivalent for chtmpl command is:
SQL> ALTER DISKGROUP disk_group ALTER TEMPLATE template_name ...;
rmtmpl command
Removes a template from a diskgroup.
rmtmpl -G diskgroup template
The following example removes temp_uf template from the dg_data diskgroup.
ASMCMD [+] > rmtmpl -G dg_data temp_uf
SQL equivalent for rmtmpl command is:
SQL> ALTER DISKGROUP disk_group DROP TEMPLATE template_name ...;
ASMCMD Volume Management Commands
volcreate command
Creates an Oracle ADVM volume in the specified diskgroup.
volcreate -G diskgroup -s size [--column number] [--width stripe_width] [--redundancy {high|mirror|unprotected}]
[--primary {hot|cold}] [--secondary {hot|cold}] volume
Flag Description
-G Name of the diskgroup containing the volume.
-s size Size of the volume to be created in units of K, M, G, T, P, or E. The unit designation must be appended to the number specified. No space is allowed. For example: 20G
--column Number of columns in a stripe set. Values range from 1 to 8. The default value is 4.
--width Stripe width of a volume. The value can range from 4 KB to 1 MB, at power-of-two intervals, with a default of 128 KB.
--redundancy Redundancy of the Oracle ADVM volume which can be specified for normal redundancy diskgroups. The range of values are as follows: unprotected for non-mirrored redundancy, mirror for double-mirrored redundancy, or high for triple-mirrored redundancy. If redundancy is not specified, the setting defaults to the redundancy level of the diskgroup.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region.
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold region.
volume Name of the volume to be created. Can be a maximum of 11 alphanumeric characters; dashes are not allowed. The first character must be alphabetic.
When creating an Oracle ADVM volume, a volume device name is created with a unique Oracle ADVM persistent diskgroup number that is concatenated to the end of the volume name. The unique number can be one to three digits.
On Linux, the volume device name is in the format volume_name-nnn, such as volume1-123. On Windows the volume device name is in the format asm-volume_name-nnn, such as asm-volume1-123.
A successful volume creation automatically enables the volume device.
The volume device file functions as any other disk or logical volume to mount file systems or for applications to use directly.
The following example creates volume1 in the dg_data diskgroup with the size set to 10 gigabytes.
ASMCMD [+] > volcreate -G dg_data -s 10G --width 64K --column 8 volume1
You can determine the volume device name with the volinfo command.
ASMCMD [+] > volinfo -G dg_data volume1
Diskgroup Name: DATA
Volume Name: VOLUME1
Volume Device: /dev/asm/volume1-123
State: ENABLED
Size (MB): 10240
Resize Unit (MB): 512
Redundancy: MIRROR
Stripe Columns: 8
Stripe Width (K): 64
Usage:
Mountpath:
ASMCMD [+] > volcreate -G dg_fra -s 100M vol2
SQL equivalent for volcreate command is:
SQL> ALTER DISKGROUP disk_group ADD VOLUME volume_name SIZE n;
volinfo command
Displays information about Oracle ADVM volumes.
volinfo {-a | -G diskgroup -a | -G diskgroup volume}
volinfo [--show_diskgroup|--show_volume] volumedevice}
Flag Description
-a When used without a diskgroup name, specifies all volumes within all diskgroups. When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgroup.
-G Name of the diskgroup containing the volume.
volume Name of the volume.
--show_diskgroup Returns only the diskgroup name. A volume device name is required.
--show_volume Returns only the volume name. A volume device name is required.
volumedevice Name of the volume device.
The first example displays information about the volume1 volume in the dg_data diskgroup and was produced in a Linux environment. The mount path field displays the last mount path for the volume.
ASMCMD [+] > volinfo -G dg_data volume1
Diskgroup Name: DG_DATA
Volume Name: VOLUME1
Volume Device: /dev/asm/volume1-123
State: ENABLED
Size (MB): 10240
Resize Unit (MB): 512
Redundancy: MIRROR
Stripe Columns: 8
Stripe Width (K): 64
Usage: ACFS
Mountpath: /u01/app/acfsmounts/acfs1
The second example displays information about the asm-volume1 volume in the dg_data diskgroup and was produced in a Windows environment.
ASMCMD [+] > volinfo -G dg_data -a
Diskgroup Name: DG_DATA
Volume Name: VOLUME1
Volume Device: \\.\asm-volume1-311
State: ENABLED
Size (MB): 1024
Resize Unit (MB): 256
Redundancy: MIRROR
Stripe Columns: 4
Stripe Width (K): 128
Usage: ACFS
Mountpath: C:\oracle\acfsmounts\acfs1
ASMCMD [+] > volinfo -a
SQL equivalent for volinfo command is:
SQL> SELECT * FROM V$ASM_VOLUME;
SQL> SELECT * FROM V$ASM_VOLUME_STAT;
voldelete command
Deletes an Oracle ADVM volume.
voldelete -G diskgroup volume
To successfully execute this command, the local Oracle ASM instance must be running and the diskgroup required by this command must be mounted in the Oracle ASM instance. Before deleting a volume, you must ensure that there are no active file systems associated with the volume.
The following example deletes volume1 from the dg_data diskgroup.
ASMCMD [+] > voldelete -G dg_data volume1
SQL equivalent for voldelete command is:
SQL> ALTER DISKGROUP disk_group DROP VOLUME volume_name;
voldisable command
Disables Oracle ADVM volumes in mounted diskgroups and removes the volume device on the local node.
voldisable {-a | -G diskgroup -a | -G diskgroup volume}
Flag Description
-a When used without a diskgroup name, specifies all volumes within all diskgroups.
When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgroup.
-G Name of the diskgroup containing the volume.
volume Name of the volume to be operated on. Can be maximum of 30 alphanumeric characters. The first character must be alphabetic.
You can disable volumes before shutting down an Oracle ASM instance or dismounting a diskgroup to verify that the operations can be accomplished normally without including a force option due to open volume files. Disabling a volume also prevents any subsequent opens on the volume or device file because it no longer exists.
Before disabling a volume, you must ensure that there are no active file systems associated with the volume. You must first dismount the Oracle ACFS file system before disabling the volume. You can delete a volume without first disabling the volume.
The following example disables volume1 in the dg_data diskgroup.
ASMCMD [+] > voldisable -G dg_data volume1
SQL equivalent for voldisable command is:
SQL> ALTER DISKGROUP disk_group DISABLE VOLUME volume_name;
volenable command
Enables Oracle ADVM volumes in mounted diskgroups. A volume is enabled when it is created.
volenable {-a | -G diskgroup -a | -G diskgroup volume}
Flag Description
-a When used without a diskgroup name, specifies all volumes within all diskgroups.
When used with a diskgroup name (-G diskgroup -a), specifies all volumes within that diskgroup.
-G Name of the diskgroup containing the volume.
volume Name of the volume to be operated on.
The following example enables volume1 in the dg_data diskgroup.
ASMCMD [+] > volenable -G dg_data volume1
SQL equivalent for volenable command is:
SQL> ALTER DISKGROUP disk_group ENABLE VOLUME volume_name;
volresize command
Resizes an Oracle ADVM volume.
volresize -G diskgroup -s size [-f] volume
Flag Description
-G Name of the diskgroup containing the volume.
-f Force the shrinking of a volume that is not an Oracle ACFS volume to suppress the warning message.
volume Name of the volume to be operated on.
-s New size of the volume in units of K, M, G, or T.
If the volume is mounted on a non-Oracle ACFS file system, then dismount the file system first before resizing. If the new size is smaller than current, you are warned of possible data corruption. Unless the -f (force) option is specified, you are prompted whether to continue with the operation.
If there is an Oracle ACFS file system on the volume, then you cannot resize the volume with the volresize command. You must use the acfsutil size command, which also resizes the volume and file system.
The following is an example of the volresize command that resizes volume1 in the dg_data diskgroup to 20 gigabytes.
ASMCMD [+] > volresize -G dg_data -s 20G volume1
SQL equivalent for volresize command is:
SQL> ALTER DISKGROUP disk_group RESIZE VOLUME volume_name SIZE n;
volset commnad
Sets attributes of an Oracle ADVM volume in mounted diskgroups.
volset -G diskgroup [--usagestring string] [--mountpath mount_path] [--primary {hot|cold}] [--secondary {hot|cold}] volume
Flag Description
-G Name of the diskgroup containing the volume.
--usagestring Optional usage string to tag a volume which can be up to 30 characters. This string is set to ACFS when the volume is attached to an Oracle ACFS file system and should not be changed.
--mountpath Optional string to tag a volume with its mount path string which can be up to 1024 characters. This string is set when the file system is mounted and should not be changed.
--primary Intelligent Data Placement specification for primary extents, either hot or cold region.
--secondary Intelligent Data Placement specification for secondary extents, either hot or cold region.
volume Name of the volume to be operated on.
When running the mkfs command to create a file system, the usage field is set to ACFS and mountpath field is reset to an empty string if it has been set. The usage field should remain at ACFS.
When running the mount command to mount a file system, the mountpath field is set to the mount path value to identify the mount point for the file system. After the value is set by the mount command, the mountpath field should not be updated.
The following is an example of a volset command that sets the usage string for a volume that is not associated with a file system.
ASMCMD [+] > volset -G dg_arch --usagestring 'no file system created' volume1
ASMCMD [+] > volset -G dg_data --usagestring 'acfs' volume1
SQL equivalent for volset command is:
SQL> ALTER DISKGROUP disk_group MODIFY VOLUME volume_name USAGE 'usage_string;
volstat command
Reports I/O statistics for Oracle ADVM volumes.
volstat [-G diskgroup] [volume]
The following apply when using the volstat command.
If the diskgroup is not specified and the volume name is specified, all mounted diskgroups are searched for the specified volume name.
If the diskgroup name is specified and the volume name is omitted, all volumes are displayed for the named diskgroup.
If both the diskgroup name and the volume name are omitted, all volumes on all diskgroups are displayed.
The following is an example of the volstat command that displays information about volumes in the dg_data diskgroup.
ASMCMD [+] > volstat -G dg_data
DISKGROUP NUMBER / NAME: 1 / DG_DATA
---------------------------------------
VOLUME_NAME
READS BYTES_READ READ_TIME READ_ERRS
WRITES BYTES_WRITTEN WRITE_TIME WRITE_ERRS
-------------------------------------------------------------
VOLUME1
10085 2290573312 22923 0
1382 5309440 1482 0
SQL equivalent for volstat command is:
SQL> SELECT * FROM V$ASM_VOLUME_STAT;
ASMCMD File Management Commands
lsof command
Lists the open files of the local clients.
lsof [-H] {-G diskgroup|--dbname db|-C instance}
Flag Description
-H Suppresses column headings.
-G List files only from this specified disk group.
--dbname List files only from this specified database.
-C List files only from this specified instance.
ASMCMD [+] > lsof -G dg_data
DB_Name Instance_Name Path
orcl orcl +dg_data/orcl/controlfile/current.260.691577263
orcl orcl +dg_data/orcl/datafile/example.265.691577295
orcl orcl +dg_data/orcl/datafile/sysaux.257.691577149
orcl orcl +dg_data/orcl/datafile/system.256.691577149
orcl orcl +dg_data/orcl/datafile/undotbs1.258.691577151
orcl orcl +dg_data/orcl/datafile/users.259.691577151
orcl orcl +dg_data/orcl/onlinelog/group_1.261.691577267
orcl orcl +dg_data/orcl/onlinelog/group_2.262.691577271
orcl orcl +dg_data/orcl/onlinelog/group_3.263.691577275
orcl orcl +dg_data/orcl/tempfile/temp.264.691577287
ASMCMD [+] > lsof -C +ASM
DB_Name Instance_Name Path
asmvol +ASM +data/VOLUME1.271.679226013
asmvol +ASM +data/VOLUME2.272.679227351
Other file management commands are
cd, cp, du, find, ls, mkalias, pwd, rm, rmalias
asmcmd command line history
The asmcmd utility does not provide command history with the up-arrow key. With rlwrap utility installed, that can be done by adding the following entry to the oracle user’s profile file:
alias asmcmd='rlwrap asmcmd'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment