码迷,mamicode.com
首页 > 系统相关 > 详细

linux磁盘阵列raid1的搭建教程

时间:2018-09-16 15:35:19      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:磁盘   技术   list   com   star   开机   physical   default   code   

骤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的搭建教程

标签:磁盘   技术   list   com   star   开机   physical   default   code   

原文地址:https://www.cnblogs.com/liuhui-xzz/p/9655158.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!