linux下raid1数据恢复,在linux下做RAID1试验

RAID1试验

---路亚南制作

试验要求:两块磁盘做raid1

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

恢复破坏的磁盘及数据

57a8877ce21661c86f96983ba4ae10b3.gif

实现过程:1.准备linux,配置IP,链接putty

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/Linux3.选择两块30G硬盘

d74e0afae0580dc102258e04a7c745b8.gif

62e5bdda86494eca8b45c4a381bc17ae.gif

b2285b810d3a9c221988da5a069c367e.gif

4b5ad06212920782e3384004c74cd722.gif

0382e9bb28bb66f912e8dcf3ab730180.gif

4ed32df04a1ea782895b8b018d6ca8e1.gifbdcfb69c32e51c8519ff290205dbaf5e.gif4.重启

[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:

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

979d64427d202a74f6cf3e733c3ab3c8.gif

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.查看日志

658b7a4e541f32dfd2a8c4372ce95b13.gif

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值