Linux下如何做raid1,Linux下创建软RAID1实战

Thu Aug 18 20:45:34 CST 2016

[[email protected] ~]# 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.

[[email protected] ~]# partprobe /dev/sdb

[[email protected] ~]# partprobe /dev/sdc

[[email protected] ~]# ls /dev/sdb*

/dev/sdb  /dev/sdb1

[[email protected] ~]# ls /dev/sdc*

/dev/sdc  /dev/sdc1

检查磁盘是 否可以创建RAID1

[[email protected] ~]# 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

[[email protected] ~]# 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状态

[[email protected] ~]# 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:

[[email protected] ~]# watch cat /proc/mdstat

查看两块盘的状态

[[email protected] ~]# 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状态

[[email protected] ~]# 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

格式化

[[email protected] ~]# 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

[[email protected] ~]# mkdir /raid1

[[email protected] ~]# mount /dev/md1 /raid1/

[[email protected] 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

aa

[[email protected] raid1]# du /raid1

204800    /raid1

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

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值