磁盘阵列:
磁盘阵列是由多个磁盘,组合成一个容量巨大的磁盘组,作用是可以增加传输速度,增加总容量,增加文件备份。
下面是主要几种阵列模式:
RAID0:把一份文件分成两份,一半放一个磁盘,如果其中有一个坏了,那剩下的半分也没有意义了,唯一的优点就是磁盘的空间增大了。
RAID1:把一份文件备份成两份,分别存放在两个磁盘中,如果其中的任何一份文件损坏,还有另一份可以用。但这种模式虽然安全性能高一点,但是成本也变得高了。
RAID5:将一份文件分割成好几份两半,分散地存放在三个硬盘里,两个磁盘分别放半份,另一个磁盘放分割出来的一份文件,这样可以增加安全性能,容量也大了,但是成本变得很高,而且若两个磁盘都坏了,那么整个磁盘阵中的数据就被破坏了。
RAID 0+1:顾名思义,就是RAID0和RAID1的组合。先做出来RAID0,然后再做出来RAID1。这种模式由四个磁盘组成,RAID0+1是储存性能和数据安全都比较好的一种模式,但是成本确实非常高。
LVM:
将一个或者很多个硬盘的分区组合成一个大的硬盘来使用,当硬盘不够用的时候,可以继续把其他的硬盘分区加到里面,这样就可以做到磁盘空间的动态管理,比普通的磁盘分区灵活。
PV(物理卷):物理的磁盘分区
VG(卷组):lvm中的物理磁盘分区,也就是PV必须加入VG,可以将VG理解为一个大仓库或者是几个大的硬盘
LV(逻辑卷):从VG中划分出来的逻辑分区
创建pv[root@we Desktop]# fdisk -lDisk /dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0001abdc Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 13055 104651776 8e Linux LVMDisk /dev/sdb: 12.9 GB, 12884901888 bytes255 heads, 63 sectors/track, 1566 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-LogVol01: 98.6 GB, 98570338304 bytes255 heads, 63 sectors/track, 11983 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-LogVol00: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000
[root@we Desktop]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created
[root@we Desktop]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name VolGroup PV Size 99.80 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 25549 Free PE 0 Allocated PE 25549 PV UUID HTEXx8-Z6X5-4jhT-HRdn-3kyj-3bcP-WoMTNu "/dev/sdb" is a new physical volume of "12.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb VG Name PV Size 12.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID O6tQar-6oYA-82Bm-S8qT-YVcx-Ysxf-yAth8s
创建VG
[root@we Desktop]# vgcreate VolumeGroup01 /dev/sdb Volume group "VolumeGroup01" successfully created
[root@we Desktop]# vgdisplay --- Volume group --- VG Name VolumeGroup01 System ID Format lvm2 Metadata Areas 1 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 1 Act PV 1 VG Size 12.00 GiB PE Size 4.00 MiB Total PE 3071 Alloc PE / Size 0 / 0 Free PE / Size 3071 / 12.00 GiB VG UUID faezlK-n148-NomH-eXEl-8Ue6-H9wN-aNz9rP --- Volume group --- VG Name VolGroup System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 99.80 GiB PE Size 4.00 MiB Total PE 25549 Alloc PE / Size 25549 / 99.80 GiB Free PE / Size 0 / 0 VG UUID 99AqhW-qeiU-toQ9-15Ds-h8oC-vDW6-YIA8gv
创建LV
[root@we Desktop]# lvcreate -L 4096M -n lv001 VolumeGroup01 Logical volume "lv001" created
LV格式化及挂载
[root@we Desktop]# mkfs.ext4 /dev/VolumeGroup01/lv001mke2fs 1.43-WIP (20-Jun-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks262144 inodes, 1048576 blocks52428 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=107374182432 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done
[root@we yg]# mount /dev/VolumeGroup01/lv001 /yg
测试及挂载
[root@we yg]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-LogVol01 91G 3.8G 82G 5% /tmpfs 2.0G 280K 2.0G 1% /dev/shm/dev/sda1 190M 54M 126M 31% /boot/dev/sr0 57M 57M 0 100% /media/VBOXADDITIONS_5.0.10_104061/dev/mapper/VolumeGroup01-lv001 3.9G 8.0M 3.7G 1% /yg