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

Linux下创建软RAID1实战

时间:2016-08-18 21:32:16      阅读:420      评论:0      收藏:0      [点我收藏+]

标签:linux

[root@RHEL7 ~]# date

Thu Aug 18 20:45:34 CST 2016

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

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 0xe1f55a32.

Command (m for help): p

Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xe1f55a32

   Device Boot      Start         End      Blocks   Id  System

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-10485759, default 2048):

Using default value 2048

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

Using default value 10485759

Partition 1 of type Linux and of size 5 GiB is set

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): fd     #fd:linux raid mode

Changed type of partition ‘Linux‘ to ‘Linux raid autodetect‘

Command (m for help): p

Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xe1f55a32

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1            2048    10485759     5241856   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@RHEL7 ~]# partprobe /dev/sdb

[root@RHEL7 ~]# partprobe /dev/sdc

[root@RHEL7 ~]# ls /dev/sdb*

/dev/sdb  /dev/sdb1

[root@RHEL7 ~]# ls /dev/sdc*

/dev/sdc  /dev/sdc1

 检查磁盘是 否可以创建RAID1

[root@RHEL7 ~]# mdadm -E /dev/sd[b-c]

/dev/sdb:

   MBR Magic : aa55

Partition[0] :     10483712 sectors at         2048 (type fd)

/dev/sdc:

   MBR Magic : aa55

Partition[0] :     10483712 sectors at         2048 (type fd)

创建RAID1

[root@RHEL7 ~]# mdadm -C -v /dev/md1 -l 1 -n 2 /dev/sdb1 /dev/sdc1

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 ensure that

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

    --metadata=0.90

mdadm: size set to 5237696K

Continue creating array? y

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md1 started.

查看RAID状态

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

Personalities : [raid1]

md1 : active raid1 sdc1[1] sdb1[0]

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

      [============>........]  resync = 60.6% (3175232/5237696) finish=0.1min speed=211682K/sec

unused devices: <none>

[root@RHEL7 ~]# watch cat /proc/mdstat

查看两块盘的状态

[root@RHEL7 ~]# mdadm -E /dev/sdb1 /dev/sdc1

/dev/sdb1:

          Magic : a92b4efc

        Version : 1.2

    Feature Map : 0x0

     Array UUID : b3f8134a:abc56378:c6498702:55215f10

           Name : RHEL7.2:1  (local to host RHEL7.2)

  Creation Time : Thu Aug 18 20:49:27 2016

     Raid Level : raid1

   Raid Devices : 2

 Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)

     Array Size : 5237696 (5.00 GiB 5.36 GB)

  Used Dev Size : 10475392 (5.00 GiB 5.36 GB)

    Data Offset : 8192 sectors

   Super Offset : 8 sectors

          State : clean

    Device UUID : 4cb9ba13:784b2294:29e78967:d93d8a94

    Update Time : Thu Aug 18 20:49:54 2016

       Checksum : 595f46a0 - correct

         Events : 17

   Device Role : Active device 0

   Array State : AA (‘A‘ == active, ‘.‘ == missing)

/dev/sdc1:

          Magic : a92b4efc

        Version : 1.2

    Feature Map : 0x0

     Array UUID : b3f8134a:abc56378:c6498702:55215f10

           Name : RHEL7.2:1  (local to host RHEL7.2)

  Creation Time : Thu Aug 18 20:49:27 2016

     Raid Level : raid1

   Raid Devices : 2

 Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)

     Array Size : 5237696 (5.00 GiB 5.36 GB)

  Used Dev Size : 10475392 (5.00 GiB 5.36 GB)

    Data Offset : 8192 sectors

   Super Offset : 8 sectors

          State : clean

    Device UUID : 841e8e8c:b3ffe403:a487475c:c899e735

    Update Time : Thu Aug 18 20:49:54 2016

       Checksum : d8105c7d - correct

         Events : 17

   Device Role : Active device 1

   Array State : AA (‘A‘ == active, ‘.‘ == missing)


查看RAID1状态

[root@RHEL7 ~]# mdadm -D /dev/md1

/dev/md1:

        Version : 1.2

  Creation Time : Thu Aug 18 20:49:27 2016

     Raid Level : raid1

     Array Size : 5237696 (5.00 GiB 5.36 GB)

  Used Dev Size : 5237696 (5.00 GiB 5.36 GB)

   Raid Devices : 2

  Total Devices : 2

    Persistence : Superblock is persistent

    Update Time : Thu Aug 18 20:49:54 2016

          State : clean

 Active Devices : 2

Working Devices : 2

 Failed Devices : 0

  Spare Devices : 0

           Name : RHEL7.2:1  (local to host RHEL7.2)

           UUID : b3f8134a:abc56378:c6498702:55215f10

         Events : 17

    Number   Major   Minor   RaidDevice State

       0       8       17        0      active sync   /dev/sdb1

       1       8       33        1      active sync   /dev/sdc1

[root@RHEL7 ~]#

格式化

[root@RHEL7 ~]# mkfs.xfs -f /dev/md1

meta-data=/dev/md1               isize=256    agcount=4, agsize=327356 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0

data     =                       bsize=4096   blocks=1309424, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=0

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@RHEL7 ~]# mkdir /raid1

[root@RHEL7 ~]# mount /dev/md1 /raid1/

[root@RHEL7 ~]# cd /raid1/

[root@RHEL7 raid1]# dd if=/dev/zero of=/raid1/aa bs=2M count=100

100+0 records in

100+0 records out

209715200 bytes (210 MB) copied, 1.7897 s, 117 MB/s

[root@RHEL7 raid1]# ls

aa

[root@RHEL7 raid1]# du /raid1

204800    /raid1


本文出自 “技术成就梦想” 博客,请务必保留此出处http://andyliu.blog.51cto.com/518879/1840109

Linux下创建软RAID1实战

标签:linux

原文地址:http://andyliu.blog.51cto.com/518879/1840109

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