mdadm双盘阵

来源:互联网 发布:java判断素数 编辑:程序博客网 时间:2024/05/20 07:50

查看系统版本号

[root@localhost ~]# uname -a

Linuxlocalhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014x86_64 x86_64 x86_64 GNU/Linux

 

磁盘分区:

给/dev/sdb分区:

root@localhost ~]# fdisk /dev/sdb

Command (m for help): n

Partition type:

  p   primary (0 primary, 0extended, 4 free)

  e   extended

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-62914559, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G}(2048-62914559, default 62914559): +50M

Partition 1 of type Linux and of size 50 MiBis set

 

 

Command (m for help): n

Partition type:

  p   primary (1 primary, 0extended, 3 free)

  e   extended

Select (default p): p

Partition number (2-4, default 2): 2

First sector (104448-62914559, default104448):

Using default value 104448

Last sector, +sectors or +size{K,M,G}(104448-62914559, default 62914559): +50M

Partition 2 of type Linux and of size 50 MiBis set

 

Command (m for help): w

查看sdb的分区情况:

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

 

Disk /dev/sdb: 32.2 GB, 32212254720 bytes,62914560 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk label type: dos

Disk identifier: 0xd109dbc5

 

  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1            2048      104447       51200  83  Linux

/dev/sdb2          104448      206847       51200  83  Linux

给sdc分区

[root@localhost ~]#fdisk /dev/sdc

Command (m for help): n

Partition type:

  p   primary (0 primary, 0extended, 4 free)

  e   extended

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-62914559, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G}(2048-62914559, default 62914559): +20M

Partition 1 of type Linux and of size 20 MiBis set

 

Command (m for help): n

Partition type:

  p   primary (1 primary, 0extended, 3 free)

  e   extended

Select (default p): p

Partition number (2-4, default 2): 2

First sector (43008-62914559, default 43008):

Using default value 43008

Last sector, +sectors or +size{K,M,G}(43008-62914559, default 62914559): +30M

Partition 2 of type Linux and of size 30 MiBis set

 

Command (m for help): w

查看sdc的分区情况

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

 

Disk /dev/sdc: 32.2 GB, 32212254720 bytes,62914560 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk label type: dos

Disk identifier: 0x1c50da75

 

 Device Boot      Start         End      Blocks  Id  System

/dev/sdc1            2048       43007       20480  83  Linux

/dev/sdc2           43008      104447       30720  83  Linux

 

在Centos7上已经安装有mdadm,mdadm-3.2.6-31.el7.x86_64已经安装,无需安装。

创建RID0

[root@localhost ~]# mdadm --create --verbose/dev/md0 --level=mirror --raid-devices=2 /dev/sdb /dev/sdc

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 ensurethat

    your boot-loader understands md/v1.xmetadata, or use

    --metadata=0.90

mdadm:size set to 20955008K

Continuecreating array? y

mdadm:Defaulting to version 1.2 metadata

mdadm:array /dev/md0 started.

查看RID0创建情况

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

Personalities: [raid1]

md0 :active raid1 sdc[1] sdb[0]

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

      [===========>.........]  resync = 58.2% (12206464/20955008)finish=0.7min speed=200000K/sec

格式化光盘

root@localhost ~]# mkfs.ext4 /dev/md0

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=512 blocks, Stripe width=1024 blocks

17712 inodes, 70656 blocks

3532 blocks (5.00%) reserved for the superuser

First data block=1

Maximum filesystem blocks=33685504

9 block groups

8192 blocks per group, 8192 fragments pergroup

1968 inodes per group

Superblock backups stored on blocks:

       8193, 24577, 40961, 57345

 

Allocating group tables: done

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accountinginformation: done

 

 

创建挂载点,挂载硬盘

[root@localhost~]# mkdir /DATA

[root@localhost~]# mount /dev/md0 /DATA

保存raid配置

[root@localhost~]# mdadm --detail --scan >> /etc/mdadm.conf

[root@localhost~]# vi /etc/mdadm.conf

ARRAY/dev/md0 metadata=1.2 name=localhost.localdomain:0UUID=6db58f0f:2bb6a45c:104d1157:55200fbc

~

模拟磁盘坏掉:

仍然可以读写数据

[root@localhost~]# cd /DATA

[root@localhostDATA]# ls

lost+found

查看日志

Aug 1500:18:33 localhost kernel: Write(10): 2a 00 00 01 a1 20 00 00 08 00

Aug 1500:18:33 localhost kernel: end_request: I/O error, dev sdb, sector 106784

Aug 1500:18:33 localhost kernel: md/raid1:md0: Disk failure on sdb, disabling device.

md/raid1:md0:Operation continuing on 1 devices.

Aug 1500:18:33 localhost kernel: md/raid1:md0: redirecting sector 74016 to othermirror: sdc

0 0
原创粉丝点击