如何在Linux中配置RAID(5)

Choose Create MD device:

选择创建MD设备:

Choose device type

选择设备类型

The next step is to choose the RAID type. This is a step where some thorough thinking is needed. You need to ask yourselves what are you trying to achieve?

下一步是选择RAID类型。这是在需要充分考虑之后下一步。你要问自己你到底想达到什么目的?

I'm going to do the following:

我要做到以下几点:

Create a RAID 1 (mirror) device called md0 and later use it as root (/). This will slow down the performance, but ensure reliability.

创建一个RAID1(镜像)设备,称为md0,稍后把它作为根目录(/)。这会降低性能,但确保了可靠性。

Create a RAID 0 (stripe) device called md1 and use it as swap. We'll both benefit from a performance boost and increased total size. No need to worry about reliability here.

创建一个RAID0(条带)设备称为md1,用作交换区。我们可以同时从性能提升和增加总的容量大小上受益。这里不需要担心可靠性。

Create a RAID 0 (stripe) device called md2 and use it as home (/home). This will allow me to have a larger home directory than individual partitions allow. Likewise, it should improve the performance.

创建一个RAID0(条带)设备称为md2,用做家目录(/home)。这允许我有比独立分区允许的更大的家目录。同样,它应该改善性能。

Optimally, RAID 0 devices should be physically located on separate partitions, so that I/O operations can benefit from seeks by multiple disk heads. Furthermore, RAID 1 devices should exist on separate drives, to ensure reliability.

理想情况下,RAID0设备的位置应该是物理上位于单独分区,这样的I/O操作可以受益于多个磁头。此外RAID1设备应该位于不同的驱动器,保证了可靠性。

In our case, we're using partitions, which are only parts of physical disks, making the decisions regarding performance and reliability trickier. But if you're using whole disks as single partitions, then the classic rules for RAID configurations fully apply.

在我们的例子中,我们使用的分区,只有物理磁盘的部分,根据性能和可靠性做决定。但如果你使用磁盘作为单一分区,然后对RAID配置的经典规则完全适用。

This layout may not suit you at all. You may want performance for / and reliability for /home, so you may want to use a different layout. Or you may want to create a linear array for swap, because it does not really matter how you use it, as it's a raw device.

这种设置可能不适合你了。可能你想要根目录的性能和家目录(/home)的可靠性,所以可能你想要使用不同的设置。或者你可能想要为交换区创建线性阵列,因为你如何使用它无关紧要,因为她是原始设备。

So, our first device will be a RAID 1.

那么,我们第一设备会是RAID1。

Choose number of devices

选择设备的数量

We need to decide how many (active) devices will participate in the mirror. We'll go for two.

你必须选择在镜像中多少(有效的)设备做分区。我们实施下一步。

Choose spares

选择备件

The next step is to choose spares. We need none, so it's 0.

下一步是选择备件。我们不需要,因此选择0。

Choose devices

选择设备

Now, we need to select which devices (those marked as RAID), we want to use. For the first device, we'll use sda1 and sdb1.

现在,需要选择我们想要使用哪些设备(标记RAID)。对于第一个设备,我们使用sda1和sdb1。

Similarly, we'll repeat the procedure for the other two devices. Our swap will be a stripe, as we want performance and no redundancy is needed.

同样地,我们对其他两个设备重复步骤。我们的交换分区是一个条带,因为我们想要性能和不需要冗余。

And the last device, again a stripe:

最后一个设备,又是条带:

Final layout

最后的设置

This is what we have:

这是我们有的:

Configure mount points

配置挂载点

Now, for all practical purposes, the md devices are just like any other partition. We need to format them and configure the mount points.

现在,所有实用目的,md设备就像任何其他分区。我们需要格式化他们,并配置挂载点。

Configure root

配置根目录

We'll configure the root first:

我们将首先配置根目录:

We'll repeat the same procedure for the other two partitions, swap and /home. Our final layout is now as follows:

