在11gr2中,asm已经由单独的grid软件来掌管了,另外,在11gr2中也提供了advm和acfs的特性。
先看下结构图:
Advm:asm动态卷管理
Acfs:asm cluster file sytem
有了这两个图,估计也就不用多说什么了,下面简单介绍下命令吧:
先说下advm的用法,这个其实跟linux等的lvm类似,只不过advm管理的是asm的磁盘,
如创建一个动态卷可以用两种方法:
1)用sql
用sysasm登录asm实例之后,执行
Alter diskgroup data add volume vol02 size 1g;
SQL> select volume_name,size_mb,volume_number,state,usage,volume_device from v$asm_volume;
VOLUME_NAMESIZE_MB VOLUME_NUMBER STATE
------------------------------ ---------- ------------- --------
USAGE
------------------------------
VOLUME_DEVICE
--------------------------------------------------------------------------------
VOL0110241 ENABLED
/dev/asm/vol01-442
VOL0210242 ENABLED
/dev/asm/vol02-442
VOLUME_NAMESIZE_MB VOLUME_NUMBER STATE
------------------------------ ---------- ------------- --------
USAGE
------------------------------
VOLUME_DEVICE
--------------------------------------------------------------------------------
2)用asmcmd
下面是创建卷的语法,可以直接help获得,在此贴出来一个,做简要说明。
ASMCMD> help volcreate
volcreate -G -s [--redundancy ] [--width ] [--column ] [--primary ] [-secondary ]
Create the volume in the specified diskgroup. The diskgroup
must be mounted. The volume size must be specified and must contain the
"size multiplier" K, M, G, or T. The following options may be specified:
--redundancy - "unprotected", "mirror", or "high"
--width - 4K to 1M at power of 2 intervals (default = 128K)
--column - between 1 and 8 (inclusive) (default = 4)
--primary primary region - "hot", or "cold"
--secondary mirrored region- "hot", or "cold"
其中:redundancy指的是冗余度,这个很好理解;
Width指的是条带宽度,了解raid的这个也都明白;
Primary和secondary后边都有选择hot和cold的选项,是针对这个卷中的数据来说的,其实在em上也有解释,原话是这么说的“if the data is frequently accessed and mostly read only, put primary extents in the host region and mirror extents in the cold region. if the data is frequently accessed and updated ,put both primary and mirror extents in the hot region.”
ASMCMD> volcreate -G data -s 1g vol01
ASMCMD> ls
DATA/
FRA/
ASMCMD> volinfo -a
Diskgroup Name: DATA
Volume Name: VOL01
Volume Device: /dev/asm/vol01-442
State: ENABLED
Size (MB): 1024
Resize Unit (MB): 256
Redundancy: UNPROT
Stripe Columns: 4
Stripe Width (K): 128
Usage:
Mountpath:
[root@yanfa2 ~]# cat /proc/partitions
major minor#blocksname
80570310656 sda
81104391 sda1
8251199155 sda2
838193150 sda3
841 sda4
8519543041 sda5
8697667136 sda6
87244147806 sda7
8848837568 sda8
8948837568 sda9
81051777463 sda10
2522263051048576 asm/vol01-442
通过以上的测试,可以看明白卷的用处了。还有一点需要注意,一般在安装完grid之后,默认不会启动advm和acfs的驱动,如下:
[root@yanfa2 ~]# lsmod | grep oracle
oracleasm841361
在启动acfs驱动之后,就有了advm和acfs的了,如果不启动的话,创建卷时会报错。
[root@yanfa2 ~]# /app/home/11.2.0/grid/bin/acfsload start -s
[root@yanfa2 ~]#
[root@yanfa2 ~]# lsmod | grep oracle
oracleacfs8773200
oracleadvm2217600
oracleoks2768802 oracleacfs,oracleadvm
oracleasm841361
在创建完volume之后,可以格式化设备,然后就能用在os上了,如:
[root@yanfa2 /]# mke2fs -j /dev/asm/vol01-442
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.Use tune2fs -c or -i to override.
[root@yanfa2 /]# mount /dev/asm/vol01-442 /u01
另外,也可以将卷格式化成acfs
[root@yanfa2 u01]# mkfs -t acfs /dev/asm/vol02-442
mkfs.acfs: version= 11.2.0.1.0.0
mkfs.acfs: on-disk version= 39.0
mkfs.acfs: volume= /dev/asm/vol02-442
mkfs.acfs: volume size= 1073741824
mkfs.acfs: Format complete.
[root@yanfa2 /]# mount -t acfs /dev/asm/vol02-442 /u02
挂载acfs文件格式时,需要指定文件格式
挂载之后:
[root@yanfa2 /]# df -lh
FilesystemSizeUsed Avail Use% Mounted on
/dev/asm/vol01-4421008M34M924M4% /u01
/dev/asm/vol02-4421.0G39M986M4% /u02
卷命令:volcreate, voldelete, voldisable, volenable, volinfo
volresize, volset, volstat
之后,在创建数据库时,也可以使用advm和acfs。