• slider image 168
:::
條列式新聞
新聞載入中,請稍後...

9-5-1 實作1 zfs Raid1 陣列替換固障硬碟

  1. 列出 pool 內容
    root@pve4:~# zpool status VM4
    pool: VM4
     state: DEGRADED
    status: One or more devices could not be used because the label is missing or
        invalid.  Sufficient replicas exist for the pool to continue
        functioning in a degraded state.
    action: Replace the device using 'zpool replace'.
       see: http://zfsonlinux.org/msg/ZFS-8000-4J
      scan: scrub repaired 128K in 7h48m with 0 errors on Sun Aug 13 08:12:40 2017
    config:
        NAME                                      STATE     READ WRITE CKSUM
        VM4                                       DEGRADED     0     0     0
          mirror-0                                DEGRADED     0     0     0
            12927721325441278894                  UNAVAIL      0     0     0  was /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X631K3K0FNWA-part1
            ata-TOSHIBA_MD03ACA400V_X641K3LIFNWA  ONLINE       0     0     0
    errors: No known data errors
    root@pve4:~#
    找到原來 zfs Raid1 兩顆硬碟組成中固障的那一顆硬碟的 disk-id,
    (就是這一顆硬碟的序號,也可以在硬碟標籤上找到這一串數字)
    /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X631K3K0FNWA
    這個 disk-id 待會兒要以 zpool 指令替換新硬碟時會用到

     
  2. 先將有問題的硬碟拔出,換上新硬碟後開機
    再找出新硬碟的序號

    root@pve4:~# ls -alF /dev/disk/by-id/
    lrwxrwxrwx 1 root root  9  1月  8 20:33 ata-TOSHIBA_MD03ACA400V_X641K3LLFNWA -> ../../sdb
     
  3. 以 zpool replace 指令替換新的硬碟
    指令:
    zpool replace  pool名稱  固障硬碟的序號  正常新硬碟的序號


    root@pve4:~# zpool replace VM4    /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X631K3K0FNWA   \
    /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X641K3LLFNWA


    invalid vdev specification
    use '-f' to override the following errors:
    /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X641K3LLFNWA-part1 is part of exported pool 'pvefs24T1'

    新換上的硬碟原來曾以 zpool 建立名稱為 pvefs24T1 的 儲存池,所以無法替換
    如果要強制替換的話,加上   -f   參數予以強制替換

     
  4. 加上 -f 參數強制替換
    root@pve4:~# zpool replace VM4 /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X631K3K0FNWA /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X641K3LLFNWA -f
    root@pve4:~#

     
  5. 成功替換新的硬碟,查看目前 pool VM4 現況
    root@pve4:~# zpool status VM4
      pool: VM4
     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 Mon Jan  8 20:33:15 2018
        65.8G scanned out of 2.19T at 87.0M/s, 7h6m to go
        65.8G resilvered, 2.93% done
    config:
        NAME                                        STATE     READ WRITE CKSUM
        VM4                                         DEGRADED     0     0     0
          mirror-0                                  DEGRADED     0     0     0
            replacing-0                             DEGRADED     0     0     0
              12927721325441278894                  UNAVAIL      0     0     0  was /dev/disk/by-id/ata-TOSHIBA_MD03ACA400V_X631K3K0FNWA-part1
              ata-TOSHIBA_MD03ACA400V_X641K3LLFNWA  ONLINE       0     0     0  (resilvering)
            ata-TOSHIBA_MD03ACA400V_X641K3LIFNWA    ONLINE       0     0     0
    errors: No known data errors
    root@pve4:~#


     
  6. (resilvering)  ---> 重建中,將資料由另一顆硬碟同步寫進新加入的硬碟

     
  7. 重建完成

:::
展開 | 闔起

文章類別

書籍目錄

展開 | 闔起

線上使用者

14人線上 (13人在瀏覽線上書籍)

會員: 0

訪客: 14

更多…