我们会在其他两个分区、交换分区和家目录重复同样的步骤。现在我们最后的设置如下:

We have everything configured as we wanted. Our devices are ready. The root partition will reside on a mirror device (md0), formatted as ext3. The md1 (stripe) will be used as swap. The home partition will reside on a stripe device (md2), formatted as ext3.

我们拥有一切我们想要的配置。我们的设备已准备就绪。根分区会驻留在ext3格式的镜像设备上。md1(条带)会当成交换分区使用。家分区会驻留在ext3格式的条带设备上(md2)。

Undo / Commit

撤销 /Commit

If you're satisfied, you can commit the changes - OR - undo the operations and start over.

如果你不满意,你可以提交更改——或——撤销操作,并重新开始。

You will have to confirm your choices, in case you decide to commit them:

如果你决定要提交他们,你必须确认你的选择:

Installation

安装

We can begin the installation.

我们可以开始安装。

You can now reboot and start enjoying your new system. What about the GRUB bootloader, you're asking? Well, nothing special. We'll see what happens after the boot.

你现在可以重新启动,开始享受你的新系统。你会问GRUB、引导程序什么样?好的,没什么特别的。我们会看到在开机后会发生什么。

After installation

安装后

Our system booted up fine, as expected.

我们的系统会正常启动,正如预期那样。

However, some of you may have read online that GRUB cannot install properly on RAID devices and that a manual intervention may be needed in order to make sure the system is bootable. This is partially true, and I will soon show you why.

然而,有些人可能已经在线阅读了GRUB不能在RAID设备正常安装,并且需要手动干预确保系统可以启动。这部分是事实的,我很快会告诉你为什么。

Before that, let's see what RAID looks like inside a working system:

在此之前,让我们看看工作系统中的RAID看起来是什么样子:

/proc/mdstat

/proc/mdstat

Let's take a look what mdstat reports:

我们仔细看看mdstat的显示:

Since we're using more than one type of RAID, the list of Personalities is now longer.

由于我们使用了不仅一种类型的RAID,Personalities的这列就不再存在了。

Another interesting bit of information is that md1 and md2, both stripes, do not have any information inside square brackets. This means that they have no redundancy. If any of the components of their arrays goes bad, the arrays will fail. md0, on the other hand, is a mirror, and has redundancy, which is manifested in the status of healthy, used devices.

另外有趣的一点是md1和md2,两条带,在方括号内没有任何的信息。这意味着,它们没有冗余。如果他们阵列的任何组件出问题了,整个阵列出现故障。md0,从另一方面上,是镜像,并有冗余,在健康状态,所用的设备表现出来。

This also tells us another bit of information: we can manipulate mirror devices in vivo, but persistent changes for RAID 0 type devices will require a reboot to take effect.

这也告诉我们另一个信息:我们可以操作镜像设备,但RAID0类设备的持久性变化需要重新启动才能生效。

Let's take a look at what fdisk reports:

让我们看看fdisk显示:

fdisk

fdisk

fdisk is a handy partitioning utility for Linux. We've seen it in the GParted tutorial; it allows us to manipulate partitions from the command line.

fdisk对Linux分区方便实用。我们已经在GParted教程中看到它了;它允许我们在命令行操作分区。

We can see that fdisk properly reports the RAID devices for all our partitions.

我们可以看到fdisk正确地显示了所有分区的RAID设备。

df

df

df reports file system disk usage. It also works with RAID devices and can tell us how much free space we have left on our partitions. Used with flags -l (local) and -h (human), it will report back for local partitions in human readable format (MB/GB):

df显示文件系统的磁盘使用情况。它还可以与RAID设备工作,告诉我们分区上还有多少可用空间。使用参数-l(本地)和-h,它可以可读格式(MB/GB)显示本地分区。

df -lh | grep md

df -lh | grep md

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywzpd.html