如何在 RHEL 上设置 Linux RAID 1
创始人
2024-03-01 18:54:39
0

设置 Linux RAID 1

配置 LINUX RAID 1 非常重要,因为它提供了冗余性。

RAID 分区拥有高级功能,如冗余和更好的性能。所以让我们来说下如何实现 RAID,以及让我们来看看不同类型的 RAID:

  • RAID 0(条带):磁盘组合在一起,形成一个更大的驱动器。这以可用性为代价提供了更好的性能。如果 RAID 中的任何一块磁盘出现故障,则整个磁盘集将无法使用。最少需要两块磁盘。
  • RAID 1(镜像):磁盘从一个复制到另一个,提供了冗余。如果一块磁盘发生故障,则另一块磁盘接管,它有另外一份原始磁盘的数据的完整副本。其缺点是写入时间慢。最少需要两块磁盘。
  • RAID 5(带奇偶校验的条带):磁盘类似于 RAID 0,并且连接在一起以形成一个大型驱动器。这里的区别是,一块磁盘用于奇偶校验位,这允许在单个磁盘发生故障时可以恢复磁盘。最少需要三块盘。

让我们继续进行 Linux RAID 1 配置。

安装 Linux RAID 1 的要求:

1、系统中应该安装了 mdam,请用下面的命令确认。

[root@rhel1 ~]# rpm -qa | grep -i mdadm
mdadm-3.2.2-9.el6.x86_64
[root@rhel1 ~]#

2、 系统应该连接了 2 块磁盘。

创建两个分区,一个磁盘一个分区(sdc、sdd),每个分区占据整块磁盘。

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x67cc8cfb

Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 83 Linux

Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0294382b

Device Boot Start End Blocks Id System
/dev/sdd1 1 130 1044193+ 83 Linux

现在你可以用你已经创建好的两个分区来设置 RAID 1 了。你可以使用 mdadm 命令来创建 RAID 阵列。

Syntax: mdadm [options] 
Options: -a, xx Adds a disk into a current array 
-C, —create Creates a new RAID array 
-D, —detail Prints the details of an array 
-G, —grow Changes the size or shape of an active array
-f, xx Fails a disk in the array
-l, —level Specifies level (type) of RAID array to create 
-n, —raid-devices Specifies the devices in the RAID array 
-q, —quiet Species not to show output 
-S, —stop Stops an array 
-v, —verbose Provides verbose output

创建 Linux RAID 1 设备:

[root@rhel1 ~]# mdadm -Cv /dev/md0 --level=1 -n2 /dev/sdc1 /dev/sdd1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 1044181K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@rhel1 ~]#

使用下列命令查看新创建的 RAID 1 设备:

[root@rhel1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdd1[1] sdc1[0]
1044181 blocks super 1.2 [2/2] [UU]
 
unused devices: 
[root@rhel1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdd1[1] sdc1[0]
1044181 blocks super 1.2 [2/2] [UU]
 
unused devices: 

使用 mdadm 命令再次确认,RAID 1 已经创建好了。

[root@rhel1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Wed Dec 7 15:50:06 2016
Raid Level : raid1
Array Size : 1044181 (1019.88 MiB 1069.24 MB)
Used Dev Size : 1044181 (1019.88 MiB 1069.24 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
 
Update Time : Wed Dec 7 15:50:12 2016
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
 
Name : rhel1.lab.com:0 (local to host rhel1.lab.com)
UUID : d5c0f82e:4e0753e6:0b28c178:e6f75af4
Events : 17
 
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
[root@rhel1 ~]#

使用下列命令格式化新创建的 Linux RAID 1 设备:

[root@rhel1 ~]# mkfs.ext4 /dev/md0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65280 inodes, 261045 blocks
13052 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
8160 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
 
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

挂载 Linux RAID 1 设备:

[root@rhel1 ~]# mkdir /RAID1
[root@rhel1 ~]# mount /dev/md0 /RAID1
[root@rhel1 ~]# df -h /RAID1
Filesystem Size Used Avail Use% Mounted on
/dev/md0 1004M 18M 936M 2% /RAID1
[root@rhel1 ~]#

作者简介:

大家好!我是 Manmohan Mirkar。我很高兴见到你们!我在 10 多年前开始使用 Linux,我从来没有想过我会到今天这个地步。我的激情是帮助你们获取 Linux 知识。谢谢阅读!


via: http://www.linuxroutes.com/linux-raid-1/

作者:Manmohan Mirkar 译者:geekpi 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关内容

Linux操作系统内存管理...
1、RAID磁盘阵列简称:独立冗余磁盘阵列把多块独立...
2025-05-28 16:09:45
【服务器数据恢复】服务器断...
服务器数据恢复环境: 某品牌ProLiant DL系...
2025-05-28 02:35:49
Android相机:找不到...
问题:Android相机:找不到getPhysicalCamera...
2024-10-12 13:02:11
仅一行代码,英特尔 EMR...
IT之家 8 月 5 日消息,Ubuntu 发行版开发方 Cano...
2024-08-05 20:11:56
优化UnRaid容器的We...
文章目录前言详细流程 前言 自从入了UnRaid的坑࿰...
2024-05-31 05:03:44
使用 mdadm 管理 R...
mdadm 是 多磁盘和设备管理 Multiple Disk an...
2024-03-02 02:21:09

热门资讯

Helix:高级 Linux ... 说到 基于终端的文本编辑器,通常 Vim、Emacs 和 Nano 受到了关注。这并不意味着没有其他...
使用 KRAWL 扫描 Kub... 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。当你使用 Kubernet...
JStock:Linux 上不... 如果你在股票市场做投资,那么你可能非常清楚投资组合管理计划有多重要。管理投资组合的目标是依据你能承受...
通过 SaltStack 管理... 我在搜索Puppet的替代品时,偶然间碰到了Salt。我喜欢puppet,但是我又爱上Salt了:)...
Epic 游戏商店现在可在 S... 现在可以在 Steam Deck 上运行 Epic 游戏商店了,几乎无懈可击! 但是,它是非官方的。...
《Apex 英雄》正式可在 S... 《Apex 英雄》现已通过 Steam Deck 验证,这使其成为支持 Linux 的顶级多人游戏之...
如何在 Github 上创建一... 学习如何复刻一个仓库,进行更改,并要求维护人员审查并合并它。你知道如何使用 git 了,你有一个 G...
2024 开年,LLUG 和你... Hi,Linuxer,2024 新年伊始,不知道你是否已经准备好迎接新的一年~ 2024 年,Lin...
什么是 KDE Connect... 什么是 KDE Connect?它的主要特性是什么?它应该如何安装?本文提供了基本的使用指南。科技日...
Opera 浏览器内置的 VP... 昨天我们报道过 Opera 浏览器内置了 VPN 服务,用户打开它可以防止他们的在线活动被窥视。不过...