【ASM】Oracle ASM命令行工具
ASMCMD概述
ASMCMD命令是命令行工具,可以用来管理Oracle ASM实例、磁盘组、磁盘组的文件访问控制、磁盘组内的文件和目录、模板和卷。该命令可以运行在交互模式或者非交互模式。
ASMCMD命令类型
ASMCMD命令类型有以下:
- ASMCMD实例管理命令:dsget、dsset、lsct、lsop、lspwusr、orapwusr、shutdown、spbackup、spcopy、spget、spmove、spset、startup;
- ASMCMD文件管理命令:cd、cp、du、find、ls、lsof、mkalias、pwd、rm、rmalias;
- ASMCMD磁盘组管理命令:chdg、chkdg、dropdg、iostat、lsattr、lsdg、lsdsk、lsod、md_backup、md_restore、mkdg、mount、offline、online、rebal、remap、setattr、umount;
- ASMCMD模板管理命令:chtmpl、lstmpl、mktmpl、rmtmpl;
- ASMCMD文件访问控制命令:chgrp、chmod、chown、groups、grpmod、lsgrp、lsusr、mkgrp、mkusr、passwd、rmgrp、rmusr;
- ASMCMD卷管理命令:volcreate、voldelete、voldisable、volenable、volinfo、volresize、volset、volstat;
ASM示例
1、启动ASMCMD命令行;
[grid@strong ~]$ asmcmd
ASMCMD>
2、查看ASMCMD版本信息;
[grid@strong ~]$ asmcmd -V
asmcmd version 11.2.0.4.0
3、查看ASMCMD帮助信息;
[grid@strong ~]$ asmcmd help
asmcmd [-V] [-v <errors|warnings|normal|info|debug>] [--privilege <sysasm|sysdba>] [-p] [command]
asmcmd_no_conn_str
Starts asmcmd (if no parameters) or executes the command with given parameters
asmcmd [-V] [-v <errors|warnings|normal|info|debug>] [--privilege <sysasm|sysdba>] [-p] [command]
Specify the connect string after the -c option to use the listener to
connect. By default, ASMCMD asks for a password in a non-echoing
prompt, unless the password is specified as part of the connect string.
The connect identifier is in the form of "host:port:sid", with the
host and the port being option. Host defaults to "localhost" and port
to 1521. If the sid is not specified as a part of the connect
identifier, then it is read from the environment variable ORACLE_SID.
If no connect string is used, then environment variables
ORACLE_HOME and ORACLE_SID determine the instance to which the program
connects, and asmcmd establishes a bequeath connection to the it, in
the same manner as a SQLPLUS / AS SYSASM. The user must be a member
of the SYSDBA group to exercise this option.
Specifying the -V option prints the asmcmd version number and
exits immediately.
Specifying the -v option prints extra information that can help
advanced users diagnose problems.
Specify the --privilege option to choose the type of connection. There are
only two possibilities: connecting as SYSASM or as SYSDBA.
The default value if this option is unspecified is SYSASM:
Specifying the -p option allows the current directory to be displayed
in the command prompt, like so:
ASMCMD [+DATA/ORCL/CONTROLFILE] >
The parameter command specifies one of the following commands, along
with its parameters.
Type "help [command]" to get help on a specific ASMCMD command.
commands:
--------
md_backup, md_restore
lsattr, setattr
cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias
mkdir, pwd, rm, rmalias
chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount
offline, online, rebal, remap, umount
dsget, dsset, lsop, shutdown, spbackup, spcopy, spget
spmove, spset, startup
chtmpl, lstmpl, mktmpl, rmtmpl
chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr
mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr
volcreate, voldelete, voldisable, volenable, volinfo
volresize, volset, volstat
4、查看具体某一个命令的帮助信息;
ASMCMD> help ls
ls
Lists the contents of an Oracle ASM directory, the attributes of the
specified file, or the names and attributes of all disk groups from the
V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view. The default view is
V$ASM_DISKGROUP_STAT.
ls [-lsdtLg] [--absolutepath][--suppressheader] [--reverse][--permission][pattern]
The options for the ls command are described below.
(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). When
used in the "ls -l +" command, displays directory
information. Note that not all possible file
attributes or disk group attributes are included.
To view the complete set of column values for a file
or a disk group, query the V$ASM_FILE and
V$ASM_DISKGROUP views.
-s - Displays file space information.
-d - If the value for the name argument is a directory,
then ls displays information about that directory,
rather than the directory contents. Typically used
with another flag, such as the -l flag.
--reverse - Reverses the sort order of the listing.
-t - Sorts the listing by timestamp (latest first)
instead of by name.
-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.
--absolutepath - For each listed file, displays the absolute path of
the alias that references it, if any.
-g - Selects from GV$ASM_DISKGROUP_STAT, or from
GV$ASM_DISKGROUP if the -c flag is also specified.
GV$ASM_DISKGOUP.INST_ID is included in the output.
--suppressheader - 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.
Command options enable you to modify and customize the output of
the command. Table 12-20 lists the options and their descriptions.
For disk group information, this command queries the
V$ASM_DISKGROUP_STAT view by default, which can be modified by
using the -g option.
If you specify all of the options, then the command shows a union
of their attributes, with duplicates removed.
If you enter ls +, then the command returns information about all
disk groups, including information about whether the disk groups
are mounted.
name - can be a filename or directory name,
including wildcard characters.
If name is a directory name, then ls lists the contents of the
directory and depending on flag settings, ls also lists information
about each directory member. Directories are listed with a trailing
slash (/) to distinguish them from files.
If the value that you enter for name is a filename, then ls lists
the file and depending on the flag settings, ls also lists
information about the file. The file must be located in the current
directory if the filename is specified with a relative path.
The following are examples of the ls command that display various
information about directories and the contents of the directories.
ASMCMD [+] > ls +data/orcl/datafile
EXAMPLE.265.691577295
SYSAUX.257.691577149
SYSTEM.256.691577149
UNDOTBS1.258.691577151
USERS.259.691577151
ASMCMD [+] > ls -lt +data/orcl/datafile
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE JUL 13 08:00:00 Y EXAMPLE.265.691577295
DATAFILE MIRROR COARSE JUL 13 05:00:00 Y SYSAUX.257.691577149
DATAFILE MIRROR COARSE JUL 13 02:00:00 Y USERS.259.691577151
DATAFILE MIRROR COARSE JUL 13 02:00:00 Y UNDOTBS1.258.691577151
DATAFILE MIRROR COARSE JUL 13 02:00:00 Y SYSTEM.256.691577149
ASMCMD [+] > ls -l +data/orcl/datafile/sy*
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE JUL 13 05:00:00 Y SYSAUX.257.691577149
DATAFILE MIRROR COARSE JUL 13 02:00:00 Y SYSTEM.256.691577149
ASMCMD [+] > ls -s +data/orcl/datafile
Block_Size Blocks Bytes Space Name
8192 12801 104865792 214958080 EXAMPLE.265.691577295
8192 88321 723525632 1452277760 SYSAUX.257.691577149
8192 88321 723525632 1452277760 SYSTEM.256.691577149
8192 7681 62922752 131072000 UNDOTBS1.258.691577151
8192 641 5251072 12582912 USERS.259.691577151
ASMCMD [+] > ls --permission +data/orcl/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>