- 论坛徽章:
- 0
|
SVM 学习笔记:
1.solaris 将1块硬盘分为8个分区(0-7 slice)。IA架构为10个分区。
2.常用分区:
slice
0 /
1 swap
2 entire disk
5 opt
6 /export
3.SVM管理思想有2种:
a.将磁盘分区创建为逻辑卷,然后再创建raid。比如raid1。
b.直接利用磁盘分区创建raid,比如raid5,raid0。
SVM 需要有一个stat db保持卷,raid信息。所以一般需要在多个磁盘创建stat db。
#metadb -f -a -c 2 c0d0s3 c0d1s3 c1d0s3 c1d1s3
4.常用命令:
metadb 创建stat db。
metainit 创建逻辑卷,创建raid命令。
metastat 查看卷,raid信息。
metaclear 删除卷,删除raid。
metareplace:
更换卷中的分区。英文意思是更换卷中的组件。但是我理解一般就是更换卷的分区。还有一个作用就是启用卷中的分区,使得该卷进行重新同步。
#metareplace -e d11 c1d1s4 启用d11中的c1d1s4分区。
#metareplace d11 c1d0s4 c1d1s4 利用c1d1s4更换卷d11中损坏的c1d0s4
metaonline/metaoffline: 该命令在raid1中使用,但是我觉得没有必要,假如磁盘损坏了,不需要offline,直接detach,再attach一个就好了,谁让他是raid1呢。:)
metattach/metadetach: 向创建好的raid中添加/删除卷和分区。
metahs: 修改热备池中分区。
metaparam:修改raid配置,比如raid0的读,写属性,还有就是将热备池绑定到raid上。
growfs: 在线扩展卷集大小。
格式:growfs -M /mount-point /device-rdsk-point
5.各raid创建步骤:
5.1 raid0:
创建stat db:
[root@solaris /]#metadb -f -a c0d0s3 c0d1s3 c1d0s3 c1d1s3
[root@solaris /]#metadb
flags first blk block count
a u 16 8192 /dev/dsk/c0d0s3
a u 16 8192 /dev/dsk/c0d1s3
a u 16 8192 /dev/dsk/c1d0s3
a u 16 8192 /dev/dsk/c1d1s3
raid 0 分为条带和串联2种,我们先创建串联raid 0:
[root@solaris /]#metainit d41 1 3 /dev/dsk/c0d0s4 /dev/dsk/c0d1s3 /dev/dsk/c1d0s3
d41: Concat/Stripe is setup
[root@solaris /]#metastat d41
d41: Concat/Stripe
Size: 282555 blocks
Stripe 0: (interlace: 32 blocks)
Device Start Block Dbase Reloc
c0d0s4 0 No Yes
c0d1s3 8505 Yes Yes
c1d0s3 8505 Yes Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c1d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=10000000000000000001
创建hsp:
[root@solaris /]#metainit hsp4 c1d1s5
hsp004: Hotspare pool is setup
[root@solaris /]#metaparam -h hsp4 d41
[root@solaris /]#metastat
d41: Concat/Stripe
Hot spare pool: hsp004
Size: 282555 blocks
Stripe 0: (interlace: 32 blocks)
Device Start Block Dbase Reloc
c0d0s4 0 No Yes
c0d1s3 8505 Yes Yes
c1d0s3 8505 Yes Yes
hsp004: 1 hot spare
Device Status Length Reloc
c1d1s5 Available 262710 blocks Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c1d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=10000000000000000001
c1d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=11000000000000000001
将hsp中c1d1s5更换为c1d1s4:
[root@solaris /]#metahs -r hsp4 c1d1s5 c1d1s4
hsp004: Hotspare c1d1s5 is replaced with c1d1s4
[root@solaris /]#metastat
d41: Concat/Stripe
Hot spare pool: hsp004
Size: 282555 blocks
Stripe 0: (interlace: 32 blocks)
Device Start Block Dbase Reloc
c0d0s4 0 No Yes
c0d1s3 8505 Yes Yes
c1d0s3 8505 Yes Yes
hsp004: 1 hot spare
Device Status Length Reloc
c1d1s4 Available 262710 blocks Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c1d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=10000000000000000001
c1d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=11000000000000000001
向hsp中添加分区:
[root@solaris /]#metahs -a hsp4 c1d1s5
hsp004: Hotspare is added
[root@solaris /]#metastat hsp4
hsp004: 2 hot spares
Device Status Length Reloc
c1d1s4 Available 262710 blocks Yes
c1d1s5 Available 262710 blocks Yes
Device Relocation Information:
Device Reloc Device ID
c1d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=11000000000000000001
删除hsp和raid 0:
[root@solaris /]#metaparam -h none d41
[root@solaris /]#metastat
d41: Concat/Stripe
Size: 282555 blocks
Stripe 0: (interlace: 32 blocks)
Device Start Block Dbase Reloc
c0d0s4 0 No Yes
c0d1s3 8505 Yes Yes
c1d0s3 8505 Yes Yes
hsp004: 2 hot spares
Device Status Length Reloc
c1d1s4 Available 262710 blocks Yes
c1d1s5 Available 262710 blocks Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c1d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=10000000000000000001
c1d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=11000000000000000001
[root@solaris /]#metaclear hsp4
hsp004: Hotspare pool is cleared
[root@solaris /]#metaclear d41
d41: Concat/Stripe is cleared
[root@solaris /]#metastat
条带raid0:
[root@solaris /]#metainit d41 3 1 c0d0s4 1 c0d1s4 1 c1d0s4
d41: Concat/Stripe is setup
[root@solaris /]#metastat d41
d41: Concat/Stripe
Size: 788130 blocks
Stripe 0:
Device Start Block Dbase Reloc
c0d0s4 0 No Yes
Stripe 1:
Device Start Block Dbase Reloc
c0d1s4 0 No Yes
Stripe 2:
Device Start Block Dbase Reloc
c1d0s4 0 No Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
c1d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=10000000000000000001
5.2创建raid1:
[root@solaris /]#metainit d41 1 1 c0d0s4
d41: Concat/Stripe is setup
[root@solaris /]#metainit d42 1 1 c0d1s4
d42: Concat/Stripe is setup
[root@solaris /]#metainit d40 -m d41
d40: Mirror is setup
[root@solaris /]#metastat d40
d40: Mirror
Submirror 0: d41
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 262710 blocks
d41: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s4 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
[root@solaris /]#metattach d40 d42
d40: submirror d42 is attached
[root@solaris /]#metastat d40
d40: Mirror
Submirror 0: d41
State: Okay
Submirror 1: d42
State: Resyncing
Resync in progress: 17 % done
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 262710 blocks
d41: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s4 0 No Okay Yes
d42: Submirror of d40
State: Resyncing
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s4 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
总结:创建raid1 时,先将分区创建为逻辑卷,然后将一个卷加入到raid1中,此时该卷就成为raid的一个submirror。
最后,利用metattach命令,将其他子卷也逐一添加到raid1中。
svm也支持 metainit d40 -m d41 d42 ,但是solaris手册上面说不推荐,好像是怕会出现数据不同步。
将d42 offline然后再online:
(这个我不明白什么意思,好像是离线后进行维护,更换硬盘吗?使用metattach/metadetach不是可以完成吗,反正我不清楚,高手指点)
[root@solaris /]#metaoffline d40 d42
d40: submirror d42 is offlined
[root@solaris /]#metastat d40
d40: Mirror
Submirror 0: d41
State: Okay
Submirror 1: d42
State: Needs maintenance
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 262710 blocks
d41: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s4 0 No Okay Yes
d42: Submirror of d40
State: Needs maintenance
Invoke: metaonline d40 d42
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s4 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
[root@solaris /]#metaonline d40 d42
d40: submirror d42 is onlined
[root@solaris /]#metastat d40
d40: Mirror
Submirror 0: d41
State: Okay
Submirror 1: d42
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 262710 blocks
d41: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s4 0 No Okay Yes
d42: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d1s4 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
c0d1 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
将d42从raid1中分离出来,这个是更换坏分区时候用的:
[root@solaris /]#metadetach d40 d42
d40: submirror d42 is detached
[root@solaris /]#metastat d40
d40: Mirror
Submirror 0: d41
State: Okay
Pass: 1
Read option: roundrobin (default)
Write option: parallel (default)
Size: 262710 blocks
d41: Submirror of d40
State: Okay
Size: 262710 blocks
Stripe 0:
Device Start Block Dbase State Reloc Hot Spare
c0d0s4 0 No Okay Yes
Device Relocation Information:
Device Reloc Device ID
c0d0 Yes id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001
删除raid1:
[root@solaris /]#metaclear -r d40
d40: Mirror is cleared
d41: Concat/Stripe is cleared
5.3 如何创建raid1到/目录上面。
[root@solaris /]#metainit -f d41 1 1 c0d0s0 ---> 注意使用 -f参数
d41: Concat/Stripe is setup
[root@solaris /]#metainit -f d42 1 1 c0d1s0
d42: Concat/Stripe is setup
[root@solaris /]#metainit d40 -m d41
d40: Mirror is setup
[root@solaris /]#metaroot d40 ---> 修改/etc/system /etc/vfstab 文件
[root@solaris /]#lockfs -fa
[root@solaris /]#reboot
[root@solaris /]#metattach d40 d42
此时执行df就会发现/ 已经mount 在 d40上面了,而且/etc/vfstab里面相应的项目也已经改变了。
如何取消/使用raid1:
metadetach d40 d42
metaroot /dev/c0d0s0
lockfs -fa
reboot
metaclear -r d40
metaclear d42
5.4 如何创建swap的raid1卷
步骤类似在/上面创建raid1。
metainit -f d41 1 1 c0d0s1
metainit d42 1 1 c0d1s1
metainit d40 -m d41
手动修改/etc/vfstab,将swap项更改为/dev/md/dsk/d40
reboot
metattach d40 d42
swap -l 就可以看到swap已经在使用d40卷了。
5.5 如何创建raid5
#metainit d50 -r c0d0s4 c0d1s4 c1d0s4
#metastat d50
5.6 创建hsp
#metainit hsp4 c1d1s4
#metaparam -h hsp4 d50 --->将hsp4绑定到d50
#metahs -a hsp4 c0t0d0s4 -->增加hsp4中的热备分区
#metahs -d hsp4 c0t0d0s4 --> 删除hsp4中的热备分区
#metahs -r hsp4 c0t0d0s4 c0t1d0s4 更换hsp4中的热备分区
#metaparam -h none d50 -->取消d50上面的所有热备绑定
#metaclear hsp4 -->删除hsp4卷
#metaclear d50 -->删除d50卷
5.7 growfs
growfs支持在线扩展文件系统大小。语法为:
[root@solaris /]#growfs --h
/usr/sbin/growfs: illegal option -- -
usage: growfs [ -M mount-point ] [ newfs-options ] raw-special-device
#growfs -M /home1 /dev/md/rdsk/d50 |
|