root@wll ~ # apt-get install mdadm root@wll ~ # cat /etc/mdadm/mdadm.conf ...
root@wll:~# mdadm --create --verbose /dev/md0 --level=linear --raid-devices=2 /dev/sdb /dev/sdc
mdadm: chunk size defaults to 64K
mdadm: array /dev/md0 started.
root@wll:~# cat /proc/mdstat
Personalities : [linear]
md0 : active linear sdc[1] sdb[0]
4194176 blocks 64k rounding
unused devices: <none>
root@wll:~# mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb /dev/sdc
mdadm: array /dev/md0 started.
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid0 sdc[1] sdb[0]
4194176 blocks 64k chunks
unused devices: <none>
root@wll:~# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 --spare-disks=1 /dev/sdb /dev/sdc /dev/sdd
mdadm: array /dev/md0 started.
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid1 sdd[2](S) sdc[1] sdb[0]
2097088 blocks [2/2] [UU]
unused devices: <none>
root@wll:~# mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
mdadm: array /dev/md0 started.
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdd[2] sdc[1] sdb[0]
4194176 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
root@wll:~# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90
Creation Time : Wed Oct 13 16:51:17 2010
Raid Level : raid1
Array Size : 2097088 (2048.28 MiB 2147.42 MB)
Used Dev Size : 2097088 (2048.28 MiB 2147.42 MB)
Raid Devices : 2
Total Devices : 3
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Mon Oct 18 09:36:43 2010
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
UUID : cd25e116:d89492c5:442adbe2:10e49378
Events : 0.56
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
2 8 48 - spare /dev/sdd
root@wll:~# mdadm --stop /dev/md0 mdadm: stopped /dev/md0
root@wll:~# mkfs -t ext3 /dev/md0 root@wll:~# mkdir /mnt root@wll:~# mount /dev/md0 /mnt root@wll:~# df -h /mnt 파일시스템 크기 사용됨 사용가능 사용율% 마운트 됨 /dev/md0 4.0G 73M 3.7G 2% /mnt root@wll:~#
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdd[2] sdc[1] sdb[0]
4194176 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
root@wll:~# mdadm /dev/md0 --fail /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdd[2] sdc[1] sdb[3](F)
4194176 blocks level 5, 64k chunk, algorithm 2 [3/2] [_UU]
unused devices: <none>
root@wll:~# mdadm /dev/md0 --remove /dev/sdb
mdadm: hot removed /dev/sdb
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdd[2] sdc[1]
4194176 blocks level 5, 64k chunk, algorithm 2 [3/2] [_UU]
unused devices: <none>
[/dev/sdb 디스크 교체]
root@wll:~# mdadm /dev/md0 --add /dev/sdb
mdadm: re-added /dev/sdb
root@wll:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdb[0] sdd[2] sdc[1]
4194176 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
root@wll:~# apt-get install lvm2 root@wll:~# apt-get install reiserfsprogs
root@wll:~# pvcreate /dev/sdb Wiping software RAID md superblock on /dev/sdb Physical volume "/dev/sdb" successfully created root@wll:~# pvcreate /dev/sdc Wiping software RAID md superblock on /dev/sdc Physical volume "/dev/sdc" successfully created root@wll:~# pvcreate /dev/sdd Wiping software RAID md superblock on /dev/sdd Physical volume "/dev/sdd" successfully created root@wll:~# pvscan PV /dev/sdb lvm2 [2.00 GiB] PV /dev/sdc lvm2 [2.00 GiB] PV /dev/sdd lvm2 [2.00 GiB] Total: 3 [6.00 GiB] / in use: 0 [0 ] / in no VG: 3 [6.00 GiB] root@wll:~# pvdisplay --- Physical volume --- PV Name /dev/sdb VG Name VG_1 PV Size 2.00 GiB / not usable 1.00 GiB Allocatable yes PE Size 1.00 GiB Total PE 1 Free PE 1 Allocated PE 0 PV UUID 3mCSkv-ODb9-i8h7-qLGM-POVp-az6N-CKk9le --- Physical volume --- ... root@wll:~#만약 오류 발생시 0번 섹터를 초기화하고 다시 시도해 본다.
root@wll:~# dd if=/dev/zero of=/dev/sdb bs=512 count=1 root@wll:~# blockdev --rereadpt /dev/hdb
root@wll:~# vgcreate VG_1 /dev/sdb /dev/sdc Volume group "VG_1" successfully created root@wll:~# vgdisplay --- Volume group --- VG Name VG_1 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 3.99 GiB PE Size 4.00 MiB Total PE 1022 Alloc PE / Size 0 / 0 Free PE / Size 1022 / 3.99 GiB VG UUID FZgrFY-AtKn-JTLf-YMQG-gkoZ-C0qN-WFd7xK
root@wll:~# vgchange -a y VG_1 0 logical volume(s) in volume group "VG_1" now active
root@wll:~# vgextend VG_1 /dev/sdd Volume group "VG_1" successfully extended root@wll:~# vgdisplay --- Volume group --- VG Name VG_1 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 5.99 GiB PE Size 4.00 MiB Total PE 1533 Alloc PE / Size 0 / 0 Free PE / Size 1533 / 5.99 GiB VG UUID FZgrFY-AtKn-JTLf-YMQG-gkoZ-C0qN-WFd7xK
root@wll:~# pvmove /dev/sdd root@wll:~# vgreduce VG_1 /dev/sdd Removed "/dev/sdd" from volume group "VG_1"pvmove의 두번째 인자가 없으면 PV에서 사용하고 있는 익스텐드를 다른 곳으로 옮긴다.
root@wll:~# vgchange -a n VG_1 0 logical volume(s) in volume group "VG_1" now active root@wll:~# vgremove VG_1 Volume group "VG_1" successfully removed
root@wll:~# pvremove /dev/sdb /dev/sdc /dev/sdd Labels on physical volume "/dev/sdb" successfully wiped Labels on physical volume "/dev/sdc" successfully wiped Labels on physical volume "/dev/sdd" successfully wiped
root@wll:~# lvcreate -L 1g -n LV_1 VG_1 Logical volume "LV_1" created root@wll:~# lvscan ACTIVE '/dev/VG_1/LV_1' [1.00 GiB] inherit root@wll:~# lvdisplay --- Logical volume --- LV Name /dev/VG_1/LV_1 VG Name VG_1 LV UUID DceWpk-MLbL-tGry-QVaC-CzLX-uT4A-yoekYx LV Write Access read/write LV Status available # open 0 LV Size 1.00 GiB Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0/dev/VG_1/LV_1 이 블록장치 경로다.
root@wll:~# mkfs -t reiserfs /dev/VG_1/LV_1
root@wll:~# mount /dev/VG_1/LV_1 /mnt
root@wll:~# df -h /mnt
파일시스템 크기 사용됨 사용가능 사용율% 마운트 됨
/dev/mapper/VG_1-LV_1
1.0G 33M 992M 4% /mnt
root@wll:~# lvextend -L +1g /dev/VG_1/LV_1 Extending logical volume LV_1 to 2.00 GiB Logical volume LV_1 successfully resized root@wll:~# lvextend -L 4g /dev/VG_1/LV_1 Extending logical volume LV_1 to 4.00 GiB Logical volume LV_1 successfully resizedReiserFS의 경우 아래와 같이 작업한다.
root@wll:~# resize_reiserfs -f /dev/VG_1/LV_1
resize_reiserfs 3.6.21 (2009 www.namesys.com)
resize_reiserfs: On-line resizing finished successfully.
root@wll:~# df -h /mnt
파일시스템 크기 사용됨 사용가능 사용율% 마운트 됨
/dev/mapper/VG_1-LV_1
4.0G 33M 4.0G 1% /mnt
ext2/ext3: unmount 후 [resize2fs /dev/VG_1/LV_1]
root@wll:~# umount /mnt
root@wll:~# resize_reiserfs -s-1G /dev/VG_1/LV_1
...
root@wll:~# lvreduce -L-1G /dev/VG_1/LV_1
WARNING: Reducing active logical volume to 3.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LV_1? [y/n]: y
Reducing logical volume LV_1 to 3.00 GiB
Logical volume LV_1 successfully resized
root@wll:~# mount /dev/VG_1/LV_1 /mnt
root@wll:~# df -h /mnt
파일시스템 크기 사용됨 사용가능 사용율% 마운트 됨
/dev/mapper/VG_1-LV_1
3.0G 33M 3.0G 2% /mnt
root@wll:~# umount /mnt root@wll:~# lvremove /dev/VG_1/LV_1
root@wll:~# lvcreate -L 512m -s -n LV_1_SNAP`date "+%Y%m%d"` /dev/VG_1/LV_1 Logical volume "LV_1_SNAP20101017" created root@wll:~# mkdir /mntbackup root@wll:~# mount /dev/VG_1/LV_1_SNAP`date "+%Y%m%d"` /mntbackup root@wll:~# tar cvfz mntbackup.tar.gz /mntbackup스냅샷의 삭제는 LV를 지우는 작업과 동일하다.
root@wll:~# umount /mntbackup root@wll:~# lvremove /dev/VG_1/LV_1_SNAP`date "+%Y%m%d"` Do you really want to remove active logical volume LV_1_SNAP20101017? [y/n]: y Logical volume "LV_1_SNAP20101017" successfully removed
root@wll:~# unmount /mnt root@wll:~# vgchange -a n VG_1 root@wll:~# vgexport VG_1 디스크를 전부 wll2 시스템으로 이전 root@wll2:~# pvscan root@wll2:~# vgimport VG_1 root@wll2:~# vgchange -a y VG_1 root@wll2:~# mount /dev/VG_1/LV_1 /mnt
root@wll:~# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 --spare-disks=1 \ /dev/sdb /dev/sdc /dev/sdd root@wll:~# mdadm --assemble /dev/md0 /dev/sdb /dev/sdc /dev/sdd root@wll:~# pvcreate /dev/md0 root@wll:~# vgcreate VG_1 /dev/md0 root@wll:~# lvcreate -L 1G -n LV_1 VG_1
root@wll:~# mkfs -t reiserfs /dev/VG_1/LV_1 root@wll:~# mkdir /u01 root@wll:~# mount /dev/VG_1/LV_1 /u01
root@wll:~# echo "DEVICES /dev/sdb /dev/sdc /dev/sdd" > /etc/mdadm/mdadm.conf root@wll:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf root@wll:~# vi /etc/mdadm/mdadm.conf ARRAY 에서 metadata=00.90 을 metadata=0.90 으로 변경 MAILADDR xxx@example.com root@wll:~# vi /etc/fstab ... /dev/VG_1/LV_1 /u01 reiserfs defaults 0 0 root@wll:~# sync; reboot재시작 후 아래와 같이 마운트 되어있는 것을 확인할 수 있다.
root@wll:~# df -h /u01
파일시스템 크기 사용됨 사용가능 사용율% 마운트 됨
/dev/mapper/VG_1-LV_1
1.0G 33M 992M 4% /u01
|
|
Copyright © 2004-2012 Jo HoSeok. All rights reserved. |