您的位置:首页 > 运维架构 > Linux

Linux 磁盘管理 四(Raid、LVM、Quota)

2010-12-27 05:42 621 查看
(二)、逻辑磁盘管理LVM配置
1、LVM前磁盘阵列准备
1-1、构建raid5:将之前的raid1删除,重新构建raid5:

[root@localhost ~]# mdadm -S /dev/md1
mdadm: stopped /dev/md1
[root@localhost ~]# mdadm -Cv /dev/md5 -l5 -n3 /dev/sd{b,c,d}1
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 64K
mdadm: /dev/sdb1 appears to contain an ext2fs file system
size=3132288K mtime=Sat Aug 21 23:35:25 2010
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid1 devices=3 ctime=Sun Aug 22 16:53:39 2010
mdadm: /dev/sdc1 appears to contain an ext2fs file system
size=3132288K mtime=Sat Aug 21 23:35:25 2010
mdadm: /dev/sdc1 appears to be part of a raid array:
level=raid1 devices=3 ctime=Sun Aug 22 16:53:39 2010
mdadm: /dev/sdd1 appears to contain an ext2fs file system
size=3132288K mtime=Sat Aug 21 23:35:25 2010
mdadm: /dev/sdd1 appears to be part of a raid array:
level=raid1 devices=3 ctime=Sun Aug 22 16:53:39 2010
mdadm: size set to 1044096K
Continue creating array? y
mdadm: array /dev/md5 started.

1-2、添加一块磁盘(大小设为2G,类型设为SCSI),把/dev/sde创建成RAID1

[root@localhost ~]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 131

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (132-261, default 132):
Using default value 132
Last cylinder or +size or +sizeM or +sizeK (131-261, default 261):
Using default value 261

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sde: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sde1 1 131 1052226 fd Linux raid autodetect
/dev/sde2 132 261 1044225 fd Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@localhost ~]# mdadm -Cv /dev/md1 -l1 -n2 /dev/sde1 /dev/sde2
mdadm: size set to 1044160K
mdadm: array /dev/md1 started.

[root@localhost ~]# mdadm -Ds
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=0.90 UUID=044acd0c:b8a9fa95:b860ea09:c5488410
ARRAY /dev/md5 level=raid5 num-devices=3 metadata=0.90 UUID=d8fcd7a7:c734ce5b:5618eac3:c5393a78

2、建立LVM
2-1、创建PV

[root@localhost ~]# pvcreate /dev/md1
Physical volume "/dev/md1" successfully created
[root@localhost ~]# pvcreate /dev/md5
Physical volume "/dev/md5" successfully created

查看PV详细信息

[root@localhost ~]# pvdisplay
"/dev/md1" is a new physical volume of "1019.69 MB"
--- NEW Physical volume ---
PV Name /dev/md1
VG Name
PV Size 1019.69 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID dbooLs-8rpr-uCOp-UDxJ-aUf6-z9D7-OLcIkT

"/dev/md5" is a new physical volume of "1.99 GB"
--- NEW Physical volume ---
PV Name /dev/md5
VG Name
PV Size 1.99 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID R7x4V1-2tc8-8eF9-hbA2-G5sB-o6yU-fME5qk

2-2、创建VG,卷组名为LVMonRaid

[root@localhost ~]# vgcreate LVMonRaid /dev/md1 /dev/md5
Volume group "LVMonRaid" successfully created
[root@localhost ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "LVMonRaid" using metadata type lvm2

2-3、创建LV

[root@localhost ~]# lvcreate --size 1024M --name LogicLV1 LVMonRaid
Logical volume "LogicLV1" created
[root@localhost ~]# lvcreate --size 1024M --name LogicLV2 LVMonRaid
Logical volume "LogicLV2" created
[root@localhost ~]# lvscan
ACTIVE '/dev/LVMonRaid/LogicLV1' [1.00 GB] inherit
ACTIVE '/dev/LVMonRaid/LogicLV2' [1.00 GB] inherit

2-4、格式化创建文件系统,并挂载使用:

[root@localhost ~]# mkfs.ext3 /dev/LVMonRaid/LogicLV1
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 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# mkfs.ext3 /dev/LVMonRaid/LogicLV2
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 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@localhost ~]# mkdir /mnt/lv1
[root@localhost ~]# mkdir /mnt/lv2
[root@localhost ~]# mount -t ext3 /dev/LVMonRaid/LogicLV1 /mnt/lv1
[root@localhost ~]# mount -t ext3 /dev/LVMonRaid/LogicLV2 /mnt/lv2

本文出自 “大海无量” 博客,请务必保留此出处http://hky008.blog.51cto.com/803965/465359
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: