linux中新建raid1~快来瞧一瞧看一看啦~~

操作

分区:

[root@localhost ~]# fdisk -l

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

Disk identifier: 0x00000000

 

 

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

Disk identifier: 0x00000000

 

 

Disk /dev/sdd: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

Disk identifier: 0x00000000

 

fdisk /dev/sdb

 

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to

         switch off the mode (command ‘c‘) and change display units to

         sectors (command ‘u‘).

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

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): fd

Changed system type of partition 1 to fd (Linux raid autodetect)

建立raid1

[root@localhost ~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[bc]1

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

Continue creating array? yes

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

创建文件系统

格式化:

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

 

[root@localhost ~]# mkdir /data/

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

[root@localhost ~]# ll /data/

total 16

drwx------ 2 root root 16384 Aug  5 11:16 lost+found

 

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

在最后添加如下内容

 

drwx------ 2 root root 16384 Aug 14 15:21 lost+found

 

[root@localhost ~]# mdadm -Ds

ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=c00e8204:a51e89ea:f6069fbe:9350ed9a

写入配置文件

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

重新启动

[root@localhost ~]#  reboot

 

 

[root@localhost ~]# mount

/dev/mapper/VolGroup-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

/dev/md0 on /data type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

 

模拟故障

 

[root@localhost ~]# mdadm /dev/md0 -a /dev/sdb1

mdadm: added /dev/sdb1

 

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

Personalities : [raid1]

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

      20948288 blocks super 1.2 [2/1] [_U]

      [=====>...............]  recovery = 28.7% (6021952/20948288) finish=1.5min speed=159484K/sec

 

unused devices: <none>

 

 

本文出自 “新鲜的恐龙肉快来” 博客,请务必保留此出处http://9283898.blog.51cto.com/9273898/1540174

linux中新建raid1~快来瞧一瞧看一看啦~~,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。