博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux软raid下线后恢复
阅读量:7222 次
发布时间:2019-06-29

本文共 5470 字,大约阅读时间需要 18 分钟。

机器中有数据的话,操作起来必须要非常小心。内部samba服务器访问不了,到了/share(共享目录)下,什么也没有。数据全部都没看到。后来,仔细查看,发现机器有5块硬盘,好像是做了软raid

1.使用fdisk -l命令查看,发现

/dev/sde1               1       60801   488384001   fd  Linux raid autodete

2.cat /proc/mdstat,md0,md1全部都是inactive

3.全部下线,考虑了很久,因为有数据,所以不敢做太多的操作,想重新建立应该是没关系的吧

先关闭raid:mdadm -Ss,然后启动raid:mdadm -As

cat /etc/mdadm.conf

DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/md0 /dev/md1
ARRAY /dev/md0 metadata=1.2 name=file:0 UUID=4bd3bbbb:57305692:6d264713:10028518
ARRAY /dev/md1 metadata=1.2 name=file:1 UUID=190d94c6:7d7754a0:f91a4e70:acfdc372
ARRAY /dev/md2 metadata=1.2 name=file:2 UUID=6662ae21:aa253ded:46ea5e25:9a4559a4

4.启动后,fdisk -l

Disk /dev/sdb: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 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: 0xd87fd87f

  Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       38913   312568641   fd  Linux raid autodetect

Disk /dev/sdc: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 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: 0x3a563a56

  Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       38913   312568641   fd  Linux raid autodetect

Disk /dev/sdd: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x9fd1c6eb

  Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       60801   488384001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/sde: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xe0150a6e

  Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       60801   488384001   fd  Linux raid autodetect
Partition 1 does not start on physical sector boundary.

Disk /dev/md0: 319.9 GB, 319935873024 bytes
2 heads, 4 sectors/track, 78109344 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
Disk identifier: 0xddd48bce

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 500.0 GB, 499970801664 bytes
2 heads, 4 sectors/track, 122063184 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Alignment offset: 512 bytes
Disk identifier: 0x00000000

Disk /dev/md1 doesn't contain a valid partition table

Disk /dev/md2: 819.9 GB, 819906215936 bytes
2 heads, 4 sectors/track, 200172416 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Alignment offset: 512 bytes
Disk identifier: 0xe6aa9a8f

   Device Boot      Start         End      Blocks   Id  System
/dev/md2p1             129   200172416   800689152   8e  Linux LVM
Partition 1 does not start on physical sector boundary.

5.mdadm --detail /dev/md0 
/dev/md0:
       Version : 1.2
 Creation Time : Tue Mar 26 00:10:39 2013
    Raid Level : raid1
    Array Size : 312437376 (297.96 GiB 319.94 GB)
 Used Dev Size : 312437376 (297.96 GiB 319.94 GB)
  Raid Devices : 2
 Total Devices : 2
   Persistence : Superblock is persistent

   Update Time : Thu Apr  3 22:43:39 2014
         State : clean 
Active Devices : 2
Working Devices : 2
Failed Devices : 0
 Spare Devices : 0

          Name : file:0  (local to host file)
          UUID : 4bd3bbbb:57305692:6d264713:10028518
        Events : 16408

   Number   Major   Minor   RaidDevice State
      0       8       17        0      active sync   /dev/sdb1
      2       8       33        1      active sync   /dev/sdc1

就是两个磁盘做raid1,然后md0和md1做raid0

6.看了上面的输出,有使用率,说明数据还在,稍微放了一下心

直接mount /dev/md2p1 /share,提示mount: unknown filesystem type 'LVM2_member'

解决方法:

--- Logical volume ---
 LV Name                /dev/vgmd2/lvshare
 VG Name                vgmd2
 LV UUID                hN0kGI-5yBU-3ABH-rkU2-fPGi-JfX8-D1C0DQ
 LV Write Access        read/write
 LV Status              NOT available
 LV Size                256.00 GiB
 Current LE             16384
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto

 --- Logical volume ---
 LV Name                /dev/vgmd2/lvnfs
 VG Name                vgmd2
 LV UUID                PRKkOr-zzJd-O0di-GT8W-0lsf-wtN3-1bFShN
 LV Write Access        read/write
 LV Status              NOT available
 LV Size                10.00 GiB
 Current LE             640
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto

vgchange -ay后,lvdisplay

--- Logical volume ---
 LV Name                /dev/vgmd2/lvshare
 VG Name                vgmd2
 LV UUID                hN0kGI-5yBU-3ABH-rkU2-fPGi-JfX8-D1C0DQ
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                256.00 GiB
 Current LE             16384
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     4096
 Block device           254:4

 --- Logical volume ---
 LV Name                /dev/vgmd2/lvnfs
 VG Name                vgmd2
 LV UUID                PRKkOr-zzJd-O0di-GT8W-0lsf-wtN3-1bFShN
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                10.00 GiB
 Current LE             640
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     4096
 Block device           254:5

mount -t ext4 /dev/vgmd2/lvshare /share

7.最后用samba用户名和密码登陆,可以进去,没有提示无权限错误,操作要小心。

最后写入/etc/fstab


总结就是一下几步

1
2
3
4
5
6
#!/bin/bash
mdadm -Ss
mdadm -As
mdadm --detail 
/dev/md0
vgchange -ay 
/dev/vgmd2
mount 
-t ext4 
/dev/vgmd2/lvshare 
/share
本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1390178,如需转载请自行联系原作者
你可能感兴趣的文章
***微信公众平台开发: 获取用户基本信息+OAuth2.0网页授权
查看>>
第二章 例题2-2 在屏幕上显示两个短句
查看>>
【转】iOS学习之适配iOS10
查看>>
OC语言BLOCK和协议
查看>>
C++创建一个动态链接库工程
查看>>
(六)maven之本地仓库
查看>>
如何使用 SPICE client (virt-viewer) 来连接远程虚拟机桌面?
查看>>
CentOS7
查看>>
linux高编IO-------tmpnam和tmpfile临时文件
查看>>
微信的机器人开发
查看>>
从零开始学Java(二)基础概念——什么是"面向对象编程"?
查看>>
近期面试总结(2016.10)
查看>>
CodeForces 525D Arthur and Walls :只包含点和星的矩阵,需要将部分星变成点使满足点组成矩形 : dfs+思维...
查看>>
积累_前辈的推荐
查看>>
strcpy和memcpy的区别《转载》
查看>>
在windows平台下electron-builder实现前端程序的打包与自动更新
查看>>
DroidPilot V2.1 手写功能特别版
查看>>
COOKIE欺骗
查看>>
js 强转规范解读
查看>>
ACdream - 1735:输油管道
查看>>