在linux下做RAID1试验

RAID1试验

试验要求:

  • 两块磁盘做raid1

  • 破坏其中一个硬盘(做删除操作)

  • 恢复破坏的磁盘及数据

                           

实现过程:

  1. 1.准备linux,配置IP,链接putty

  2. 2.查看系统信息

[root@localhost~]# uname -a

Linuxlocalhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013x86_64 x86_64 x86_64 GNU/Linux

  1. 3.选择两块30G硬盘

  1. 4.重启

 

[root@localhost~]# reboot

 

5.浏览硬盘

 

[root@localhost~]# fdisk –l

········下面出现新的硬盘信息

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0x00000000

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0x00000000

 

6.建立分区b   c

 

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

Command (m forhelp): n

Command action

   e  extended

   p  primary partition (1-4)

p

Partitionnumber (1-4): 1

First cylinder(1-3916, default 1):

Using defaultvalue 1

Last cylinder,+cylinders or +size{K,M,G} (1-3916, default 3916):

Using defaultvalue 3916

 

Command (m forhelp): t

Selectedpartition 1

Hex code (typeL to list codes): fd

Changed systemtype of partition 1 to fd (Linux raid autodetect)

 

Command (m forhelp): w

The partitiontable has been altered!

 

Callingioctl() to re-read partition table.

Syncing disks.

建立c分区同上

 

7.查看sdb1  sdc

 

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

 

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0xaf9deeac

 

   Device Boot      Start        End      Blocks  Id  System

/dev/sdb1               1        3916   31455238+  fd  Linux raid autodetect

 

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

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0x8f842ede

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdc1               1        3916   31455238+  fd  Linux raid autodetect

 

8. 建立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 ensurethat

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

    --metadata=0.90

Continuecreating array? yes

mdadm:Defaulting to version 1.2 metadata

mdadm: array/dev/md0 started.

 

9.格式化该磁盘阵列

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

 

10.创建data目录

[root@localhost~]# mkdir /data

 

11.挂载阵列到data目录下

 

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

 

12.查看

 

[root@localhost~]# ll /data/

total 16

drwx------. 2root root 16384 Aug 15 04:36 lost+found

 

13.保存分区内容

 

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

 

14.扫描系统阵列

 

[root@localhost~]# mdadm -Ds

ARRAY /dev/md0metadata=1.2 name=localhost.localdomain:0UUID=78520035:25e976fe:7411d793:5962601a

 

15.写入到配置文件

 

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

 

16.重启查看

 

[root@localhost~]# reboot

 

17.查看挂载点

 

[root@localhost~]# mount

/dev/mapper/VolGroup-lv_rooton / type ext4 (rw)

proc on /proctype proc (rw)

sysfs on /systype sysfs (rw)

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

tmpfs on/dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/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)

 

18.查看mdstat内容

 

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

Personalities: [raid1]

md0 : activeraid1 sdc1[1] sdb1[0]

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

 

unuseddevices: <none>

 

19.将其中一块30GB Linux6 64 标准模板的克隆-4.vmdkK删除。

 

 

20.重启后查看被删除的分区

[root@localhost~]# fdisk -l

Disk /dev/sda:21.5 GB, 21474836480 bytes

255 heads, 63sectors/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

Diskidentifier: 0x0004106c

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *          1          64      512000  83  Linux

Partition 1does not end on cylinder boundary.

/dev/sda2              64        2611   20458496   8e  Linux LVM

 

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0xaf9deeac

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        3916   31455238+  fd  Linux raid autodetect

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 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

Diskidentifier: 0x00000000

 

 

Disk/dev/mapper/VolGroup-lv_root: 16.8 GB, 16752050176 bytes

255 heads, 63sectors/track, 2036 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

Diskidentifier: 0x00000000

 

 

Disk/dev/mapper/VolGroup-lv_swap: 4194 MB, 4194304000 bytes

255 heads, 63sectors/track, 509 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

Diskidentifier: 0x00000000

 

 

Disk /dev/md0:32.2 GB, 32193249280 bytes

2 heads, 4sectors/track, 7859680 cylinders

Units =cylinders of 8 * 512 = 4096 bytes

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

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

Diskidentifier: 0x00000000

 

21.raid1重建

 

模拟恢复,还是添加30GB的硬盘,重复6建立删除的分区c

 

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

mdadm: added/dev/sdc1

 

22.查看日志

 


本文出自 “我的地盘我做主” 博客,请务必保留此出处http://9281308.blog.51cto.com/9271308/1540188

在linux下做RAID1试验,古老的榕树,5-wow.com

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