linux raid1 失败,虚拟机Linux做RAID1并模拟故障

查看磁盘格式

[root@ns2~]# fdisk -l /dev/sdb

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0xe410bd9d

Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        3787   30419046   fd  Linux raid autodetect

[root@ns2 ~]# fdisk -l /dev/sdc

Disk /dev/sdc: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0x50b24a29

Device Boot      Start         End      Blocks  Id  System

/dev/sdc1               1        3787   30419046   fd  Linux raid autodetect

建立RAID1[root@ns2~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[bc]1

mdadm: Note: this array has metadata at thestart 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

Continue creating array?yes

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

在日志中可以看到相关的信息

[root@ns2~]# tail -f /var/log/messages

创建文件系统格式化该磁盘阵列

[root@ns2~]# mkfs.ext4 /dev/md0

新建挂载目录

[root@ns2~]# mkdir /data

挂载磁盘到新建的目录

[root@ns2~]# mount /dev/md0 /data

查看目录信息

[root@ns2~]# ll /data

total 16

drwx------ 2 root root 16384 Aug 15 03:54lost+found

将其设置为开机自动挂载

编辑

[root@ns2~]# vi /etc/fstab

添加以下内容

/dev/md0                /data                ext4        defaults       0 0

[root@ns2~]# mdadm -Ds

ARRAY /dev/md0 metadata=1.2name=ns2.yyp.local:0 UUID=000c6956:c552cc97:cdfff93c:167e3e72

写入到配置文件

[root@ns2~]# mdadm -Ds >> /etc/mdadm.conf

重新启动验证是否是自动挂载

[root@ns2 ~]# reboot

模拟故障删除一个硬盘

查看日志

在挂载目录写入东西,日志有变化

[root@ns2~]# cat /proc/mdstat

Personalities : [raid1]

md0 : active raid1 sdc1[1](F) sdb1[0]

30402560 blocks super 1.2 [2/1] [U_]

unused devices:

RAID1重建模拟恢复,还是30GB的硬盘,添加新的磁盘

[root@ns2~]# fdisk -l /dev/sdb

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0xe410bd9d

Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        3787   30419046   fd  Linux raid autodetect

fdisk -l/dev/sdb

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x9b6ff607

DeviceBoot      Start         End      Blocks  Id  System

/dev/sdb1               1        3916   31455238+  fd  Linux raid autodetect

添加的新磁盘需重复“硬盘分区”的操作

[root@ns2~]# mdadm /dev/md0 -a /dev/sdc1

mdadm: added /dev/sdc1

[root@ns2~]# cat /proc/mdstat

Personalities : [raid1]

md0 : active raid1 sdc1[2] sdb1[0]

30402560 blocks super 1.2 [2/2] [UU]

unused devices:

查看日志

md: bind

md:recovery of RAID array md0

md:minimum _guaranteed_  speed: 1000KB/sec/disk.

md:using maximum available idle IO bandwidth (but n

forrecovery.

md:using 128k window, over a total of 30402560k.

md:md0: recovery done.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值