- 论坛徽章:
- 7
|
本帖最后由 milujite 于 2011-11-24 15:15 编辑
其实官方中文文档都有的~最近看卷的帖子比较多,自己刚好前几天做了下实验,分析给大家吧。- 实验
- 有两个磁盘c2t0d0和c3t0d0。两个盘的s0都分配20mb大小,用于存放2个metadb,并且分区表如下:
- Part Tag Flag Cylinders Size Blocks
- 0 unassigned wm 0 - 9 20.00MB (10/0/0) 40960
- 1 unassigned wm 10 - 1033 2.00GB (1024/0/0) 4194304
- 2 backup wu 0 - 4091 7.99GB (4092/0/0) 16760832
- 3 unassigned wm 1034 - 2057 2.00GB (1024/0/0) 4194304
- 4 unassigned wm 2058 - 3081 2.00GB (1024/0/0) 4194304
- 5 unassigned wm 3082 - 4091 1.97GB (1010/0/0) 4136960
- 6 unassigned wm 0 0 (0/0/0) 0
- 7 unassigned wm 0 0 (0/0/0) 0
- 8 boot wu 0 - 0 2.00MB (1/0/0) 4096
- 9 unassigned wm 0 0 (0/0/0) 0
- metadb状态:
- [root@Solaris /]#metadb -a -c 2 -f c2t0d0s0 c3t0d0s0
- [root@Solaris /]#metadb -i
- flags first blk block count
- a u 16 8192 /dev/dsk/c2t0d0s0
- a u 8208 8192 /dev/dsk/c2t0d0s0
- a u 16 8192 /dev/dsk/c3t0d0s0
- a u 8208 8192 /dev/dsk/c3t0d0s0
- r - replica does not have device relocation information
- o - replica active prior to last mddb configuration change
- u - replica is up to date
- l - locator for this replica was read successfully
- c - replica's location was in /etc/lvm/mddb.cf
- p - replica's location was patched in kernel
- m - replica is master, this is replica selected as input
- W - replica has device write errors
- a - replica is active, commits are occurring to this replica
- M - replica had problem with master blocks
- D - replica had problem with data blocks
- F - replica had format problems
- S - replica is too small to hold current data base
- R - replica had device read errors
- 创建raid0条带卷(即创建一个条带,串联里有两个组件):
- [root@Solaris /]#metainit d0 1 2 c2t0d0s1 c3t0d0s1 -i 16k
- [root@Solaris /]#metaclear c2t0d0s1 c3t0d0s1
- [root@Solaris /]#metastat -p
- d0 1 2 c2t0d0s1 c3t0d0s1 -i 32b
- [root@Solaris /]#ls -l /dev/md/*/d0
- lrwxrwxrwx 1 root root 36 Nov 6 17:29 /dev/md/dsk/d0 -> ../../../devices/pseudo/md@0:0,0,blk
- lrwxrwxrwx 1 root root 36 Nov 6 17:29 /dev/md/rdsk/d0 -> ../../../devices/pseudo/md@0:0,0,raw
- 创建raid0串联卷(即创建2个条带,每个串联里有一个组件):
- [root@Solaris /]#metainit d0 2 1 c2t0d0s1 1 c3t0d0s1
- d0: Concat/Stripe is setup
- [root@Solaris /]#metastat -p
- d0 2 1 c2t0d0s1 \
- 1 c3t0d0s1
- 创建raid0条带串联卷每个条带使用不同的交错大小(3个条带,每个串联里有2个组件,并且使用不同的交错大小)
- [root@Solaris /]#metainit d0 3 2 c2t0d0s1 c3t0d0s1 -i 64k 2 c2t0d0s3 c3t0d0s3 -i 32k 2 c2t0d0s5 c3t0d0s5 -i 16k
- d0: Concat/Stripe is setup
- [root@Solaris /]#metastat -p
- d0 3 2 c2t0d0s1 c3t0d0s1 -i 128b \
- 2 c2t0d0s3 c3t0d0s3 -i 64b \
- 2 c2t0d0s5 c3t0d0s5 -i 32b
- 通过raid0串联卷对普通分区文件系统扩容:
- [root@Solaris /]#newfs /dev/rdsk/c2t0d0s1
- newfs: /dev/rdsk/c2t0d0s1 last mounted as /mnt
- newfs: construct a new file system /dev/rdsk/c2t0d0s1: (y/n)? y
- Warning: 2048 sector(s) in last cylinder unallocated
- /dev/rdsk/c2t0d0s1: 4194304 sectors in 683 cylinders of 48 tracks, 128 sectors
- 2048.0MB in 43 cyl groups (16 c/g, 48.00MB/g, 11648 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
- 3248288, 3346720, 3445152, 3543584, 3642016, 3740448, 3838880, 3937312,
- 4035744, 4134176
- [root@Solaris /]#mount /dev/dsk/c2t0d0s1 /mnt
- [root@Solaris /]#cd /mnt
- [root@Solaris mnt]#ls
- lost+found
- [root@Solaris mnt]#touch testfile
- [root@Solaris mnt]#cd
- [root@Solaris /]#umount /mnt
- [root@Solaris /]#metainit d1 2 1 c2t0d0s1 1 c3t0d0s1 ###必须将c2t0d0s1放在第一个位置,否则原有文件系统的数据会丢失。
- d1: Concat/Stripe is setup
- [root@Solaris /]#growfs /dev/md/rdsk/d1
- Warning: 4096 sector(s) in last cylinder unallocated
- /dev/md/rdsk/d1: 8388608 sectors in 1366 cylinders of 48 tracks, 128 sectors
- 4096.0MB in 86 cyl groups (16 c/g, 48.00MB/g, 11648 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
- 7472672, 7571104, 7669536, 7767968, 7866400, 7964832, 8063264, 8161696,
- 8260128, 8358560
- [root@Solaris /]#mount /dev/md/
- admin dsk/ rdsk/
- [root@Solaris /]#mount /dev/md/dsk/d1 /mnt
- [root@Solaris /]#cd /mnt
- [root@Solaris mnt]#ls
- lost+found testfile
- raid0串联卷扩容当前的串联卷
- [root@Solaris /]#metastat -p
- [root@Solaris /]#metainit d0 1 1 c2t0d0s1
- d0: Concat/Stripe is setup
- [root@Solaris /]#newfs /dev/md/rdsk/d0
- newfs: /dev/md/rdsk/d0 last mounted as /mnt
- newfs: construct a new file system /dev/md/rdsk/d0: (y/n)? y
- /dev/md/rdsk/d0: 4194304 sectors in 1024 cylinders of 128 tracks, 32 sectors
- 2048.0MB in 45 cyl groups (23 c/g, 46.00MB/g, 11264 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
- 3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
- 4052352, 4146592
- [root@Solaris /]#mount /dev/md/dsk/d0 /mnt
- [root@Solaris /]#cd /mnt
- [root@Solaris mnt]#ls
- lost+found
- [root@Solaris mnt]#touch testfile
- [root@Solaris mnt]#cd
- [root@Solaris /]#umount /mnt
- [root@Solaris /]#metattach d0 c3t0d0s1
- d0: component is attached
- [root@Solaris /]#growfs /dev/md/rdsk/d0
- Warning: inode blocks/cyl group (358) >= data blocks (256) in last
- cylinder group. This implies 4096 sector(s) cannot be allocated.
- /dev/md/rdsk/d0: 8384512 sectors in 2047 cylinders of 128 tracks, 32 sectors
- 4094.0MB in 89 cyl groups (23 c/g, 46.00MB/g, 11264 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
- 7444992, 7539232, 7633472, 7727712, 7821952, 7916192, 8010432, 8104672,
- 8198912, 8293152
- [root@Solaris /]#mount /dev/md/dsk/d0 /mnt
- [root@Solaris /]#df -lh |grep mnt
- /dev/md/dsk/d0 3.9G 4.0M 3.8G 1% /mnt
- [root@Solaris /]#cd /mnt
- [root@Solaris mnt]#ls
- lost+found testfile
- 创建raid1卷:
- [root@Solaris /]#metainit d11 1 1 c2t0d0s1 ###创建子镜像d11
- d11: Concat/Stripe is setup
- [root@Solaris /]#metainit d12 1 1 c3t0d0s1 ###创建子镜像d12
- d12: Concat/Stripe is setup
- [root@Solaris /]#metainit d10 -m d11 ###创建镜像d10,第一个成员为d11
- d10: Mirror is setup
- [root@Solaris /]#metattach d10 d12 ###附加第二个子镜像d12到d10
- d10: submirror d12 is attached
- [root@Solaris /]#metastat -p
- d10 -m d11 d12 1
- d11 1 1 c2t0d0s1
- d12 1 1 c3t0d0s1
- [root@Solaris /]#newfs /dev/md/rdsk/d10
- newfs: construct a new file system /dev/md/rdsk/d10: (y/n)? y
- /dev/md/rdsk/d10: 4194304 sectors in 1024 cylinders of 128 tracks, 32 sectors
- 2048.0MB in 45 cyl groups (23 c/g, 46.00MB/g, 11264 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
- 3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
- 4052352, 4146592
- 创建raid1+0卷:
- [root@Solaris /]#metainit d11 1 2 c2t0d0s1 c3t0d0s1
- d11: Concat/Stripe is setup
- [root@Solaris /]#metainit d12 1 2 c2t0d0s3 c3t0d0s3
- d12: Concat/Stripe is setup
- [root@Solaris /]#metainit d10 -m d11
- d10: Mirror is setup
- [root@Solaris /]#metattach d10 d12
- d10: submirror d12 is attached
- [root@Solaris /]#metastat -p
- d10 -m d11 d12 1
- d11 1 2 c2t0d0s1 c3t0d0s1 -i 32b
- d12 1 2 c2t0d0s3 c3t0d0s3 -i 32b
- [root@Solaris /]#metastat d10
- d10: Mirror
- Submirror 0: d11
- State: Okay
- Submirror 1: d12 ###d12状态resyncing
- State: Resyncing
- Resync in progress: 2 % done
- Pass: 1
- Read option: roundrobin (default)
- Write option: parallel (default)
- Size: 8388608 blocks (4.0 GB)
- d11: Submirror of d10
- State: Okay
- Size: 8388608 blocks (4.0 GB)
- Stripe 0: (interlace: 32 blocks)
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s1 0 No Okay Yes
- c3t0d0s1 0 No Okay Yes
- d12: Submirror of d10
- State: Resyncing
- Size: 8388608 blocks (4.0 GB)
- Stripe 0: (interlace: 32 blocks)
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s3 0 No Okay Yes
- c3t0d0s3 0 No Okay Yes
- Device Relocation Information:
- Device Reloc Device ID
- c2t0d0 Yes id1,sd@n6000c29e5f98b5bb3fb5263cf1c524c6
- c3t0d0 Yes id1,sd@n6000c2982f7aef8afeb682a73edccd6a
- 为现有的文件系统(可umount)创建raid1卷:
- [root@Solaris /]#newfs /dev/rdsk/c2t0d0s1
- newfs: construct a new file system /dev/rdsk/c2t0d0s1: (y/n)? y
- Warning: 2048 sector(s) in last cylinder unallocated
- /dev/rdsk/c2t0d0s1: 4194304 sectors in 683 cylinders of 48 tracks, 128 sectors
- 2048.0MB in 43 cyl groups (16 c/g, 48.00MB/g, 11648 i/g)
- super-block backups (for fsck -F ufs -o b=#) at:
- 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
- 3248288, 3346720, 3445152, 3543584, 3642016, 3740448, 3838880, 3937312,
- 4035744, 4134176
- [root@Solaris /]#mount /dev/dsk/c2t0d0s1 /test
- [root@Solaris /]#cd /test
- [root@Solaris test]#ls
- lost+found
- [root@Solaris test]#touch testfile
- [root@Solaris /]#umount /test
- [root@Solaris /]#metainit -f d1 1 1 c2t0d0s1 ###对在线的文件系统强制创建子镜像卷d1
- d1: Concat/Stripe is setup
- [root@Solaris /]#metainit d2 1 1 c3t0d0s1 ###创建第二个子镜像d2
- d2: Concat/Stripe is setup
- [root@Solaris /]#metainit d0 -m d1 ###创建raid1镜像d0,并且第一个卷为d1
- d0: Mirror is setup
- [root@Solaris /]#umount /test
- [root@Solaris /]#metattach d0 d2
- d0: submirror d2 is attached
- [root@Solaris /]#metastat -p
- d0 -m d1 d2 1
- d1 1 1 c2t0d0s1
- d2 1 1 c3t0d0s1
- [root@Solaris /]#mount /dev/md/dsk/d0 /test
- [root@Solaris /]#cd /test/
- [root@Solaris test]#ls
- lost+found testfile
- 为swap(不能umount)创建raid1镜像:
- [root@Solaris /]#metainit -f d1 1 1 c1t0d0s1 ###swap所在的分区作为第一个子镜像卷d1
- d1: Concat/Stripe is setup
- [root@Solaris /]#metainit d2 1 1 c2t0d0s1 ###创建第二个子镜像卷d2
- d2: Concat/Stripe is setup
- [root@Solaris /]#metainit d0 -m d1 ###创建raid1镜像d0,并且第一个卷为d1
- d0: Mirror is setup
- [root@Solaris /]#vi /etc/vfstab
- /dev/md/dsk/d0 - - swap - no - ###将原来的分区替换为镜像d0
- [root@Solaris /]#reboot
- [root@Solaris /]#metastat -p
- d0 -m d1 1
- d1 1 1 c1t0d0s1
- d2 1 1 c2t0d0s1
- [root@Solaris /]#metattach d0 d2
- d0: submirror d2 is attached
- [root@Solaris /]#metastat -p
- d0 -m d1 d2 1
- d1 1 1 c1t0d0s1
- d2 1 1 c2t0d0s1
- x86平台为/创建raid1镜像:
- [root@Solaris /]#metainit -f d1 1 1 c1t0d0s0 ###/所在的分区作为第一个子镜像卷d1
- d1: Concat/Stripe is setup
- [root@Solaris /]#metainit d2 1 1 c1t1d0s0 ###创建第二个子镜像d2
- d2: Concat/Stripe is setup
- [root@Solaris /]#metastat -p
- d2 1 1 c1t1d0s0
- d1 1 1 c1t0d0s0
- [root@Solaris /]#metainit d0 -m d1 ###创建raid1镜像d0,并且第一个卷为d1
- d0: Mirror is setup
- [root@Solaris /]#metaroot d0 ###为d0安装metaroot信息
- [root@Solaris /]#lockfs -fa ###锁定文件系统,并且flush所有的脏数据
- [root@Solaris /]#reboot
- [root@Solaris /]#metattach d0 d2
- d0: submirror d2 is attached
- [root@Solaris /]#metastat -p
- d0 -m d1 d2 1
- d1 1 1 c1t0d0s0
- d2 1 1 c1t1d0s0
- [root@Solaris /]#ls -l /dev/dsk/c1t1d0s0 ###将第二个子镜像作为备用启动
- lrwxrwxrwx 1 root root 46 Nov 6 22:29 /dev/dsk/c1t1d0s0 ->
- ../../devices/pci@0,0/pci15ad,1976@10/sd@1,0:a
- [root@Solaris /]#eeprom altbootpath=/devices/pci@0,0/pci15ad,1976@10/sd@1,0:a
- [root@Solaris /]#fdisk -b /usr/lib/fs/ufs/mboot /dev/rdsk/c1t1d0p0
- Total disk size is 2088 cylinders
- Cylinder size is 16065 (512 byte) blocks
- Cylinders
- Partition Status Type Start End Length %
- ========= ====== ============ ===== === ====== ===
- 1 Active Solaris2 1 2087 2087 100
- SELECT ONE OF THE FOLLOWING:
- 1. Create a partition
- 2. Specify the active partition
- 3. Delete a partition
- 4. Change between Solaris and Solaris2 Partition IDs
- 5. Exit (update disk configuration and exit)
- 6. Cancel (exit without updating disk configuration)
- Enter Selection: 5
- [root@Solaris /]#installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t1d0s0 ###由于intabllboot被intallgrub取代,因此这里使用installgrub来安装stage1和stage2
- stage1 written to partition 0 sector 0 (abs 16065)
- stage2 written to partition 0, 273 sectors starting at 50 (abs 16115)
- 更换故障的slice
- [root@Solaris /]#metastat -p
- d10 -m d11 d12 1
- d11 1 2 c2t0d0s1 c3t0d0s1 -i 32b
- d12 1 2 c2t0d0s3 c3t0d0s3 -i 32b
- [root@Solaris /]#metareplace d10 c3t0d0s1 c3t0d0s4
- d10: device c3t0d0s1 is replaced with c3t0d0s4
- [root@Solaris /]#metastat -p
- d10 -m d11 d12 1
- d11 1 2 c2t0d0s1 c3t0d0s4 -i 32b
- d12 1 2 c2t0d0s3 c3t0d0s3 -i 32b
- d0 -m d1 d2 1
- d1 1 1 c1t0d0s0
- d2 1 1 c1t1d0s0
- [root@Solaris /]#metastat d10
- d10: Mirror
- Submirror 0: d11
- State: Resyncing
- Submirror 1: d12
- State: Okay
- Resync in progress: 5 % done
- Pass: 1
- Read option: roundrobin (default)
- Write option: parallel (default)
- Size: 8388608 blocks (4.0 GB)
- d11: Submirror of d10
- State: Resyncing
- Size: 8388608 blocks (4.0 GB)
- Stripe 0: (interlace: 32 blocks)
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s1 0 No Okay Yes
- c3t0d0s4 0 No Resyncing Yes
- d12: Submirror of d10
- State: Okay
- Size: 8388608 blocks (4.0 GB)
- Stripe 0: (interlace: 32 blocks)
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s3 0 No Okay Yes
- c3t0d0s3 0 No Okay Yes
- Device Relocation Information:
- Device Reloc Device ID
- c2t0d0 Yes id1,sd@n6000c29e5f98b5bb3fb5263cf1c524c6
- c3t0d0 Yes id1,sd@n6000c2982f7aef8afeb682a73edccd6a
- raid1卷扩容:
- [root@Solaris /]#metainit d11 1 1 c2t0d0s1
- d11: Concat/Stripe is setup
- [root@Solaris /]#metainit d12 1 1 c3t0d0s1
- d12: Concat/Stripe is setup
- [root@Solaris /]#metainit d10 -m d11
- d10: Mirror is setup
- [root@Solaris /]#metattach d10 d12
- d10: submirror d12 is attached
- [root@Solaris /]#metastat d10
- d10: Mirror
- Submirror 0: d11
- State: Okay
- Submirror 1: d12
- State: Resyncing
- Resync in progress: 6 % done
- Pass: 1
- Read option: roundrobin (default)
- Write option: parallel (default)
- Size: 4194304 blocks (2.0 GB)
- d11: Submirror of d10
- State: Okay
- Size: 4194304 blocks (2.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s1 0 No Okay Yes
- d12: Submirror of d10
- State: Resyncing
- Size: 4194304 blocks (2.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c3t0d0s1 0 No Okay Yes
- Device Relocation Information:
- Device Reloc Device ID
- c2t0d0 Yes id1,sd@n6000c29e5f98b5bb3fb5263cf1c524c6
- c3t0d0 Yes id1,sd@n6000c2982f7aef8afeb682a73edccd6a
- [root@Solaris /]#metattach d11 c2t0d0s3
- d11: component is attached
- metattach: Solaris: d10: growing of metadevice delayed
- [root@Solaris /]#metattach d12 c3t0d0s3
- d12: component is attached
- [root@Solaris /]#metastat d10
- d10: Mirror
- Submirror 0: d11
- State: Okay
- Submirror 1: d12
- State: Resyncing
- Resync in progress: 66 % done
- Pass: 1
- Read option: roundrobin (default)
- Write option: parallel (default)
- Size: 4194304 blocks (2.0 GB)
- d11: Submirror of d10
- State: Okay
- Size: 8388608 blocks (4.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s1 0 No Okay Yes
- Stripe 1:
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s3 0 No Okay Yes
- d12: Submirror of d10
- State: Resyncing
- Size: 8388608 blocks (4.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c3t0d0s1 0 No Okay Yes
- Stripe 1:
- Device Start Block Dbase State Reloc Hot Spare
- c3t0d0s3 0 No Okay Yes
- Device Relocation Information:
- Device Reloc Device ID
- c2t0d0 Yes id1,sd@n6000c29e5f98b5bb3fb5263cf1c524c6
- c3t0d0 Yes id1,sd@n6000c2982f7aef8afeb682a73edccd6a
- [root@Solaris /]#metattach d10
- [root@Solaris /]#metastat d10
- d10: Mirror
- Submirror 0: d11
- State: Okay
- Submirror 1: d12
- State: Okay
- Pass: 1
- Read option: roundrobin (default)
- Write option: parallel (default)
- Size: 8388608 blocks (4.0 GB)
- d11: Submirror of d10
- State: Okay
- Size: 8388608 blocks (4.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s1 0 No Okay Yes
- Stripe 1:
- Device Start Block Dbase State Reloc Hot Spare
- c2t0d0s3 0 No Okay Yes
- d12: Submirror of d10
- State: Okay
- Size: 8388608 blocks (4.0 GB)
- Stripe 0:
- Device Start Block Dbase State Reloc Hot Spare
- c3t0d0s1 0 No Okay Yes
- Stripe 1:
- Device Start Block Dbase State Reloc Hot Spare
- c3t0d0s3 0 No Okay Yes
- Device Relocation Information:
- Device Reloc Device ID
- c3t0d0 Yes id1,sd@n6000c2982f7aef8afeb682a73edccd6a
- c2t0d0 Yes id1,sd@n6000c29e5f98b5bb3fb5263cf1c524c6
- c1t1d0 Yes id1,sd@n6000c29cc60ef436309c688c80a0880a
- c1t0d0 Yes id1,sd@n6000c297b0d86f9e7c02a2710f66ceaa
- 删除/的raid1卷:
- [root@Solaris /]#metastat -p
- d0 -m d1 d2 1
- d1 1 1 c1t0d0s0
- d2 1 1 c1t1d0s0
- [root@Solaris /]#metadetach d0 d2
- d0: submirror d2 is detached
- [root@Solaris /]#metaroot /dev/dsk/c1t0d0s0 ###安装metaroot到c1t0d0s0(未创建raid1前的slice)
- [root@Solaris /]#reboot
- [root@Solaris /]#metaclear -r d0
- d0: Mirror is cleared
- d1: Concat/Stripe is cleared
- [root@Solaris /]#metaclear -r d2
- d2: Concat/Stripe is cleared
- [root@Solaris /]#metastat -p
复制代码 |
|