Merge pull request #1844 from GOLinux/master

[Translated] 20141013 Manage Multiple Logical Volume Management Disks using Striping I O--Part V.md
This commit is contained in:
joeren 2014-10-15 12:11:30 +08:00
commit 3521b67ad1
2 changed files with 145 additions and 158 deletions

View File

@ -1,158 +0,0 @@
Translating by GOLinux!
Manage Multiple Logical Volume Management Disks using Striping I/O
================================================================================
In this article, we are going to see how the logical volumes writes the data to disk by striping I/O. Logical Volume management has one of the cool feature which can write data over multiple disk by striping the I/O.
![Manage LVM Disks Using Striping I/O](http://www.tecmint.com/wp-content/uploads/2014/09/LVM-Striping.jpeg)
Manage LVM Disks Using Striping I/O
### What is LVM Striping? ###
**LVM Striping** is one of the feature which will writes the data over multiple disk, instead of constant write on a single Physical volume.
#### Features of Striping ####
- It will increase the performance of disk.
- Saves from hard write over and over to a single disk.
- Disk fill-up can be reduced using striping over multiple disk.
In Logical volume management, if we need to create a logical volume the extended will get fully mapped to the volume group and physical volumes. In such situation if one of the **PV** (Physical Volume) gets filled we need to add more extends from other physical volume. Instead, adding more extends to PV, we can point our logical volume to use the particular Physical volumes writing I/O.
Assume we have **four disks** drives and pointed to four physical volumes, if each physical volume are capable of **100 I/O** totally our volume group will get **400 I/O**.
If we are not using the **stripe method**, the file system will writes across the underlying physical volume. For example, some data writes to physical volume 100 I/O will be write only to the first (**sdb1**) PV. If we create the logical volume with stripe option while writing, it will write to every four drives by splitting 100 I/O, that means every four drive will receive 25 I/O each.
This will be done in round robin process. If any one of the logical volume need to be extended, in this situation we cant add 1 or 2 PV. We have to add all 4 pvs to extend the logical volume size. This is one of the drawback in stripe feature, from this we can know that while creating logical volumes we need to assign the same stripe size over all logical volumes.
Logical Volume management has these features which we can stripe the data over multiple pvs at the same time. If you are familiar with logical volume you can go head to setup the logical volume stripe. If not then you must need to know about the logical volume managements basics, read below articles to know more about logical volume management.
#### My Server Setup ####
Here Im using **Centos6.5** for my workout. The same steps can be used in RHEL, Oracle Linux, and most of the distributions.
Operating System : CentOS 6.5
IP Address : 192.168.0.222
Hostname : tecmint.storage.com
### Logical Volume management using Striping I/O ###
For demonstration purpose, Ive used 4 Hard drives, each drive with 1 GB in Size. Let me show you four drives using **fdisk** command as shown below.
# fdisk -l | grep sd
![List Hard Drives](http://www.tecmint.com/wp-content/uploads/2014/09/List-Hard-Drives.png)
List Hard Drives
Now weve to create partitions for these 4 hard drives **sdb**, **sdc**, **sdd** and **sde** using **fdisk** command. To create partitions, please follow the **step #4** instructions, given in the **Part 1** of this article (link give above) and make sure you change the type to **LVM (8e)**, while creating partitions.
# pvcreate /dev/sd[b-e]1 -v
![Create Physical Volumes in LVM](http://www.tecmint.com/wp-content/uploads/2014/09/Create-Physical-Volumes-in-LVM.png)
Create Physical Volumes in LVM
Once PVs created, you can list them using **pvs** command.
# pvs
![Verify Physical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Verify-Physical-Volumes.png)
Verify Physical Volumes
Now we need to define volume group using those 4 physical volumes. Here Im defining my volume group with **16MB** of Physical extended size (PE) with volume group named as **vg_strip**.
# vgcreate -s 16M vg_strip /dev/sd[b-e]1 -v
The description of above options used in the command.
- **[b-e]1** Define your hard drive names such as sdb1, sdc1, sdd1, sde1.
- **-s** Define your physical extent size.
- **-v** verbose.
Next, verify the newly created volume group using.
# vgs vg_strip
![Verify Volume Group](http://www.tecmint.com/wp-content/uploads/2014/09/Verify-Volume-Group.png)
Verify Volume Group
To get more detailed information about VG, use switch -v with **vgdisplay** command, it will give us a every physical volumes which all used in **vg_strip** volume group.
# vgdisplay vg_strip -v
![Volume Group Information](http://www.tecmint.com/wp-content/uploads/2014/09/Volume-Group-Information.png)
Volume Group Information
Back to our topic, now while creating Logical volume, we need to define the stripe value, how data need to write in our logical volumes using stripe method.
Here Im creating a logical volume in the name of **lv_tecmint_strp1** with **900MB** size, and it needs to be in **vg_strip** volume group, and Im defining as 4 stripe, it means the data writes to my logical volume, needs to be stripe over 4 PVs.
# lvcreate -L 900M -n lv_tecmint_strp1 -i4 vg_strip
- **-L** logical volume size
- **-n** logical volume name
- **-i** stripes
![Create Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Create-Logical-Volumes.png)
Create Logical Volumes
In the above image, we can see that the default size of stripe-size was **64 KB**, if we need to define our own stripe value, we can use **-I** (Capital I). Just to confirm that the logical volume are created use the following command.
# lvdisplay vg_strip/lv_tecmint_strp1
![Confirm Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Confirm-Logical-Volumes.png)
Confirm Logical Volumes
Now next question will be, How do we know that stripes are writing to 4 drives?. Here we can use **lvdisplay** and **-m** (display the mapping of logical volumes) command to verify.
# lvdisplay vg_strip/lv_tecmint_strp1 -m
![Check Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Check-Logical-Volumes.png)
Check Logical Volumes
To create our defined stripe size, we need to create one logical volume with **1GB** size using my own defined Stripe size of **256KB**. Now Im going to stripe over only 3 PVs, here we can define which pvs we want to be striped.
# lvcreate -L 1G -i3 -I 256 -n lv_tecmint_strp2 vg_strip /dev/sdb1 /dev/sdc1 /dev/sdd1
![Define Stripe Size](http://www.tecmint.com/wp-content/uploads/2014/09/Define-Stripe-Size.png)
Define Stripe Size
Next, check the stripe size and which volume does it stripes.
# lvdisplay vg_strip/lv_tecmint_strp2 -m
![Check Stripe Size](http://www.tecmint.com/wp-content/uploads/2014/09/Check-Stripe-Size.png)
Check Stripe Size
Its time to use a device mapper, for this we use command **dmsetup**. It is a low level logical volume management tool which manages logical devices, that use the device-mapper driver. We can see the lvm information using dmsetup command to know the which stripe depends on which drives.
# dmsetup deps /dev/vg_strip/lv_tecmint_strp[1-2]
![Device Mapper](http://www.tecmint.com/wp-content/uploads/2014/09/Device-Mapper.png)
Device Mapper
Here we can see that strp1 depend on 4 drives, and strp2 depend on 3 devices.
Hope you have learnt, that how we can stripe through logical volumes to write the data. For this setup one must know about the basic of logical volume management. In my next article, I will show you how we can migrate in logical volume management, till then stay tuned for updates and dont forget to give valuable comments about the article.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/manage-multiple-lvm-disks-using-striping-io/
作者:[Babin Lonston][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/babinlonston/

View File

@ -0,0 +1,145 @@
使用条块化I/O管理多个逻辑卷管理磁盘
================================================================================
在本文中我们将了解逻辑卷是如何通过条块化I/O来写入数据到磁盘的。逻辑卷管理的酷炫特性之一就是它能通过条块化I/O跨多个磁盘写入数据。
![Manage LVM Disks Using Striping I/O](http://www.tecmint.com/wp-content/uploads/2014/09/LVM-Striping.jpeg)
使用条块化I/O管理LVM磁盘
### LVM条块化是什么 ###
**LVM条块化**是LVM功能之一该技术会跨多个磁盘写入数据而不是对单一物理卷持续写入。
#### 条块化特性 ####
- 它会改善磁盘性能。
- 挽救对单一磁盘的重复硬写入。
- 使用对多个磁盘的条块化写入,可以减少磁盘填满的几率。
在逻辑卷管理中,如果我们需要创建一个逻辑卷,扩展的卷会完全映射到卷组和物理卷。在此种情形中,如果其中一个**PV**物理卷被填满我们需要从其它物理卷中添加更多扩展。这样添加更多扩展到PV中后我们可以指定逻辑卷使用特定的物理卷写入I/O。
假设我们又**四个磁盘**驱动器,分别指向了四个物理卷,如果各个物理卷总计可以达到**100 I/O**,我们卷组就可以获得**400 I/O**。
如果我们不使用**条块化方法**文件系统将横跨基础物理卷写入。例如写入一些数据到物理卷达到100 I/O这些数据只会写入到第一个PV**sdb1**。如果我们在写入时使用条块化选项创建逻辑卷它会分割100 I/O分别写入到四个驱动器中这就是说每个驱动器中都会接收到25 I/O。
这会在循环过程中完成。如果这些逻辑卷其中任何一个需要扩展在这种情形下我们不能添加1个或2个PV必须添加所有4个pv来扩展逻辑卷大小。这是条块化特性的缺点之一从中我们可以知道在创建逻辑卷时我们需要为所有逻辑卷分配相同的条块大小。
逻辑卷管理有着这些特性它使我们能够同时在多个pv中条块化数据。如果你对逻辑卷熟悉你可以去设置逻辑卷条块化。反之你则必须了解逻辑卷管理的基础知识了请阅读更基础的文章来了解逻辑卷管理。
#### 我的服务器设置 ####
这里,我使用**CentOS6.5**用作练习。下面这些步骤也适用于RHEL、Oracle Linux以及大多数发行版。
操作系统: CentOS 6.5
IP地址 192.168.0.222
主机名: tecmint.storage.com
### 条块化I/O的逻辑卷管理 ###
出于演示目的我已经准备了4个硬盘驱动器每个驱动器1GB大小。让我用下面的**fdisk**’命令来列给你看看吧。
# fdisk -l | grep sd
![List Hard Drives](http://www.tecmint.com/wp-content/uploads/2014/09/List-Hard-Drives.png)
列出硬盘驱动器
现在我们必须为这4个硬盘驱动器**sdb****sdc****sdd**和**sde**创建分区,我们将用‘**fdisk**’命令来完成该工作。要创建分区,请遵从本文**第一部分**中**步骤#4**的说明,并在创建分区时确保你已将类型修改为**LVM8e**。
# pvcreate /dev/sd[b-e]1 -v
![Create Physical Volumes in LVM](http://www.tecmint.com/wp-content/uploads/2014/09/Create-Physical-Volumes-in-LVM.png)
在LVM中创建物理卷
PV创建完成后你可以使用**pvs**’命令将它们列出来。
# pvs
![Verify Physical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Verify-Physical-Volumes.png)
验证物理卷
现在我们需要使用这4个物理卷来定义卷组。这里我定义了一个物理扩展大小PE为**16MB**,名为**vg_strip**的卷组。
# vgcreate -s 16M vg_strip /dev/sd[b-e]1 -v
上面命令中选项的说明。
- **[b-e]1** 定义硬盘驱动器名称如sdb1sdc1sdd1sde1。
- **-s** 定义物理扩展大小。
- **-v** 详情。
接下来,验证新创建的卷组:
# vgs vg_strip
![Verify Volume Group](http://www.tecmint.com/wp-content/uploads/2014/09/Verify-Volume-Group.png)
验证卷组
要获取VG更详细的信息可以在**vgdisplay**命令中使用‘-v选项它将给出**vg_strip**卷组中所使用的全部物理卷的详细情况。
# vgdisplay vg_strip -v
![Volume Group Information](http://www.tecmint.com/wp-content/uploads/2014/09/Volume-Group-Information.png)
卷组信息
回到我们的话题,现在在创建逻辑卷时,我们需要定义条块化值,就是数据需要如何使用条块化方法来写入到我们的逻辑卷中。
这里,我创建了一个名为**lv_tecmint-strp1**,大小为**900MB**的逻辑卷,它需要放到**vg_strip**卷组中。我定义了4个条块就是说数据在写入到我的逻辑卷时需要条块化分散到4个PV中。
# lvcreate -L 900M -n lv_tecmint_strp1 -i4 vg_strip
- **-L** –逻辑卷大小
- **-n** –逻辑卷名称
- **-i** –条块化
![Create Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Create-Logical-Volumes.png)
创建逻辑卷
在上面的图片中,我们可以看到条块尺寸的默认大小为**64 KB**,如果我们需要自定义条块值,我们可以使用**-I**大写I。要确认逻辑卷已经是否已经创建请使用以下命令。
# lvdisplay vg_strip/lv_tecmint_strp1
![Confirm Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Confirm-Logical-Volumes.png)
确认逻辑卷
现在接下来的问题是我们怎样才能知道条块被写入到了4个驱动器。这里我们可以使用**lvdisplay**’和**-m**(显示逻辑卷映射)命令来验证。
# lvdisplay vg_strip/lv_tecmint_strp1 -m
![Check Logical Volumes](http://www.tecmint.com/wp-content/uploads/2014/09/Check-Logical-Volumes.png)
检查逻辑卷
要创建自定义的条块尺寸,我们需要用我们自定义的条块大小**256KB**来创建一个**1GB**大小的逻辑卷。现在我打算将条块分布到3个PV上。这里我们可以定义我们想要哪些pv条块化。
# lvcreate -L 1G -i3 -I 256 -n lv_tecmint_strp2 vg_strip /dev/sdb1 /dev/sdc1 /dev/sdd1
![Define Stripe Size](http://www.tecmint.com/wp-content/uploads/2014/09/Define-Stripe-Size.png)
定义条块大小
接下来,检查条块大小和条块化的卷。
# lvdisplay vg_strip/lv_tecmint_strp2 -m
![Check Stripe Size](http://www.tecmint.com/wp-content/uploads/2014/09/Check-Stripe-Size.png)
检查条块大小
是时候使用设备映射了,我们使用‘**dmsetup**’命令来完成这项工作。它是一个低级别的逻辑卷管理工具,它用于管理使用了设备映射驱动的逻辑设备。
# dmsetup deps /dev/vg_strip/lv_tecmint_strp[1-2]
![Device Mapper](http://www.tecmint.com/wp-content/uploads/2014/09/Device-Mapper.png)
设备映射
这里我们可以看到strp1依赖于4个驱动器strp2依赖于3个设备。
希望你已经明白,我们怎样能让逻辑卷条块化来写入数据。对于此项设置,必须掌握逻辑卷管理基础知识。在我的下一篇文章中,我将给大家展示怎样在逻辑卷管理中迁移数据。到那时,请静候更新。同时,别忘了对本文提出有价值的建议。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/manage-multiple-lvm-disks-using-striping-io/
作者:[Babin Lonston][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/babinlonston/