11

我的一个 vdev 驱动器出现故障,将 zpool 的状态设置为降级:root@mediaserver:~# zpool status pool: zfsraid state: DEGRADED

所以我开始采取措施更换驱动器。

这是旧磁盘的 id:wwn-0x5000cca225f459d5 这是替换磁盘的 id:wwn-0x5000c5006e38bc61

1)离线旧盘:

 zpool offline zfsraid wwn-0x5000cca225f459d5

2)用新磁盘物理替换旧磁盘

3) 发出替换命令:

 zpool replace -o ashift=12 zfsraid wwn-0x5000cca225f459d5 wwn-0x5000c5006e38bc61

替换命令失败:

root@mediaserver:~# zpool replace -o ashift=12 zfsraid wwn-0x5000cca225f459d5 wwn-0x5000c5006e38bc61
**invalid vdev specification
use '-f' to override the following errors:
/dev/disk/by-id/wwn-0x5000c5006e38bc61 does not contain an EFI label but it may contain partition
information in the MBR.**

我似乎找不到任何可以帮助的信息。一些论坛说使用 -f 选项,但这似乎很粗略。新驱动器上没有列出分区

root@mediaserver:~# fdisk -l /dev/disk/by-id/wwn-0x5000c5006e38bc61

Disk /dev/disk/by-id/wwn-0x5000c5006e38bc61: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/disk/by-id/wwn-0x5000c5006e38bc61 doesn't contain a valid partition table
root@mediaserver:~#

我是否必须运行一些命令来擦除新驱动器?

这些是 dmesg 中与驱动器相关的最后几行:

[420274.400024] scsi 11:0:8:0: Direct-Access     ATA      ST3000DM001-1CH1 CC29 PQ: 0 ANSI: 6
[420274.400036] scsi 11:0:8:0: SATA: handle(0x000f), sas_addr(0x4433221107000000), phy(7), device_name(0x0000000000000000)
[420274.400039] scsi 11:0:8:0: SATA: enclosure_logical_id(0x5000000080000000), slot(4)
[420274.400130] scsi 11:0:8:0: atapi(n), ncq(y), asyn_notify(n), smart(y), fua(y), sw_preserve(y)
[420274.400134] scsi 11:0:8:0: qdepth(32), tagged(1), simple(0), ordered(0), scsi_level(7), cmd_que(1)
[420274.400502] sd 11:0:8:0: Attached scsi generic sg17 type 0
[420274.401375] sd 11:0:8:0: [sdr] 5860533168 512-byte logical blocks: (3.00 TB/2.72 TiB)
[420274.401377] sd 11:0:8:0: [sdr] 4096-byte physical blocks
[420274.475163] sd 11:0:8:0: [sdr] Write Protect is off
[420274.475166] sd 11:0:8:0: [sdr] Mode Sense: 7f 00 10 08
[420274.475966] sd 11:0:8:0: [sdr] Write cache: enabled, read cache: enabled, supports DPO and FUA
[420274.554649]  sdr: unknown partition table
[420274.646245] sd 11:0:8:0: [sdr] Attached SCSI disk

这是我正在运行的 ubuntu 版本:

Ubuntu 12.04.3 LTS \n \l

root@mediaserver:~# uname -a

Linux mediaserver 3.5.0-44-generic #67~precise1-Ubuntu SMP Wed Nov 13 16:16:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
4

3 回答 3

17

@Matt,这里有更多细节。

TL;博士:

要使新驱动器可用于替换故障驱动器,请使用parted

mklabel GPT

扩展舞蹈混音版:

我有这个确切的问题,今晚解决了。我在 linux (0.6.0-1) 和 3 x 1TB 驱动器上使用带有 zfs 的 Debian Squeeze (6.0.10)。

root@host:~# zpool status
  pool: dead_pool
 state: DEGRADED
status: One or more devices are faulted in response to persistent errors.
    Sufficient replicas exist for the pool to continue functioning in a
    degraded state.
action: Replace the faulted device, or use 'zpool clear' to mark the device
    repaired.
 scan: resilvered 6.09G in 3h10m with 0 errors on Tue Sep  1 11:15:24 2015
config:

NAME                                    STATE     READ WRITE CKSUM
dead_pool                               DEGRADED     0     0     0
  raidz1-0                              DEGRADED     0     0     0
    scsi-SATA_<orig_device_1>           ONLINE       0     0     0
    scsi-SATA_<orig_device_2>           ONLINE       0     0     0
    scsi-SATA_<orig_device_3>           FAULTED      0     3     0  too many errors

哎呀。我今天下午出去买了一个相同尺寸(不同品牌/型号)的新驱动器,关闭电源并将其安装在三个现有的 zfs 驱动器旁边。再次通电,当系统启动时,我看到旧驱动器上出现大量 I/O 错误。可怕的东西。

在 zfs 中用新的替换旧的:

  • 旧磁盘 ID:1784233895253655477(使用“zdb”找到)
  • 新磁盘设备:/dev/disk/by-id/scsi-SATA_

    root@host:~# zpool offline dead_pool 1784233895253655477
    root@host:~# zpool replace dead_pool 1784233895253655477 /dev/disk/by-id/scsi-SATA_<new_device_id>
    invalid vdev specification
    use '-f' to override the following errors:
    /dev/disk/by-id/scsi-SATA_<new_device_id> does not contain an EFI label but it may contain partition
    information in the MBR.
    

这就是@Matt 的问题所在。使用 parted 设置 GPT(感谢systutorials.com):

root@host:~# parted /dev/disk/by-id/scsi-SATA_<new_device_id>
GNU Parted 2.3
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT                                                      
(parted) q                                                                
Information: You may need to update /etc/fstab.  

再次尝试替换:

root@host:~# zpool replace dead_pool 1784233895253655477 /dev/disk/by-id/scsi-SATA_<new_device_id>
root@host:~# 

太好了,它成功返回。现在再次检查 zpool:

root@host:~# zpool status
  pool: dead_pool
 state: DEGRADED
status: One or more devices is currently being resilvered.  The pool will
    continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
 scan: resilver in progress since Thu Sep  3 22:31:25 2015
    23.8G scanned out of 690G at 19.7M/s, 9h35m to go
    7.93G resilvered, 3.45% done
config:

    NAME                                    STATE     READ WRITE CKSUM
    dead_pool                               DEGRADED     0     0     0
      raidz1-0                              DEGRADED     0     0     0
        scsi-SATA_<orig_device_1>           ONLINE       0     0     0
        scsi-SATA_<orig_device_2>           ONLINE       0     0     0
        replacing-2                         OFFLINE      0     0     0
          scsi-SATA_<orig_device_3>         OFFLINE      0     0     0
          scsi-SATA_<new_device_id>         ONLINE       0     0     0  (resilvering)

希望这可以帮助。

于 2015-09-04T06:08:57.613 回答
3

首先,重要的是要找出您通过发行

 # zdb | grep ashift

如果它是 ashift=9,那么你将不得不用 -o ashift=9 替换你的驱动器:

 zpool replace -o ashift=9 zfsraid wwn-0x5000cca225f459d5 wwn-0x5000c5006e38bc61

但是,如果您将池设置为 ashift=12,那么您输入的命令应该是正确的。确保至少在 linux v0.6.2 上有 zfs,它应该能够处理 shift 选项。

于 2014-01-12T21:14:51.100 回答
0

在更换之前,您需要在驱动器上创建 GPT 分区表。

于 2015-06-21T23:25:31.777 回答