{"id":251,"date":"2009-07-21T23:29:38","date_gmt":"2009-07-21T15:29:38","guid":{"rendered":"http:\/\/www.yaoge123.com\/blog\/?p=251"},"modified":"2009-07-21T23:29:38","modified_gmt":"2009-07-21T15:29:38","slug":"freebsd%e4%b8%8bzfs-mirror%e5%8d%87%e9%99%8d%e7%ba%a7%e3%80%81%e7%a1%ac%e7%9b%98%e6%9b%bf%e6%8d%a2%e5%92%8c%e5%9c%a8%e7%ba%bf%e5%a2%9e%e5%ae%b9%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/www.yaoge123.com\/blog\/archives\/251","title":{"rendered":"FreeBSD\u4e0bZFS mirror\u5347\u964d\u7ea7\u3001\u786c\u76d8\u66ff\u6362\u548c\u5728\u7ebf\/\u79bb\u7ebf\u6269\u5bb9\u5b9e\u8df5"},"content":{"rendered":"<p>\u521b\u5efa\u4e00\u4e2a\u975e\u5197\u4f59\u7684ZFS pool<br \/>\ntest# zpool create zfspool da1<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    110K   7.94G     0%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: none requested<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          da1       ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u589e\u52a0\u4e00\u4e2a\u76d8\uff0c\u5347\u7ea7\u4e3a\u53cc\u8defmirror<br \/>\ntest# zpool attach zfspool da1 da2<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    112K   7.94G     0%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:24:27 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u5982\u679c\u60f3\u76f4\u63a5\u5efa\u7acb\u4e00\u4e2a\u53cc\u8defmirror\u7684ZFS pool\u7528<br \/>\ntest# zpool create zfspool mirror da1 da2<\/p>\n<p>\u518d\u589e\u52a0\u4e00\u4e2a\u76d8\uff0c\u5347\u7ea7\u4e3a\u4e09\u8defmirror<!--more--><br \/>\ntest# zpool attach zfspool da1 da3<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    112K   7.94G     0%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:24:40 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     ONLINE       0     0     0<br \/>\n            da3     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u5220\u9664\u4e00\u4e2a\u76d8\uff0c\u964d\u7ea7\u4e3a\u53cc\u8defmirror<br \/>\ntest# zpool detach zfspool da3<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    111K   7.94G     0%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:24:40 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u76f4\u63a5\u62d4\u6389\u4e00\u4e2a\u786c\u76d8<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\nstatus: One or more devices could not be opened.  Sufficient replicas exist for<br \/>\n        the pool to continue functioning in a degraded state.<br \/>\naction: Attach the missing device and online it using &#8216;zpool online&#8217;.<br \/>\n   see: http:\/\/www.sun.com\/msg\/ZFS-8000-D3<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:24:40 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     UNAVAIL      0     0     0  cannot open<\/p>\n<p>errors: No known data errors<br \/>\nZFS\u8ba4\u4e3a\u786c\u76d8da2\u79bb\u7ebf\uff0c\u5f3a\u5236\u4e0a\u7ebf\u4e00\u4e0b<br \/>\ntest# zpool online zfspool da2<br \/>\nBringing device da2 online<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  DEGRADED   &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: DEGRADED<br \/>\nstatus: One or more devices could not be opened.  Sufficient replicas exist for<br \/>\n        the pool to continue functioning in a degraded state.<br \/>\naction: Attach the missing device and online it using &#8216;zpool online&#8217;.<br \/>\n   see: http:\/\/www.sun.com\/msg\/ZFS-8000-D3<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:51:48 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     DEGRADED     0     0     0<br \/>\n          mirror    DEGRADED     0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     UNAVAIL      0     0     0  cannot open<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u628a\u62d4\u6389\u7684\u76d8\u6e05\u7a7a\u518d\u63d2\u56de\u53bb<br \/>\ntest# zpool online zfspool da2<br \/>\nBringing device da2 online<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\nstatus: One or more devices could not be used because the label is missing or<br \/>\n        invalid.  Sufficient replicas exist for the pool to continue<br \/>\n        functioning in a degraded state.<br \/>\naction: Replace the device using &#8216;zpool replace&#8217;.<br \/>\n   see: http:\/\/www.sun.com\/msg\/ZFS-8000-4J<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 21:59:39 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     UNAVAIL      0     0     0  corrupted data<\/p>\n<p>errors: No known data errors<br \/>\n\u5e94\u8be5\u76f4\u63a5\u4f7f\u7528zpool replace\u6765\u66ff\u6362\u574f\u6389\u7684\u76d8<br \/>\ntest# zpool replace zfspool da2<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  DEGRADED   &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: DEGRADED<br \/>\nstatus: One or more devices is currently being resilvered.  The pool will<br \/>\n        continue to function, possibly in a degraded state.<br \/>\naction: Wait for the resilver to complete.<br \/>\n scrub: resilver in progress, 2.06% done, 0h9m to go<br \/>\nconfig:<\/p>\n<p>        NAME           STATE     READ WRITE CKSUM<br \/>\n        zfspool        DEGRADED     0     0     0<br \/>\n          mirror       DEGRADED     0     0     0<br \/>\n            da1        ONLINE       0     0     0<br \/>\n            replacing  DEGRADED     0     0     0<br \/>\n              da2\/old  UNAVAIL      0     0     0  cannot open<br \/>\n              da2      ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<br \/>\n\u7b49\u5f85\u6570\u636e\u6062\u590d\u5b8c\u6210\uff0cpool\u5c31\u6062\u590d\u6b63\u5e38\u4e86<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 22:11:41 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u7528\u66f4\u5927\u7684da3\u3001da4\u66ff\u6362\u5c0f\u7684da1\u3001da2<br \/>\ntest# zpool replace zfspool da1 da3<br \/>\ntest# zpool replace zfspool da2 da4<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\nstatus: One or more devices is currently being resilvered.  The pool will<br \/>\n        continue to function, possibly in a degraded state.<br \/>\naction: Wait for the resilver to complete.<br \/>\n scrub: resilver in progress, 2.50% done, 0h10m to go<br \/>\nconfig:<\/p>\n<p>        NAME           STATE     READ WRITE CKSUM<br \/>\n        zfspool        ONLINE       0     0     0<br \/>\n          mirror       ONLINE       0     0     0<br \/>\n            replacing  ONLINE       0     0     0<br \/>\n              da1      ONLINE       0     0     0<br \/>\n              da3      ONLINE       0     0     0<br \/>\n            replacing  ONLINE       0     0     0<br \/>\n              da2      ONLINE       0     0     0<br \/>\n              da4      ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<br \/>\n\u56e0\u66ff\u6362\u786c\u76d8\uff0c\u6240\u4ee5\u9700\u5c06\u6570\u636e\u4ece\u65e7\u786c\u76d8\u590d\u5236\u5230\u65b0\u786c\u76d8\u4e0a\uff0c\u5b8c\u6210\u540e\u5bb9\u91cf\u6ca1\u6709\u589e\u52a0<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G   3.97G   3.97G    49%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 22:36:43 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da3     ONLINE       0     0     0<br \/>\n            da4     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<br \/>\n\u9700\u8981\u5bfc\u5165\u5bfc\u51fapool\u624d\u80fd\u67e5\u770b\u589e\u52a0\u7684\u5bb9\u91cf<br \/>\ntest# zpool export -f zfspool<br \/>\ntest# zpool import zfspool<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                11.9G   3.97G   7.97G    33%  ONLINE     &#8211;<\/p>\n<p>\u90a3\u4e48\u5982\u4f55\u624d\u80fd\u5728\u7ebf\u6269\u5bb9\u5462\uff1f\u9700\u8981\u9996\u5148detach\u5230\u975emirror\uff0creplace\u5b9e\u73b0\u5728\u7ebf\u6269\u5bb9\uff0c\u7136\u540e\u5728attach\u5230mirror<br \/>\n\u5220\u9664zfspool\uff0c\u91cd\u65b0\u5efa\u7acb\u505a\u4e00\u6b21<br \/>\ntest# zpool destroy zfspool<br \/>\ntest# zpool create zfspool mirror da1 da2<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    454M   7.49G     5%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: none requested<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da1     ONLINE       0     0     0<br \/>\n            da2     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u964d\u7ea7\u5e76\u66ff\u6362<br \/>\ntest# zpool detach zfspool da2<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    454M   7.49G     5%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: none requested<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          da1       ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<br \/>\ntest# zpool replace zfspool da1 da3<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                7.94G    454M   7.49G     5%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\nstatus: One or more devices is currently being resilvered.  The pool will<br \/>\n        continue to function, possibly in a degraded state.<br \/>\naction: Wait for the resilver to complete.<br \/>\n scrub: resilver in progress, 48.54% done, 0h0m to go<br \/>\nconfig:<\/p>\n<p>        NAME         STATE     READ WRITE CKSUM<br \/>\n        zfspool      ONLINE       0     0     0<br \/>\n          replacing  ONLINE       0     0     0<br \/>\n            da1      ONLINE       0     0     0<br \/>\n            da3      ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u66ff\u6362\u5b8c\u6210\u540e\u5bb9\u91cf\u589e\u5927<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                11.9G    454M   11.5G     3%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 23:26:01 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          da3       ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u5347\u7ea7\u5230mirror<br \/>\ntest# zpool attach zfspool da3 da4<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                11.9G    454M   11.5G     3%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\nstatus: One or more devices is currently being resilvered.  The pool will<br \/>\n        continue to function, possibly in a degraded state.<br \/>\naction: Wait for the resilver to complete.<br \/>\n scrub: resilver in progress, 45.43% done, 0h0m to go<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da3     ONLINE       0     0     0<br \/>\n            da4     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u5347\u7ea7\u5b8c\u6210<br \/>\ntest# zpool list<br \/>\nNAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT<br \/>\nzfspool                11.9G    454M   11.5G     3%  ONLINE     &#8211;<br \/>\ntest# zpool status<br \/>\n  pool: zfspool<br \/>\n state: ONLINE<br \/>\n scrub: resilver completed with 0 errors on Tue Jul 21 23:29:13 2009<br \/>\nconfig:<\/p>\n<p>        NAME        STATE     READ WRITE CKSUM<br \/>\n        zfspool     ONLINE       0     0     0<br \/>\n          mirror    ONLINE       0     0     0<br \/>\n            da3     ONLINE       0     0     0<br \/>\n            da4     ONLINE       0     0     0<\/p>\n<p>errors: No known data errors<\/p>\n<p>\u5982\u679cattache\u7684\u786c\u76d8\u5c0f\u662f\u4e0d\u4f1a\u6210\u529f\u7684<br \/>\ntest# zpool attach zfspool da3 da1<br \/>\ncannot attach da1 to da3: device is too small<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efa\u4e00\u4e2a\u975e\u5197\u4f59\u7684ZFS pool test# zpool create zfspool da1 test# z [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15],"tags":[210,69],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-freebsd","tag-freebsd","tag-zfs"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paOwEq-43","_links":{"self":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":0,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}