==============================
-- 使用ASMCMD 工具管理ASM目录及文件
--==============================
在ASM实例中,所有的存储于ASM磁盘组中的文件对于操作系统命令而言是不可访问的,因此也无法使用常规的命令来操纵ASM磁盘中的文
件。所幸的是,我们有ASMCMD工具来代替操作系统命令来完成这部分工作。ASMCMD工具提供了类似于操作系统的常用命令,如ls , du ,find
,cd ,rm ,mkdir等等。借助这些工具可以更轻松的完成ASM实例的相关管理工作。
有关ASM的相关参考:
1.ASMCMD文件所在的位置
[[email protected] ~]# su - oracle
[[email protected] ~]$ which asmcmd
/u01/oracle/10g/bin/asmcmd
2.启动ASMCMD
[[email protected] ~]$ export ORACLE_SID=+ASM --启动前要设定ORACLE_SID环境变量
[[email protected] ~]$ 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.具体用法
[[email protected] ~]$ 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
ASMCMD> pwd --显示当前路径
+
ASMCMD> cd +DG1
ASMCMD> pwd
+DG1
ASMCMD> du
Used_MB Mirror_used_MB
732 1469
ASMCMD> find -t datafile +DG1/asmdb sys* --find 用于查找对象
+DG1/asmdb/DATAFILE/SYSAUX.261.734885459
+DG1/asmdb/DATAFILE/SYSTEM.259.734885389
ASMCMD> ls -l +DG1/asmdb
Type Redund Striped Time Sys Name
Y CONTROLFILE/
Y DATAFILE/
Y ONLINELOG/
Y PARAMETERFILE/
Y TEMPFILE/
N spfileasmdb.ora => +DG1/ASMDB/PARAMETERFILE/spfile.264.734886407
ASMCMD> ls -l +DG1/asmdb/spfi*
Type Redund Striped Time Sys Name
N spfileasmdb.ora => +DG1/ASMDB/PARAMETERFILE/spfile.264.734886407
ASMCMD> pwd
+DG1
ASMCMD> cd asmdb --cd 命令改变当前目录
ASMCMD> pwd
+DG1/asmdb
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileasmdb.ora
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED NORMAL N N 512 4096 1048576 3058 1498 0 749 0 DG1/
MOUNTED NORMAL N N 512 4096 1048576 200 98 0 49 0 DG2/
MOUNTED EXTERN N N 512 4096 1048576 3074 2949 0 2949 0 REV/
ASMCMD> mkdir +DG2/asmdb/bakfile --mkdir 创建目录
ASMCMD> ls -l +DG2/asmdb/bakfile
ASMCMD> rm +DG2/asmdb/bakfile --rm 删除目录
ASMCMD> ls -l +DG2/asmdb/bakfile
asmcmd: entry ‘bakfile‘ does not exist in directory ‘+DG2/asmdb/‘
ASMCMD> exit --退出asmcmd命令行
4.从上面的描述可以看出ASMCMD工具给我们提供了很多方便,这些操作命令基本上与Liunx,Unix命令相似,通过这些操作命令可以大大简化对
ASM实例的管理。
转:http://blog.csdn.net/leshami/article/details/6134163