1-15-2-RAID1 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)
大纲:
1、创建RAID1
2、创建RAID5
3、创建RAID10
===============================
1、创建RAID1
RAID1原理:需要两块或以上磁盘,可添加热备盘。
在写入数据时,会在另一块磁盘中生成该文件的镜像(即同步)。
两块磁盘中的内容完全一致。
故当一块磁盘损坏时,可使用另一块镜像盘中的数据。(当拥有热备盘时,若镜像盘损坏,可由热备盘替代)
磁盘利用率为50%,即两块100G的磁盘构成RAID1只能提供100G的可用空间。
实战:创建RAID1
第一步:给虚拟机添加三块硬盘,并开机检查。

[root@localhost ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdc /dev/sdd
[root@localhost ~]#
效果如图:

第二步:分别对三块磁盘分区,并修改其标签
使用相同办法,分别对/dev/sdb、/dev/sdc、/dev/sdd进行分区
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xeed790f7.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xeed790f7
Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
效果如图:

第三步:创建RAID1磁盘阵列
检查三块磁盘是否被其他磁盘阵列使用
mdadm –E /dev/sd[b-d]1

使用分区后的三块磁盘,创建RAID1磁盘阵列
(其中-n指定两块设备,-x指定一个热备盘,-l 指定级别为RAID1 -C创建 -v显示信息 /dev/md1—>指定创建的设备名)
mdadm -Cv /dev/md1 -l 1 -n 2 -x 1 /dev/sd[b-d]1

检查:
[root@localhost ~]# ls /dev/md1
/dev/md1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Array Size : 20954112 (19.98 GiB 21.46 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sun Aug 21 01:28:01 2016
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Events : 17
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 - spare /dev/sdd1
[root@localhost ~]# mdadm -E /dev/md1
mdadm: No md superblock detected on /dev/md1.
[root@localhost ~]# mdadm -E /dev/sd[b-d]1
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Name : localhost.localdomain:1 (local to host localhost.localdomain)
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
Array Size : 20954112 (19.98 GiB 21.46 GB)
Data Offset : 32768 sectors
Super Offset : 8 sectors
Unused Space : before=32680 sectors, after=0 sectors
State : clean
Device UUID : 483270f1:90ae6527:ab2ceee6:58ee030d
Update Time : Sun Aug 21 01:28:01 2016
Bad Block Log : 512 entries available at offset 72 sectors
Checksum : 5e434c0e - correct
Events : 17
Device Role : Active device 0
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/sdc1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Name : localhost.localdomain:1 (local to host localhost.localdomain)
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
Array Size : 20954112 (19.98 GiB 21.46 GB)
Data Offset : 32768 sectors
Super Offset : 8 sectors
Unused Space : before=32680 sectors, after=0 sectors
State : clean
Device UUID : b6a96682:0ca07895:8fafe1f0:c5761864
Update Time : Sun Aug 21 01:28:01 2016
Bad Block Log : 512 entries available at offset 72 sectors
Checksum : be54c04a - correct
Events : 17
Device Role : Active device 1
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/sdd1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Name : localhost.localdomain:1 (local to host localhost.localdomain)
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
Array Size : 20954112 (19.98 GiB 21.46 GB)
Data Offset : 32768 sectors
Super Offset : 8 sectors
Unused Space : before=32680 sectors, after=0 sectors
State : clean
Device UUID : 9ee8a186:310bc49c:66788d58:ec4b1d9a
Update Time : Sun Aug 21 01:28:01 2016
Bad Block Log : 512 entries available at offset 72 sectors
Checksum : 678c0856 - correct
Events : 17
Device Role : spare
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
[root@localhost ~]#
查看磁盘阵列状态信息:

生成配置信息:
[root@localhost ~]# mdadm -Dvs >> /etc/mdadm.conf
[root@localhost ~]# cat !$ # !$ --> 上一条命令最后一个参数

第四步:格式化并挂载
[root@localhost ~]# mkfs.xfs /dev/md1
效果如图:

[root@localhost ~]# mkdir /disk
[root@localhost ~]# mount /dev/md1 /disk
[root@localhost ~]# df –h | tail –1
效果如图:

第五步:设置开机启动
[root@localhost ~]# echo "/dev/md1 /disk xfs defaults 0 0 " >> /etc/fstab
[root@localhost ~]# cat !$
[root@localhost ~]# df | grep /disk
[root@localhost ~]# umount /disk
[root@localhost ~]# mount –a #测试,umount /disk 模拟重启,mount –a 模拟开机
[root@localhost ~]# df | tail –1 #检查挂载结果
效果如图:
注:也可使用 mount –av 查看挂载信息

第六步:RAID1磁盘故障模拟及修复
模拟RAID磁盘故障:
[root@localhost ~]# mdadm -D /dev/md1 #查看/dev/md1状态
/dev/md1:
Version : 1.2
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Array Size : 20954112 (19.98 GiB 21.46 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sun Aug 21 01:43:47 2016
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Events : 17
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 - spare /dev/sdd1
[root@localhost ~]# mdadm /dev/md1 -f /dev/sdb1 #设置/dev/sdb1损坏
mdadm: set /dev/sdb1 faulty in /dev/md1
[root@localhost ~]# mdadm -D /dev/md1 #查看/dev/md1状态
/dev/md1:
Version : 1.2
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Array Size : 20954112 (19.98 GiB 21.46 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sun Aug 21 01:44:50 2016
State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 1
Spare Devices : 1
Rebuild Status : 3% complete
Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Events : 19
Number Major Minor RaidDevice State
2 8 49 0 spare rebuilding /dev/sdd1
1 8 33 1 active sync /dev/sdc1
0 8 17 - faulty /dev/sdb1
[root@localhost ~]#
模拟RAID磁盘故障:
1、停用RAID1磁盘阵列
2、清除/dev/sdb1超级块标识
3、激活RAID1磁盘阵列
4、添加/dev/sdb1到磁盘阵列中
详情如下:
[root@localhost ~]# mdadm /dev/md1 --zero-superblock /dev/sdb1
mdadm: No action given for /dev/md1 in --misc mode
Action options must come before device names
[root@localhost ~]# mdadm --zero-superblock /dev/sdb1 #磁盘阵列挂载并且激活状态下,去除标志是不会成功的
mdadm: Couldn't open /dev/sdb1 for write - not zeroing
[root@localhost ~]# mdadm -S /dev/md1 #停用RAID1磁盘阵列
mdadm: Cannot get exclusive access to /dev/md1:Perhaps a running process, mounted filesystem or active volume group?
[root@localhost ~]# df |grep disk
/dev/md1 20943872 32932 20910940 1% /disk
[root@localhost ~]# umount /disk
[root@localhost ~]# mdadm -S /dev/md1 #停用RAID1磁盘阵列
mdadm: stopped /dev/md1
[root@localhost ~]# mdadm --zero-superblock /dev/sdb1 #清除/dev/sdb1超级块标识
[root@localhost ~]# mdadm -As /dev/md1 #激活RAID1磁盘阵列
mdadm: /dev/md1 has been started with 2 drives.
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Array Size : 20954112 (19.98 GiB 21.46 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sun Aug 21 01:49:16 2016
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Events : 36
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 8 33 1 active sync /dev/sdc1
[root@localhost ~]# mdadm /dev/md1 -a /dev/sdb1 #添加/dev/sdb1到磁盘阵列中
mdadm: added /dev/sdb1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Sun Aug 21 01:26:17 2016
Raid Level : raid1
Array Size : 20954112 (19.98 GiB 21.46 GB)
Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sun Aug 21 01:50:15 2016
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
Events : 37
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 8 33 1 active sync /dev/sdc1
3 8 17 - spare /dev/sdb1
[root@localhost ~]# mdadm -Dvs >> /etc/mdadm.conf #重新生成配置信息,在磁盘阵列信息发生改变后,要重新生成配置信息
[root@localhost ~]# cat !$
cat /etc/mdadm.conf
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 spares=1 name=localhost.localdomain:1 UUID=9f8c8a03:8036f47c:788bd593:8c0c83cd
devices=/dev/sdb1,/dev/sdc1,/dev/sdd1
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 spares=1 name=localhost.localdomain:1 UUID=9f8c8a03:8036f47c:788bd593:8c0c83cd
devices=/dev/sdb1,/dev/sdc1,/dev/sdd1
[root@localhost ~]#

1-15-2-RAID1 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)的更多相关文章
- 1-15-2-RAID10 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)
RAID10的搭建: 有两种方法, 第一种:直接使用四块磁盘,创建级别为10的磁盘阵列 第二种:使用四块磁盘先创建两个RAID1,然后在用RAID1创建RAID0 第一步:添加五个磁盘到虚拟机 开机后 ...
- 1-15-2-RAID5 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)
RAID5的搭建 第一步:添加四个磁盘,开机并检查(略过) 第二步:使用fdisk命令分别对四个磁盘进行分区,效果如下图: 第三步:使用mdadm命令创建RAID5磁盘阵列 [root@localho ...
- RAID磁盘阵列的搭建(以raid0、raid1、raid5、raid10为例)
mdadm工具的使用 -C或--creat 建立一个新阵列 -r 移除设备 -A 激活磁盘阵列 -l 或--level= 设定磁盘阵列的级别 -D或--detail 打印阵列设备的详细信息 -n或-- ...
- 1-15-1 RAID磁盘阵列的原理和搭建
大纲: 1.1-1-企业级RAID磁盘阵列 RAID磁盘阵列的原理 RAID0,1,5,10的搭建 硬件RAID卡 1.2-1-使用廉价的磁盘搭建RAID磁盘阵列 实战-配置RAID0带区卷 ==== ...
- RAID磁盘阵列及CentOS7系统启动流程
磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意,,数据读取无影响.将数据切割成许多区段,分别存放在各个硬盘 ...
- Linux系统的RAID磁盘阵列
RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意. 磁盘阵列是由很多价格较便宜的磁盘,以硬件( ...
- Linux下RAID磁盘阵列的原理与搭建
RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有"独立磁盘构成的具有冗余能力的阵列"之意. 磁盘阵列是由很多价格较 ...
- RAID磁盘阵列技术
RAID磁盘阵列技术 1.RAID概述 RAID(Redundant Array of Independent Disk),从字面意思讲的是基于独立磁盘的具有冗余的磁盘阵列,其核心思想是将多块独立磁盘 ...
- 快速理解几种常用的RAID磁盘阵列级别
我发现周围不少人在学习和理解RAID磁盘阵列的原理时,找了很多专业的资料来看,但是因为动手的机会比较少,因此看完以后还是似懂非懂,真正遇到实际的方案设计的时候,还是拿不定主意. 因此,我结合自己在过去 ...
随机推荐
- PAT 1077 Kuchiguse [一般]
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...
- HMM、MEMM、CRF模型比较和标注偏置问题(Label Bias Problem)
本文转自:http://www.cnblogs.com/syx-1987/p/4077325.html 路径1-1-1-1的概率:0.4*0.45*0.5=0.09 路径2-2-2-2的概率:0.01 ...
- vertical-align和line-height的深入应用
vertical-align和line-height的深入应用 本文的重点是了解vertical-align和line-height的使用 涉及到的名词:基线,底端,行内框,行框,行间距,替换元素及非 ...
- 技术分享会(二):SQLSERVER索引介绍
SQLSERVER索引介绍 一.SQLSERVER索引类型? 1.聚集索引: 2.非聚集索引: 3.包含索引: 4.列存储索引: 5.无索引(堆表): 二.如何创建索引? 索引示例: 建表 creat ...
- XDU 1003 B进制加法(高精度)
#include<bits/stdc++.h> using namespace std; long long mpow(long long a,long long b) { ; ) ; w ...
- Git在Githib和Github上的使用
本文使用的环境是linux里 一.git的常用命令解释: 1.基础命令: git init #创建版本库 git add <file> #将文件修改添加到暂存区 git commit -m ...
- Java设计原则—里氏替换原则(转)
里氏替换原则(Liskov Substitution Principel)是解决继承带来的问题. 继承的优点: 代码共享,减少创建类的工作量,每个子类都拥有父类的方法和属性: 提高代码的重用性: 子类 ...
- 【转】Google的2012论文
转自:http://www.sigvc.org/bbs/thread-1152-1-1.html Google的论文一直是业界的风向标,尤其在机器学习.分布式系统.网络等方面很多创新性的成果都是由他们 ...
- LeetCode 902. Numbers At Most N Given Digit Set
应该是常数 N的位数时间级别 我的这个方法超时很严重...但是特此记录 费劲巴拉写的... 超时: int atMostNGivenDigitSet(char** D, int DSize, int ...
- 20145328 《Java程序设计》第10周学习总结
20145328 <Java程序设计>第10周学习总结 资料学习内容总结 网络编程 13.1 网络概述 网络编程技术是当前一种主流的编程技术,随着联网趋势的逐步增强以及网络应用程序的大量出 ...