Oracle® Database Storage Administrator's Guide 11g Release 2 (11.2) Part Number E10500-01 |
|
|
View PDF |
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.
Table 12-1 Types of ASMCMD Commands
Category | Commands |
---|---|
dsget, dsset, lsct, lsop, lspwusr, orapwusr, shutdown, spbackup, spcopy, spget, spmove, spset, startup |
|
chdg, chkdg, dropdg, iostat, lsattr, lsdg, lsdsk, lsod, md_backup, md_restore, mkdg, mount, offline, online, rebal, remap, setattr, umount |
|
chgrp, chmod, chown, groups, grpmod, lsgrp, lsusr, mkgrp, mkusr, passwd, rmgrp, rmusr |
|
volcreate, voldelete, voldisable, volenable, volinfo, volresize, volset, volstat |
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:
Every file created in Oracle ASM gets a system-generated filename, otherwise known as a fully qualified filename. This is the same as a complete path name in a local file system.
Oracle ASM generates filenames according to the following scheme:
+diskGroupName/databaseName/fileType/fileTypeTag.fileNumber.incarnation
An example of a fully qualified filename is the following:
+data/orcl/CONTROLFILE/Current.256.541956473
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 (+) represent 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, data
and fra
, entering an ls
command with the root directory as the current directory produces the following output:
ASMCMD> ls
data/
fra/
The following example demonstrates navigating the Oracle ASM directory tree (refer to the fully qualified filename shown previously):
ASMCMD> cd +data/orcl/CONTROLFILE
ASMCMD> ls
Current.256.541956473
Current.257.541956475
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 cd
command.
The following example creates the directory mydir
under orcl
in the disk group data
:
ASMCMD> mkdir +data/orcl/mydir
Note:
The directoryorcl
is a system-generated directory. The contents of data
represent the contents of disk group data
.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 ALTER
DISKGROUP
command.
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:
+data/ctl1.f
+data/orcl/ctl1.f
+data/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 => +data/orcl/CONTROLFILE/Current.256.541956473
For more information about aliases, refer to "Alias Oracle ASM Filename Forms".
When you run an ASMCMD command that accepts a filename or directory name as an argument, you 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 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
+data/orcl/datafile/users.259.555341963
The following 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 +data/orcl/DATAFILE/undotbs1.272.557429239
.
ASMCMD [+] > cd +data
ASMCMD [+data] > cd orcl/DATAFILE
ASMCMD [+data/orcl/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963
ASMCMD [+data/orcl/DATAFILE] >
rm undotbs1.272.557429239
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 "..
" in place of 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 *
and %
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 cd
, du
, find
, ls
, lsattr
, lsdg
, lsdsk
, lsgrp
, lsusr
, and rm
.
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.
Example 12-1 illustrates the use of wildcards.
Example 12-1 Using Wildcards With ASMCMD
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
You can run the ASMCMD utility in either interactive or noninteractive mode.
Before running ASMCMD, review the items in the following list.
Log in to the host on which the Oracle ASM instance that you want to work with is running.
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 authenticationTo connect to the Oracle ASM instance, run ASMCMD that is located in the bin
subdirectory of the Oracle grid infrastructure home (Oracle ASM home).
Connect as SYSASM, the default connection, to administer an Oracle ASM instance.
Ensure that the ORACLE_HOME
and 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 variablesThe default value of the Oracle ASM SID for a single-instance database is +ASM
. In Real Application Clusters environments, the default value of the Oracle ASM SID on any node is +ASM
node#
.
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 or if the ORACLE_SID
is set incorrectly, ASMCMD runs only those commands that do not require an Oracle ASM instance. The commands include startup
, shutdown
, lsdsk
, help
, and exit
. If you attempt to run other ASMCMD commands, an error message displays.
You can connect to the database instance as SYSDBA by running ASMCMD that is located in the bin
directory of the Oracle Database home.
Ensure that the ORACLE_HOME
and 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 -a
option to connect as SYSDBA. See "Specifying the Type of Connection".
With this connection, there are 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.
The interactive mode of the ASMCMD utility provides a shell-like environment where you are prompted to enter ASMCMD commands. The syntax for starting ASMCMD in interactive mode is:
asmcmd
[-V
]asmcmd
[-v
] [ -a
connection_type
] [-p
]Table 12-2 summarizes the ASMCMD options.
Table 12-2 ASMCMD Interactive Options
Option | Description |
---|---|
- |
Displays the version of ASMCMD and then exits. |
|
Displays additional information with some commands to help users diagnose problems. |
|
Specifies how to connect as when accessing an Oracle ASM or database instance. Can be either SYSASM or SYSDBA. The default is SYSASM and should be used when administering the Oracle ASM instance. |
|
Displays the current directory in the prompt. |
ASMCMD can be started with multiple options. For example:
asmcmd
-p
-v
For the majority of the examples in this chapter, ASMCMD was started with the -p
and -v
options
To run ASMCMD in interactive mode without any options:
Enter the following at the operating system command prompt:
asmcmd
Oracle displays an ASMCMD command prompt as follows:
ASMCMD>
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 -a
option to choose the type of connection, either SYSASM
or SYSDBA
. The default value is SYSASM
and should be used when administering an Oracle ASM instance. Connect as SYSDBA
when connecting to the database instance.
For example:
$ asmcmd -a sysasm
You can specify the -v
option with the asmcmd
command to display additional information with some commands to help users diagnose problems as shown in the following example:
$ asmcmd -v
In noninteractive mode, you run a single ASMCMD command by including the command and command options on the command line that invokes 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:
asmcmd
command
options
Example 12-2 shows how to run ASMCMD in the noninteractive mode. The first example uses 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.
Type help
at the ASMCMD prompt or as a command in noninteractive mode to view general information about ASMCMD and a list of available ASMCMD commands.
You can type help
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 help
command.