顯示具有 zfs 標籤的文章。 顯示所有文章
顯示具有 zfs 標籤的文章。 顯示所有文章

2012-12-01

ZFS send/receive & rsync

用 rsync 在兩組六顆硬碟的 raidz2 複製資料時發現速度很慢,根據之前的經驗 cpu 夠力的話不該這麼慢。觀察 cpu 與 disk 狀態:
  PID USERNAME  THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
   11 root        4 155 ki31     0K    64K RUN     3  98:09 321.09% idle
 1430 root        1  43    0 70468K  5136K CPU3    3   0:15 31.40% rsync
 1428 root        1  42    0 66372K  5084K select  1   0:16 31.30% rsync
    0 root      308  -8    0     0K  4928K -       1   0:20 15.04% kernel
               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
tank1       6.96G  10.9T      2      0  12.0K      0
tank2       10.7T   183G    695      0  85.7M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.96G  10.9T      0      0      0      0
tank2       10.7T   183G    769      0  95.6M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.96G  10.9T      0      0      0      0
tank2       10.7T   183G    776      0  96.2M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.96G  10.9T      0     70      0  8.61M
tank2       10.7T   183G    712      0  88.4M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.96G  10.9T      0  3.39K      0   424M
tank2       10.7T   183G    781      0  96.9M      0
不知道為什麼沒有邊讀邊寫,且讀的速度實在是有點慢... 改用 zfs send/receive 看看
  PID USERNAME  THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
   11 root        4 155 ki31     0K    64K RUN     3  34.1H 270.70% idle
    0 root      307  -8    0     0K  4912K -       0 378:49 79.44% kernel
 2937 root        1  27    0 33548K  2820K CPU3    0   0:09 12.89% zfs
 2936 root        1  25    0 33548K  2740K pipelk  3   0:06  8.59% zfs
               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
tank1       5.58G  10.9T     18  1.64K   127K   197M
tank2       10.3T   582G  1.56K      0   197M  3.27K
----------  -----  -----  -----  -----  -----  -----
tank1       6.19G  10.9T      0  3.15K      0   391M
tank2       10.3T   582G  2.34K      0   297M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.19G  10.9T      0  2.44K      0   304M
tank2       10.3T   582G  2.17K      0   276M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.81G  10.9T      0  1.05K      0   116M
tank2       10.3T   582G  1.95K      0   247M      0
----------  -----  -----  -----  -----  -----  -----
tank1       6.81G  10.9T      0  3.47K      0   427M
tank2       10.3T   582G  2.63K      0   334M      0
速度快了不少,最後 7TB 的資料花了九小時才複製完 @@
receiving full stream of tank2/data@2012-11-22 into tank1/data@2012-11-22
                received 6.88TB stream in 32266 seconds (224MB/sec)

ZFS with Advanced Format (4k sector) Drives

一組六顆 1.5T 硬碟的 raidz2 掛了兩顆 WD 1.5T,現在 1.5T 不好買且不划算,乾脆全都換成 2T。之前看人討論有沒有對齊 4k 似乎是沒什麼影響,反正新入手的硬碟都是 4k sector,那就用 4k 的做法吧。

依序建 disk0~5
#gpart create -s gpt da0
#gpart add -t freebsd-zfs -l disk0 -b 2048 -a 4k da0
對其中一顆建 4k nop 後再建 pool,zfs 會以 disk 中 sector 最大值建立 pool
#gnop create -S 4096 /dev/gpt/disk0
#zpool create tank raidz2 /dev/gpt/disk0.nop /dev/gpt/disk[1-5]
export pool 後刪掉 nop 再 import
# zpool export tank
# gnop destroy /dev/gpt/disk0.nop
# zpool import -d /dev/gpt tank 
查看 ashift 是否為 12 (2^12 = 4096)
#zdb tank|grep ashift
         ashift: 12

2012-10-19

ZFS import labeled disk

把某台主機的 ZFS Raidz2 export 後到別台 import 時發現原本已 label 命名的 disk 都變回代號。
# zpool import tank1
# zpool status tank1
  pool: tank1
 state: ONLINE
 scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank1       ONLINE       0     0     0
          raidz2-0  ONLINE       0     0     0
            da2p1   ONLINE       0     0     0
            da3p1   ONLINE       0     0     0
            da1p1   ONLINE       0     0     0
            da0p1   ONLINE       0     0     0
            ada0p1  ONLINE       0     0     0
            ada1p1  ONLINE       0     0     0

errors: No known data errors

查了手冊發現可以加上 -d 指定要尋找的目錄。
# zpool import -d /dev/label tank1 
# zpool status tank1
  pool: tank1
 state: ONLINE
 scan: none requested

config:

        NAME              STATE     READ WRITE CKSUM
        tank1             ONLINE       0     0     0
          raidz2-0        ONLINE       0     0     0
            label/s15x01  ONLINE       0     0     0
            label/s15x02  ONLINE       0     0     0
            label/s15x03  ONLINE       0     0     0
            label/s15x04  ONLINE       0     0     0
            label/s20x05  ONLINE       0     0     0
            label/h15x01  ONLINE       0     0     0

errors: No known data errors
這樣 label 就都回來了。