在ASM实例中,所有的存储于ASM磁盘组中的文件对于操作系统命令而言是不可访问的,因此也无法使用常规的命令来操纵ASM磁盘中的文件。所幸的是,我们有ASMCMD工具来代替操作系统命令来完成这部分工作。ASMCMD工具提供了类似于操作系统的常用命令,如ls , du ,find,cd ,rm ,mkdir等等。借助这些工具可以更轻松的完成ASM实例的相关管理工作。
1.ASMCMD文件所在的位置
[root@oradb ~]# su - oracle
[oracle@oradb ~]$ which asmcmd
/u01/oracle/10g/bin/asmcmd
2.启动ASMCMD
[oracle@oradb ~]$ export ORACLE_SID=+ASM --启动前要设定ORACLE_SID环境变量
[oracle@oradb ~]$ asmcmd
ASMCMD> help
asmcmd [-p] [command] --该方式可以直接完成相应的功能而不需要进入到ASMCMD提示符下
The environment variables ORACLE_HOME and ORACLE_SID determine the instance to which the program connects, and ASMCMD establishes a bequeath connection to it, in the same manner as a SQLPLUS / AS SYSDBA. The user must be a member of the SYSDBA group.Specifying the -p option allows the current directory to be displayed in the command prompt, like so:
ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >
[command] specifies one of the following commands, along with its parameters.
Type "help [command]" to get help on a specific ASMCMD command.
--在asmcmd命令提示符下,输入help [命令] ,则显示该命令帮助信息
commands:
--------
cd
du
find
help
ls
lsct
lsdg
mkalias
mkdir
pwd
rm
rmalias
3.具体用法
[oracle@oradb ~]$ asmcmd -p ls -l --无需进入到ASMCMD命令提示符下完成相应的功能
State Type Rebal Unbal Name
MOUNTED NORMAL N N DG1/
MOUNTED NORMAL N N DG2/
MOUNTED EXTERN N N REV/
ASMCMD> ls -l --查看磁盘组的基本信息
State Type Rebal Unbal Name
MOUNTED NORMAL N N DG1/
MOUNTED NORMAL N N DG2/
MOUNTED EXTERN N N REV/
ASMCMD> ls -s --查看磁盘组的详细信息,如磁盘大小,可用空间,扇区大小等
Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
512 4096 1048576 3058 1498 0 749 0 DG1/
512 4096 1048576 200 98 0 49 0 DG2/
512 4096 1048576 3074 2949 0 2949 0 REV/
ASMCMD> du --查看当前目录磁盘已使用的容量
Used_MB Mirror_used_MB
804 1541