我们知道用下面的方法可创建 ASM 磁盘,然后再创建逻辑的ASM磁盘组。
以 root 用户身份创建 ASM 磁盘。
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
Verify that the ASM disks are visible from every node.
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
那么如何通过ASM磁盘或是磁盘组找到ASM磁盘对应的物理磁盘呢?
也就是上面方法的反向查询,因为有些时候ASM磁盘是由以前管理员创建,新的管理员要对以前系统存储进行查询了解。
同样用oracleasm命令的另外的参数可以查询到,如下:
SQL> Select Name,path From v$asm_disk;
NAME PATH
------------------------------ ---------------
V1 ORCL:V1
V2 ORCL:V2
[root@webdbb ~]# oracleasm querydisk V1
Disk "V1" is a valid ASM disk
[root@webdbb ~]# oracleasm querydisk /dev/sdf1
Device "/dev/sdf1" is marked an ASM disk with the label "V5"
[oracle@webdbb ~]$ /etc/init.d/oracleasm querydisk -d V5
Disk "V5" is a valid ASM disk on device [8, 81]
[oracle@webdbb ~]$ ll /dev/sd*1
brw-rw---- 1 root disk 8, 1 4月 28 21:37 /dev/sda1
brw-rw---- 1 root disk 8, 17 4月 28 13:37 /dev/sdb1
brw-rw---- 1 root disk 8, 33 4月 28 13:37 /dev/sdc1
brw-rw---- 1 root disk 8, 49 4月 28 13:37 /dev/sdd1
brw-rw---- 1 root disk 8, 65 4月 28 13:37 /dev/sde1
brw-rw---- 1 root disk 8, 81 4月 28 13:37 /dev/sdf1
[root@webdbb ~]# fdisk -l
Disk /dev/sda: 359.7 GB, 359701413888 bytes
255 heads, 63 sectors/track, 43731 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 42202 338883142+ 83 Linux
/dev/sda3 42203 43731 12281692+ 82 Linux swap
... ...
Disk /dev/sdf: 107.3 GB, 107373920256 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdf1 1 13054 104856223+ 83 Linux
下面是oracle官方文档关于oracleasm管理ASM的说明:
Administering the Automatic Storage Management Library Driver and Disks
To administer the Automatic Storage Management library driver and disks, use the oracleasm initialization script. with different options, as follows:
configure | Use the configure option to reconfigure the Automatic Storage Management library driver, if necessary: # /etc/init.d/oracleasm configure |
enabledisable | Use the disable and enable options to change the behavior. of the Automatic Storage Management library driver when the system starts. The enableoption causes the Automatic Storage Management library driver to load when the system starts: # /etc/init.d/oracleasm enable |
startstoprestart | Use the start, stop, and restart options to load or unload the Automatic Storage Management library driver without restarting the system: # /etc/init.d/oracleasm restart |
createdisk | Use the createdisk option to mark a disk device for use with the Automatic Storage Management library driver and give it a name: # /etc/init.d/oracleasm createdisk DISKNAMEdevicename |
deletedisk | Use the deletedisk option to unmark a named disk device: # /etc/init.d/oracleasm deletedisk DISKNAME Caution: Do not use this command to unmark disks that are being used by an Automatic Storage Management disk group. You must drop the disk from the Automatic Storage Management disk group before you unmark it. |
querydisk | Use the querydisk option to determine whether a disk device or disk name is being used by the Automatic Storage Management library driver: # /etc/init.d/oracleasm querydisk {DISKNAME | devicename} |
listdisks | Use the listdisks option to list the disk names of marked Automatic Storage Management library driver disks: # /etc/init.d/oracleasm listdisks |
scandisks | Use the scandisks option to enable cluster nodes to identify which shared disks have been marked as Automatic Storage Management library driver disks on another node: # /etc/init.d/oracleasm scandisks |
另外一个查看OracleASM磁盘信息的命令:kfod
注意:这也是只能查询逻辑磁盘使用情况,不能查看对应的物理磁盘。
[oracle@localhost ~]$ which kfod
/u01/oracle/product/10.2.0.1/db_1/bin/kfod
[oracle@localhost ~]$ kfod -h
_asm_a/llow_only_raw_disks KFOD allow only raw devices [_asm_allow_only_raw_disks=TRUE/(FALSE)]
_asm_l/ibraries ASM Libraries[_asm_libraries='lib1','lib2',...]
_asms/id ASM Instance[_asmsid=sid]
a/sm_diskstring ASM Diskstring [asm_diskstring='discoverystring', 'discoverystring' ...]
d/isks Disks to discover [disks=raw,asm,all]
g/roup Group discover [group=controlfile]
n/ohdr KFOD header suppression [nohdr=TRUE/(FALSE)]
o/p KFOD options type [OP=DISKS/GROUPS/ALL]
p/file ASM parameter file [pfile='parameterfile']
s/tatus Include disk header status [status=TRUE/(FALSE)]
v/erbose KFOD verbose errors [verbose=TRUE/(FALSE)]
[oracle@localhost ~]$ kfod d=all
--------------------------------------------------------------------------------
Disk Size Path
================================================================================
1: 10236 Mb ORCL:VOL1
2: 4094 Mb ORCL:VOL2
3: 12284 Mb ORCL:VOL3
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME
================================================================================
+ASM /u01/oracle/product/10.2.0.1/db_1
select name,total_mb,free_mb, (total_mb-free_mb) used from v$asm_diskgroup;
SQL> select name,total_mb,free_mb, (total_mb-free_mb) used from v$asm_diskgroup;
NAME TOTAL_MB FREE_MB USED------------------------------ ---------- ---------- ----------
ORADATA 26614 24595 2019