Merge pull request #3251 from strugglingyouth/master

raid部分翻译完成
This commit is contained in:
bazz2 2015-08-26 07:56:01 +08:00
commit a200ce5d28
2 changed files with 277 additions and 276 deletions

View File

@ -1,276 +0,0 @@
struggling 翻译中
Setting Up RAID 10 or 1+0 (Nested) in Linux Part 6
================================================================================
RAID 10 is a combine of RAID 0 and RAID 1 to form a RAID 10. To setup Raid 10, we need at least 4 number of disks. In our earlier articles, weve seen how to setup a RAID 0 and RAID 1 with minimum 2 number of disks.
Here we will use both RAID 0 and RAID 1 to perform a Raid 10 setup with minimum of 4 drives. Assume, that weve some data saved to logical volume, which is created with RAID 10. Just for an example, if we are saving a data “apple” this will be saved under all 4 disk by this following method.
![Create Raid 10 in Linux](http://www.tecmint.com/wp-content/uploads/2014/11/raid10.jpg)
Create Raid 10 in Linux
Using RAID 0 it will save as “A” in first disk and “p” in the second disk, then again “p” in first disk and “l” in second disk. Then “e” in first disk, like this it will continue the Round robin process to save the data. From this we come to know that RAID 0 will write the half of the data to first disk and other half of the data to second disk.
In RAID 1 method, same data will be written to other 2 disks as follows. “A” will write to both first and second disks, “P” will write to both disk, Again other “P” will write to both the disks. Thus using RAID 1 it will write to both the disks. This will continue in round robin process.
Now you all came to know that how RAID 10 works by combining of both RAID 0 and RAID 1. If we have 4 number of 20 GB size disks, it will be 80 GB in total, but we will get only 40 GB of Storage capacity, the half of total capacity will be lost for building RAID 10.
#### Pros and Cons of RAID 5 ####
- Gives better performance.
- We will loose two of the disk capacity in RAID 10.
- Reading and writing will be very good, because it will write and read to all those 4 disk at the same time.
- It can be used for Database solutions, which needs a high I/O disk writes.
#### Requirements ####
In RAID 10, we need minimum of 4 disks, the first 2 disks for RAID 0 and other 2 Disks for RAID 1. Like I said before, RAID 10 is just a Combine of RAID 0 & 1. If we need to extended the RAID group, we must increase the disk by minimum 4 disks.
**My Server Setup**
Operating System : CentOS 6.5 Final
IP Address : 192.168.0.229
Hostname : rd10.tecmintlocal.com
Disk 1 [20GB] : /dev/sdd
Disk 2 [20GB] : /dev/sdc
Disk 3 [20GB] : /dev/sdd
Disk 4 [20GB] : /dev/sde
There are two ways to setup RAID 10, but here Im going to show you both methods, but I prefer you to follow the first method, which makes the work lot easier for setting up a RAID 10.
### Method 1: Setting Up Raid 10 ###
1. First, verify that all the 4 added disks are detected or not using the following command.
# ls -l /dev | grep sd
2. Once the four disks are detected, its time to check for the drives whether there is already any raid existed before creating a new one.
# mdadm -E /dev/sd[b-e]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde
![Verify 4 Added Disks](http://www.tecmint.com/wp-content/uploads/2014/11/Verify-4-Added-Disks.png)
Verify 4 Added Disks
**Note**: In the above output, you see there isnt any super-block detected yet, that means there is no RAID defined in all 4 drives.
#### Step 1: Drive Partitioning for RAID ####
3. Now create a new partition on all 4 disks (/dev/sdb, /dev/sdc, /dev/sdd and /dev/sde) using the fdisk tool.
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
**Create /dev/sdb Partition**
Let me show you how to partition one of the disk (/dev/sdb) using fdisk, this steps will be the same for all the other disks too.
# fdisk /dev/sdb
Please use the below steps for creating a new partition on /dev/sdb drive.
- Press n for creating new partition.
- Then choose P for Primary partition.
- Then choose 1 to be the first partition.
- Next press p to print the created partition.
- Change the Type, If we need to know the every available types Press L.
- Here, we are selecting fd as my type is RAID.
- Next press p to print the defined partition.
- Then again use p to print the changes what we have made.
- Use w to write the changes.
![Disk sdb Partition](http://www.tecmint.com/wp-content/uploads/2014/11/Disk-sdb-Partition.png)
Disk sdb Partition
**Note**: Please use the above same instructions for creating partitions on other disks (sdc, sdd sdd sde).
4. After creating all 4 partitions, again you need to examine the drives for any already existing raid using the following command.
# mdadm -E /dev/sd[b-e]
# mdadm -E /dev/sd[b-e]1
OR
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde
# mdadm --examine /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
![Check All Disks for Raid](http://www.tecmint.com/wp-content/uploads/2014/11/Check-All-Disks-for-Raid.png)
Check All Disks for Raid
**Note**: The above outputs shows that there isnt any super-block detected on all four newly created partitions, that means we can move forward to create RAID 10 on these drives.
#### Step 2: Creating md RAID Device ####
5. Now its time to create a md (i.e. /dev/md0) device, using mdadm raid management tool. Before, creating device, your system must have mdadm tool installed, if not install it first.
# yum install mdadm [on RedHat systems]
# apt-get install mdadm [on Debain systems]
Once mdadm tool installed, you can now create a md raid device using the following command.
# mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1
6. Next verify the newly created raid device using the cat command.
# cat /proc/mdstat
![Create md raid Device](http://www.tecmint.com/wp-content/uploads/2014/11/Create-md-raid-Device.png)
Create md raid Device
7. Next, examine all the 4 drives using the below command. The output of the below command will be long as it displays the information of all 4 disks.
# mdadm --examine /dev/sd[b-e]1
8. Next, check the details of Raid Array with the help of following command.
# mdadm --detail /dev/md0
![Check Raid Array Details](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Raid-Array-Details.png)
Check Raid Array Details
**Note**: You see in the above results, that the status of Raid was active and re-syncing.
#### Step 3: Creating Filesystem ####
9. Create a file system using ext4 for md0 and mount it under /mnt/raid10. Here, Ive used ext4, but you can use any filesystem type if you want.
# mkfs.ext4 /dev/md0
![Create md Filesystem](http://www.tecmint.com/wp-content/uploads/2014/11/Create-md-Filesystem.png)
Create md Filesystem
10. After creating filesystem, mount the created file-system under /mnt/raid10 and list the contents of the mount point using ls -l command.
# mkdir /mnt/raid10
# mount /dev/md0 /mnt/raid10/
# ls -l /mnt/raid10/
Next, add some files under mount point and append some text in any one of the file and check the content.
# touch /mnt/raid10/raid10_files.txt
# ls -l /mnt/raid10/
# echo "raid 10 setup with 4 disks" > /mnt/raid10/raid10_files.txt
# cat /mnt/raid10/raid10_files.txt
![Mount md Device](http://www.tecmint.com/wp-content/uploads/2014/11/Mount-md-Device.png)
Mount md Device
11. For automounting, open the /etc/fstab file and append the below entry in fstab, may be mount point will differ according to your environment. Save and quit using wq!.
# vim /etc/fstab
/dev/md0 /mnt/raid10 ext4 defaults 0 0
![AutoMount md Device](http://www.tecmint.com/wp-content/uploads/2014/11/AutoMount-md-Device.png)
AutoMount md Device
12. Next, verify the /etc/fstab file for any errors before restarting the system using mount -a command.
# mount -av
![Check Errors in Fstab](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Errors-in-Fstab.png)
Check Errors in Fstab
#### Step 4: Save RAID Configuration ####
13. By default RAID dont have a config file, so we need to save it manually after making all the above steps, to preserve these settings during system boot.
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
![Save Raid10 Configuration](http://www.tecmint.com/wp-content/uploads/2014/11/Save-Raid10-Configuration.png)
Save Raid10 Configuration
Thats it, we have created RAID 10 using method 1, this method is the easier one. Now lets move forward to setup RAID 10 using method 2.
### Method 2: Creating RAID 10 ###
1. In method 2, we have to define 2 sets of RAID 1 and then we need to define a RAID 0 using those created RAID 1 sets. Here, what we will do is to first create 2 mirrors (RAID1) and then striping over RAID0.
First, list the disks which are all available for creating RAID 10.
# ls -l /dev | grep sd
![List 4 Devices](http://www.tecmint.com/wp-content/uploads/2014/11/List-4-Devices.png)
List 4 Devices
2. Partition the all 4 disks using fdisk command. For partitioning, you can follow #step 3 above.
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
3. After partitioning all 4 disks, now examine the disks for any existing raid blocks.
# mdadm --examine /dev/sd[b-e]
# mdadm --examine /dev/sd[b-e]1
![Examine 4 Disks](http://www.tecmint.com/wp-content/uploads/2014/11/Examine-4-Disks.png)
Examine 4 Disks
#### Step 1: Creating RAID 1 ####
4. First let me create 2 sets of RAID 1 using 4 disks sdb1 and sdc1 and other set using sdd1 & sde1.
# mdadm --create /dev/md1 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[b-c]1
# mdadm --create /dev/md2 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[d-e]1
# cat /proc/mdstat
![Creating Raid 1](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-1.png)
Creating Raid 1
![Check Details of Raid 1](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-1.png)
Check Details of Raid 1
#### Step 2: Creating RAID 0 ####
5. Next, create the RAID 0 using md1 and md2 devices.
# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/md1 /dev/md2
# cat /proc/mdstat
![Creating Raid 0](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-0.png)
Creating Raid 0
#### Step 3: Save RAID Configuration ####
6. We need to save the Configuration under /etc/mdadm.conf to load all raid devices in every reboot times.
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
After this, we need to follow #step 3 Creating file system of method 1.
Thats it! we have created RAID 1+0 using method 2. We will loose two disks space here, but the performance will be excellent compared to any other raid setups.
### Conclusion ###
Here we have created RAID 10 using two methods. RAID 10 has good performance and redundancy too. Hope this helps you to understand about RAID 10 Nested Raid level. Let us see how to grow an existing raid array and much more in my upcoming articles.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/create-raid-10-in-linux/
作者:[Babin Lonston][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/babinlonston/

View File

@ -0,0 +1,277 @@
在 Linux 中设置 RAID 10 或 1 + 0嵌套 - 第6部分
================================================================================
RAID 10 是结合 RAID 0 和 RAID 1 形成的。要设置 RAID 10我们至少需要4个磁盘。在之前的文章中我们已经看到了如何使用两个磁盘设置 RAID 0 和 RAID 1。
在这里我们将使用最少4个磁盘结合 RAID 0 和 RAID 1 来设置 RAID 10。假设我们已经在逻辑卷保存了一些数据这是 RAID 10 创建的如果我们要保存数据“apple”它将使用以下方法将其保存在4个磁盘中。
![Create Raid 10 in Linux](http://www.tecmint.com/wp-content/uploads/2014/11/raid10.jpg)
在 Linux 中创建 Raid 10
使用 RAID 0 时它将“A”保存在第一个磁盘“p”保存在第二个磁盘下一个“P”又在第一个磁盘“L”在第二个磁盘。然后“e”又在第一个磁盘像这样它会继续循环此过程将数据保存完整。由此我们知道RAID 0 是将数据的一半保存到第一个磁盘,另一半保存到第二个磁盘。
在 RAID 1 方法中,相同的数据将被写入到两个磁盘中。 “A”将同时被写入到第一和第二个磁盘中“P”也将被同时写入到两个磁盘中下一个“P”也将同时被写入到两个磁盘。因此使用 RAID 1 将同时写入到两个磁盘。它将继续循环此过程。
现在大家来了解 RAID 10 怎样结合 RAID 0 和 RAID 1 来工作。如果我们有4个20 GB 的磁盘,总共为 80 GB但我们将只能得到40 GB 的容量,另一半的容量将用于构建 RAID 10。
#### RAID 10 的优点和缺点 ####
- 提供更好的性能。
- 在 RAID 10 中我们将失去两个磁盘的容量。
- 读与写的性能将会很好,因为它会同时进行写入和读取。
- 它能解决数据库的高 I/O 磁盘写操作。
#### 要求 ####
在 RAID 10 中我们至少需要4个磁盘2个磁盘为 RAID 0其他2个磁盘为 RAID 1就像我之前说的RAID 10 仅仅是结合了 RAID 0和1。如果我们需要扩展 RAID 组最少需要添加4个磁盘。
**我的服务器设置**
Operating System : CentOS 6.5 Final
IP Address : 192.168.0.229
Hostname : rd10.tecmintlocal.com
Disk 1 [20GB] : /dev/sdd
Disk 2 [20GB] : /dev/sdc
Disk 3 [20GB] : /dev/sdd
Disk 4 [20GB] : /dev/sde
有两种方法来设置 RAID 10在这里两种方法我都会演示但我更喜欢第一种方法使用它来设置 RAID 10 更简单。
### 方法1设置 RAID 10 ###
1.首先使用以下命令确认所添加的4块磁盘没有被使用。
# ls -l /dev | grep sd
2.四个磁盘被检测后,然后来检查磁盘是否存在 RAID 分区。
# mdadm -E /dev/sd[b-e]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde
![Verify 4 Added Disks](http://www.tecmint.com/wp-content/uploads/2014/11/Verify-4-Added-Disks.png)
验证添加的4块磁盘
**注意**: 在上面的输出中,如果没有检测到 super-block 意味着在4块磁盘中没有定义过 RAID。
#### 第1步为 RAID 分区 ####
3.现在使用fdisk命令为4个磁盘(/dev/sdb, /dev/sdc, /dev/sdd 和 /dev/sde)创建新分区。
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
**为 /dev/sdb 创建分区**
我来告诉你如何使用 fdisk 为磁盘(/dev/sdb)进行分区,此步也适用于其他磁盘。
# fdisk /dev/sdb
请使用以下步骤为 /dev/sdb 创建一个新的分区。
- 按 n 创建新的分区。
- 然后按 P 选择主分区。
- 接下来选择分区号为1。
- 只需按两次回车键选择默认值即可。
- 然后,按 P 来打印创建好的分区。
- 按 L列出所有可用的类型。
- 按 t 去修改分区。
- 键入 fd 设置为 Linux 的 RAID 类型,然后按 Enter 确认。
- 然后再次使用p查看我们所做的更改。
- 使用w保存更改。
![Disk sdb Partition](http://www.tecmint.com/wp-content/uploads/2014/11/Disk-sdb-Partition.png)
为磁盘 sdb 分区
**注意**: 请使用上面相同的指令对其他磁盘(sdc, sdd sdd sde)进行分区。
4.创建好4个分区后需要使用下面的命令来检查磁盘是否存在 raid。
# mdadm -E /dev/sd[b-e]
# mdadm -E /dev/sd[b-e]1
或者
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde
# mdadm --examine /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
![Check All Disks for Raid](http://www.tecmint.com/wp-content/uploads/2014/11/Check-All-Disks-for-Raid.png)
检查磁盘
**注意**: 以上输出显示,新创建的四个分区中没有检测到 super-block这意味着我们可以继续在这些磁盘上创建 RAID 10。
#### 第2步: 创建 RAID 设备 md ####
5.现在改创建一个md即 /dev/md0设备使用“mdadm” raid 管理工具。在创建设备之前必须确保系统已经安装了mdadm工具如果没有请使用下面的命令来安装。
# yum install mdadm [on RedHat systems]
# apt-get install mdadm [on Debain systems]
mdadm工具安装完成后可以使用下面的命令创建一个md raid 设备。
# mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1
6.接下来使用cat命令验证新创建的 raid 设备。
# cat /proc/mdstat
![Create md raid Device](http://www.tecmint.com/wp-content/uploads/2014/11/Create-md-raid-Device.png)
创建 md raid 设备
7.接下来使用下面的命令来检查4个磁盘。下面命令的输出会很长因为它会显示4个磁盘的所有信息。
# mdadm --examine /dev/sd[b-e]1
8.接下来,使用以下命令来查看 RAID 阵列的详细信息。
# mdadm --detail /dev/md0
![Check Raid Array Details](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Raid-Array-Details.png)
查看 Raid 阵列详细信息
**注意**: 你在上面看到的结果,该 RAID 的状态是 active 和re-syncing。
#### 第3步创建文件系统 ####
9.使用 ext4 作为md0的文件系统并将它挂载到/mnt/raid10下。在这里我用的是 ext4你可以使用你想要的文件系统类型。
# mkfs.ext4 /dev/md0
![Create md Filesystem](http://www.tecmint.com/wp-content/uploads/2014/11/Create-md-Filesystem.png)
创建 md 文件系统
10.在创建文件系统后,挂载文件系统到‘/mnt/raid10并使用ls -l命令列出挂载点下的内容。
# mkdir /mnt/raid10
# mount /dev/md0 /mnt/raid10/
# ls -l /mnt/raid10/
接下来,在挂载点下创建一些文件,并在文件中添加些内容,然后检查内容。
# touch /mnt/raid10/raid10_files.txt
# ls -l /mnt/raid10/
# echo "raid 10 setup with 4 disks" > /mnt/raid10/raid10_files.txt
# cat /mnt/raid10/raid10_files.txt
![Mount md Device](http://www.tecmint.com/wp-content/uploads/2014/11/Mount-md-Device.png)
挂载 md 设备
11.要想自动挂载,打开‘/etc/fstab文件并添加下面的条目挂载点根据你环境的不同来添加。使用 wq! 保存并退出。
# vim /etc/fstab
/dev/md0 /mnt/raid10 ext4 defaults 0 0
![AutoMount md Device](http://www.tecmint.com/wp-content/uploads/2014/11/AutoMount-md-Device.png)
挂载 md 设备
12.接下来在重新启动系统前使用mount -a来确认/etc/fstab文件是否有错误。
# mount -av
![Check Errors in Fstab](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Errors-in-Fstab.png)
检查 Fstab 中的错误
#### 第四步:保存 RAID 配置 ####
13.默认情况下 RAID 没有配置文件,所以我们需要在上述步骤完成后手动保存它。
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
![Save Raid10 Configuration](http://www.tecmint.com/wp-content/uploads/2014/11/Save-Raid10-Configuration.png)
保存 Raid10 的配置
就这样我们使用方法1创建完了 RAID 10这种方法是比较容易的。现在让我们使用方法2来设置 RAID 10。
### 方法2创建 RAID 10 ###
1.在方法2中我们必须定义2组 RAID 1然后我们需要使用这些创建好的 RAID 1 的集来定义一个 RAID 0。在这里我们将要做的是先创建2个镜像RAID1然后创建 RAID0 (条带化)。
首先,列出所有的可用于创建 RAID 10 的磁盘。
# ls -l /dev | grep sd
![List 4 Devices](http://www.tecmint.com/wp-content/uploads/2014/11/List-4-Devices.png)
列出了 4 设备
2.将4个磁盘使用fdisk命令进行分区。对于如何分区您可以按照 #步骤 3。
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
3.在完成4个磁盘的分区后现在检查磁盘是否存在 RAID块。
# mdadm --examine /dev/sd[b-e]
# mdadm --examine /dev/sd[b-e]1
![Examine 4 Disks](http://www.tecmint.com/wp-content/uploads/2014/11/Examine-4-Disks.png)
检查 4 个磁盘
#### 第1步创建 RAID 1 ####
4.首先使用4块磁盘创建2组 RAID 1一组为sdb1sdc1另一组是sdd1sde1
# mdadm --create /dev/md1 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[b-c]1
# mdadm --create /dev/md2 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[d-e]1
# cat /proc/mdstat
![Creating Raid 1](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-1.png)
创建 Raid 1
![Check Details of Raid 1](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-1.png)
查看 Raid 1 的详细信息
#### 第2步创建 RAID 0 ####
5.接下来,使用 md1 和 md2 来创建 RAID 0。
# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/md1 /dev/md2
# cat /proc/mdstat
![Creating Raid 0](http://www.tecmint.com/wp-content/uploads/2014/11/Creating-Raid-0.png)
创建 Raid 0
#### 第3步保存 RAID 配置 ####
6.我们需要将配置文件保存在‘/etc/mdadm.conf文件中使其每次重新启动后都能加载所有的 raid 设备。
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
在此之后我们需要按照方法1中的#第3步来创建文件系统。
就是这样我们采用的方法2创建完了 RAID 1+0.我们将会失去两个磁盘的空间,但相比其他 RAID ,它的性能将是非常好的。
### 结论 ###
在这里,我们采用两种方法创建 RAID 10。RAID 10 具有良好的性能和冗余性。希望这篇文章可以帮助你了解 RAID 10嵌套 RAID 的级别)。在后面的文章中我们会看到如何扩展现有的 RAID 阵列以及更多精彩的。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/create-raid-10-in-linux/
作者:[Babin Lonston][a]
译者:[strugglingyouth](https://github.com/strugglingyouth)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/babinlonston/