ASMCMD is a command-line utility that you can use to manage Oracle ASM instances, disk groups, file access control for disk groups, files and directories within disk groups, templates for disk groups, and volumes.
You can run the ASMCMD utility in either interactive or noninteractive mode.
This section contains the following topics:
The types of ASMCMD commands are listed in Table 12-1.
ASMCMD works with Oracle ASM files, directories, and aliases. Before using ASMCMD, you should understand how these common computing concepts apply to the Oracle ASM environment.
This section contains the following topics about some key definitions:
Oracle ASM generates filenames according to the following scheme:
An example of a fully qualified filename is the following:
In the previous fully qualified filename,
data is the disk group name,
orcl is the database name,
CONTROLFILE is the file type, and so on.
Only the slash (/) is supported by ASMCMD. Filenames are not case sensitive, but are case retentive. If you type a path name as lowercase, ASMCMD retains the lowercase.
For more information about Oracle ASM filenames, refer to "Fully Qualified File Name Form".
As in other file systems, an Oracle ASM directory is a container for files, and an Oracle ASM directory can be part of a tree structure of other directories. The fully qualified filename represents a hierarchy of directories in which the plus sign (+) represents the root directory. In each disk group, Oracle ASM automatically creates a directory hierarchy that corresponds to the structure of the fully qualified filenames in the disk group. The directories in this hierarchy are known as system-generated directories.
ASMCMD enables you to move up and down in this directory hierarchy with the
cd (change directory) command. The ASMCMD
ls (list directory) command lists the contents of the current directory, while the
pwd command prints the name of the current directory.
When you start ASMCMD, the current directory is set to root (+). For an Oracle ASM instance with two disk groups, for example,
fra, entering an
ls command with the root directory as the current directory produces the following output:
The following example demonstrates navigating the Oracle ASM directory tree (refer to the fully qualified filename shown previously):
ASMCMD> cd +data/orcl/CONTROLFILE
You can create your own directories as subdirectories of the system-generated directories using the ASMCMD
mkdir command. The directories that you create can have subdirectories, and you can navigate the hierarchy of both system-generated directories and user-created directories with the
The following example creates the directory
orcl in the disk group
ASMCMD> mkdir +data/orcl/mydir
orclis a system-generated directory. The contents of
datarepresent the contents of disk group
If you start ASMCMD with the
-p flag, then ASMCMD shows the current directory as part of its prompt. See "Including the Current Directory in the ASMCMD Prompt".
ASMCMD [+] > cd data/orcl
ASMCMD [+data/orcl] >
ASMCMD retains the case of the directory that you entered.
Aliases are filenames that are references or pointers to system-generated filenames. However, aliases are user-friendly names. Aliases are similar to symbolic links in UNIX or Linux computers. You can create aliases to simplify Oracle ASM filename administration. You can create aliases with the
mkalias ASMCMD command or a SQL
An alias has at a minimum the disk group name as part of its complete path. You can create aliases at the disk group level or in any system-generated or user-created subdirectory. The following are examples of aliases:
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 => +data/orcl/CONTROLFILE/Current.256.541956473
For more information about aliases, refer to "Alias Oracle ASM Filename Forms".
An absolute path refers to the full path of a file or directory. An absolute path begins with a plus sign (+) followed by a disk group name, followed by subsequent directories in the directory tree. The absolute path includes directories until the file or directory of interest is reached. A complete system-generated filename, otherwise known as the 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
cd command uses an absolute path to the directory.
ASMCMD [+data/mydir] > cd +data/orcl/CONTROLFILE
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.
In the following example, the
rm command operates on the file
undotbs1.272.557429239, which in this case is a relative path. ASMCMD appends the current directory to the command argument to obtain the absolute path to the file. In this example this is
ASMCMD [+] > cd +data
ASMCMD [+data] > cd orcl/DATAFILE
ASMCMD [+data/orcl/DATAFILE] > ls
ASMCMD [+data/orcl/DATAFILE] >
Paths to directories can also be relative. You can go up or down the hierarchy of the current directory tree branch by providing a directory argument to the
cd command whose path is relative to the current directory.
In addition, you can use the pseudo-directories "
." and "
.." rather than a directory name. The "
." pseudo-directory is the current directory. The "
.." pseudo-directory is the parent directory of the current directory.
The following example demonstrates how to use relative directory paths and pseudo-directories:
ASMCMD [+data/orcl] > cd DATAFILE
ASMCMD [+data/orcl/DATAFILE] >cd ..
ASMCMD [+data/orcl] >
The wildcard characters
% match zero or more characters anywhere within an absolute or relative path, which saves typing of the full directory or file name. The two wildcard characters behave identically. There are various ASMCMD commands that accept wildcards. These include
If a wildcard pattern matches only one directory when using wildcard characters with
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.
Example 12-1 illustrates the use of wildcards.
ASMCMD [+] > cd +data/orcl/*FILE ASMCMD-08005: +data/orcl/*FILE: ambiguous ASMCMD [+] > cd +data/orcl/C* ASMCMD [+data/orcl/CONTROLFILE] > ASMCMD [+] > ls +fra/orcl/A% 2009_07_13/ 2009_07_14/ ASMCMD [+] > ls +fra/orcl/ARCHIVELOG/2009% +fra/orcl/ARCHIVELOG/2009_07_13/: thread_1_seq_3.260.692103543 thread_1_seq_4.261.692108897 thread_1_seq_5.262.692125993 thread_1_seq_6.263.692140729 thread_1_seq_7.264.692143333 +fra/orcl/ARCHIVELOG/2009_07_14/: thread_1_seq_8.271.692158265 thread_1_seq_9.272.692174597 ASMCMD [+] > ls data/orcl/* +data/orcl/CONTROLFILE/: Current.260.692103157 +data/orcl/DATAFILE/: EXAMPLE.265.692103187 SYSAUX.257.692103045 SYSTEM.256.692103045 UNDOTBS1.258.692103045 USERS.259.692103045 +data/orcl/ONLINELOG/: group_1.261.692103161 group_2.262.692103165 group_3.263.692103169 +data/orcl/PARAMETERFILE/: spfile.266.692103315 +data/orcl/TEMPFILE/: TEMP.264.692103181 spfileorcl.ora
Before running ASMCMD, review the items in the following list.
Log in to the host which contains the Oracle ASM instance that you plan to administer.
You must log in as a user that has SYSASM or SYSDBA privileges through operating system authentication. The SYSASM privilege is the required connection to administer the Oracle ASM instance. See "Authentication for Accessing Oracle ASM Instances".
See Also:Refer to the Oracle Database Administrator's Guide for information about operating system authentication
Connect as SYSASM, the default connection, to administer an Oracle ASM instance.
Ensure that the
ORACLE_SID environment variables to refer to the Oracle ASM instance. Depending on your operating system, you might have to set other environment variables to properly connect to the Oracle ASM instance.
Ensure that the
bin subdirectory of your Oracle Grid Infrastructure home is in your
PATH environment variable.
See Also:Refer to the Oracle Database Administrator's Guide for more information about setting environment variables
The default value of the Oracle ASM SID for a single-instance database is
+ASM. In Oracle Real Application Clusters environments, the default value of the Oracle ASM SID on any node is
To use most of the ASMCMD commands, ensure that the Oracle ASM instance is started and the Oracle ASM disk groups are mounted.
If the Oracle ASM instance is not running, ASMCMD runs only those commands that do not require an Oracle ASM instance. The commands include
exit. If you attempt to run other ASMCMD commands, an error message displays.
Ensure that the
ORACLE_SID environment variables to refer to the database instance. Depending on your operating system, you might have to set other environment variables to properly connect to the database instance.
You must include the
--privilege option to connect as SYSDBA. See "Specifying the Type of Connection".
With this connection, there is a limited set of operations that can be run. For more information, see "The SYSDBA Privilege for Managing Oracle ASM Components".
When administering disk groups, Oracle recommends that you run ASMCMD from the database home of the database instance that is the owner of the files in the disk group.
Table 12-2 summarizes the ASMCMD options.
Displays the version of ASMCMD and then exits.
Displays additional information with some commands to help users diagnose problems and writes to a message file when logging is required.
Specifies the privilege to connect as when accessing an Oracle ASM or database instance. Can be either
Displays the current directory in the prompt.
ASMCMD can be started with multiple options. For example:
For the majority of the examples in this chapter, ASMCMD was started with the
Enter the following at the operating system command prompt:
Oracle displays an ASMCMD command prompt as follows:
Enter an ASMCMD command and press
Enter. The command runs and displays its output, if any, and then ASMCMD prompts for the next command.
Continue entering ASMCMD commands until you have completed the tasks.
You can specify the
--privilege option to choose the type of connection, either
SYSDBA. The default value is
SYSASM and is used when administering an Oracle ASM instance. Connect as
SYSDBA when connecting to the database instance.
$ asmcmd --privilege sysasm
$ asmcmd -v
When there is a message that must be logged during
asmcmd operations, the message is written to the
alert.log file or the
alert.log file is created or updated when
asmcmd is started with the
normal display level. The
trace.trc file is created or updated when
asmcmd is started with the
debug display level.
By default, the
alert.log is file created in the
/alert/ directory. By default, the
trace.trc file is created in the
Under certain circumstances,
$ORACLE_HOME can be set to override the default locations of the
$ asmcmd -p
ASMCMD [+] > cd data
ASMCMD [+data] >
In noninteractive mode, you run a single ASMCMD command by including the command and command options on the command line when invoking ASMCMD. ASMCMD runs the command, generates output if any, and then exits. The noninteractive mode is especially useful for running scripts.
To run ASMCMD in noninteractive mode where
command is any valid ASMCMD command and
options is a list of command options, at the command prompt enter the following:
In noninteractive mode, ASMCMD returns the codes listed in Table 12-3.
No issues for the command.
255 or -1
External user error as returned by a command.
Results include member disks only.
Results include candidate disks only.
Results include both member and candidate disks.
Example 12-2 shows how to run ASMCMD in the noninteractive mode. The first example runs the
ls command to list the disk groups for the Oracle ASM instance. The second example redirects the output of the
lsod command to the
my_lsod_test file. The third example runs
lsdsk using a pattern with a wildcard character to list specific disks in the
data disk group.
$ asmcmd ls -l State Type Rebal Name MOUNTED NORMAL N DATA/ MOUNTED NORMAL N FRA/ $ asmcmd lsod --suppressheader -G data > my_lsod_test $ asmcmd lsdsk -G data '/devices/diska*' Path /devices/diska1 /devices/diska2 /devices/diska3
Example 12-3 raises an error with an incorrect disk group name and the return code equal (255) is displayed.
$ asmcmd ls -l dat ASMCMD-08001: diskgroup 'dat' does not exist or is not mounted $ echo $? 255
Example 12-4 shows an example of ASMCMD commands run in noninteractive mode inside a script.
You can type
command to display help text for a specific command, including usage information about how to run the command with its options.
The following is an example of the use of the