linux磁盘阵列raid1的搭建教程

Posted 绿小肥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux磁盘阵列raid1的搭建教程相关的知识,希望对你有一定的参考价值。

骤1:添加两块大小相同 的磁盘

查看磁盘是否添加成功:lsblk

查看磁盘是否为raid格式

 

步骤2:/dev/sdb创建分区并且修改分区类型为raid fd

[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 0x001b1421.

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: 0x001b1421

Device Boot Start End Blocks Id System

Command (m for help):
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): 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): 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: 0x001b1421

Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux

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: 0x001b1421

Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 fd Linux raid autodetect

 

(2)/dev/sdc的创建分区并且修改分区类型为raid fd的步骤跟上面一样

(3)分区后查看结果:检查分区是否为raid类型

 步骤3:创建raid1:mdadm -C -v /dev/md1 -l 1 -n 2 /dev/sd[b-c]1

查看raid1的详细信息

步骤4:格式化并挂载设备

步骤5:设置开机自动挂载

步骤6:生成raid的配置文件

步骤7:测试:创建一个test.txt的文件

模拟坏掉一块盘mdadm /dev/md1 -f /dev/sdc1

 

查看详细信息并查看test.txt文件

出现如图所示表明raid1已经创建成功了

 

  

 

以上是关于linux磁盘阵列raid1的搭建教程的主要内容,如果未能解决你的问题,请参考以下文章

Linux中创建磁盘阵列Raid1+0

Linux配置raid1+0阵列磁盘

RAID磁盘阵列的原理与搭建

linux配置磁盘阵列raid 0raid1 raid5 raid6 raid10

linux系统中部署RAID5磁盘阵列+备份盘

RocketMq02_复制刷盘Broker常用模式磁盘阵列集群搭建