Linux下创建软RAID1实战

简介:

[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



本文转自    OpenStack2015 博客,原文链接:    http://blog.51cto.com/andyliu/1840109    如需转载请自行联系原作者

相关文章
|
1月前
|
运维 Linux Apache
Linux Apache服务详解——Apache虚拟目录与禁止显示目录列表实战
Linux Apache服务详解——Apache虚拟目录与禁止显示目录列表实战
23 2
|
1月前
|
域名解析 Linux Apache
Linux Apache服务详解——虚拟网站主机功能实战
Linux Apache服务详解——虚拟网站主机功能实战
35 5
|
1月前
|
Linux 数据安全/隐私保护 Windows
Linux vsFTPd服务详解——本地用户登录实战
Linux vsFTPd服务详解——本地用户登录实战
37 2
|
1月前
|
运维 监控 Linux
Linux Rsync服务详解(二)——Rsync服务实战
Linux Rsync服务详解(二)——Rsync服务实战
18 1
|
2月前
|
Ubuntu Linux Shell
【Linux操作系统】探秘Linux奥秘:shell 编程的解密与实战
【Linux操作系统】探秘Linux奥秘:shell 编程的解密与实战
61 0
|
2月前
|
Ubuntu Linux Shell
【Linux操作系统】探秘Linux奥秘:用户、组、密码及权限管理的解密与实战
【Linux操作系统】探秘Linux奥秘:用户、组、密码及权限管理的解密与实战
55 0
|
19天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
42 6
|
7天前
|
Linux
Linux中grep命令详解与实战应用
Linux中grep命令详解与实战应用
11 0
|
1月前
|
移动开发 网络协议 Shell
最强优化指令大全 | 【Linux技术专题】「系统性能调优实战」终极关注应用系统性能调优及原理剖析(下册)(一)
最强优化指令大全 | 【Linux技术专题】「系统性能调优实战」终极关注应用系统性能调优及原理剖析(下册)
30 0
|
1月前
|
存储 缓存 Linux
Linux 系统调用深思:从原理到实战
Linux 系统调用深思:从原理到实战
41 1