{"id":1645,"date":"2024-06-02T15:33:29","date_gmt":"2024-06-02T07:33:29","guid":{"rendered":"https:\/\/peloo.net\/?p=1645"},"modified":"2024-08-25T23:22:21","modified_gmt":"2024-08-25T15:22:21","slug":"zfs%e6%96%87%e4%bb%b6%e6%8d%9f%e5%9d%8f%e8%87%aa%e6%84%88%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/peloo.net\/?p=1645","title":{"rendered":"zfs\u6587\u4ef6\u635f\u574f\u81ea\u6108\u6d4b\u8bd5"},"content":{"rendered":"<h1>\u80cc\u666f<\/h1>\n<p>\u6d4b\u8bd5\u5728\u786c\u76d8\u5197\u4f59\u7684zfs\u6587\u4ef6\u7cfb\u7edf\u4e0b\uff0c\u67d0\u4e2a\u786c\u76d8\u91cc\u7684\u6587\u4ef6\u635f\u574f\u540e\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u3002<\/p>\n<h1>\u73af\u5883\u4fe1\u606f<\/h1>\n<p>\u7cfb\u7edf\uff1aubuntu22.04.4\uff0c\u4f7f\u7528VMware\u865a\u62df\u673a\u521b\u5efa\uff0c\u9664\u4e86\u7cfb\u7edf\u76d8\u4e4b\u5916\uff0c\u6dfb\u52a0\u53e6\u5916\u4e24\u4e2a\u76f8\u540c\u5927\u5c0f\u76841G\u865a\u62df\u78c1\u76d8\u3002<\/p>\n<p>zfs\u7248\u672c\uff1a<\/p>\n<pre><code class=\"language-bash\">(py38) pc@vm-ubuntu2204:~$ zfs -V\nzfs-2.1.5-1ubuntu6~22.04.4\nzfs-kmod-2.1.5-1ubuntu6~22.04.3<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/PixPin_2024-06-02_15-25-54.png\" alt=\"\" \/><\/p>\n<h1>\u6a21\u62df\u8fc7\u7a0b<\/h1>\n<h2>\u5efa\u7acbzfs\u6c60\u548c\u6570\u636e\u96c6<\/h2>\n<p>\u5efa\u7acb\u4e24\u4e2a\u76d8\u7684\u6c60\uff0c\u6709\u786c\u76d8\u5197\u4f59\uff0craid-1\u6a21\u5f0f\u3002<\/p>\n<pre><code class=\"language-bash\">sudo apt update -y\nsudo apt install zfsutils-linux -y\nsudo zpool create iotdata mirror \/dev\/sdh \/dev\/sdi\nsudo zfs create iotdata\/tf\nsudo zpool status -v\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531021044902.png\" alt=\"image-20240531021044902\" \/><\/p>\n<h2>\u751f\u6210\u6d4b\u8bd5\u6587\u4ef6<\/h2>\n<p>\u4f7f\u7528\u811a\u672c\u521b\u5efa150\u4e2a\u6587\u4ef6\uff0c\u5927\u5c0f1k~10MB\u968f\u673a\uff0c\u4e14\u751f\u6210\u6bcf\u4e2a\u6587\u4ef6\u7684md5\u6821\u9a8c\u503c\u5230\/opt\u76ee\u5f55\u4e0b\uff0c\u811a\u672c\u5185\u5bb9\u5982\u4e0b\uff0c<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n\n# @Time         : 2024\/5\/29 23:20\n# @Author       : Attaboy\n# @Email        : slum2183@163.com\n# @File         : mk_dummy_files.sh\n# @Software     : PyCharm\n\n# \u6279\u91cf\u751f\u6210\u6d4b\u8bd5\u6587\u4ef6\uff0c\u5927\u5c0f1k~10MB\u968f\u673a\uff0c\u5185\u5bb9\u4f7f\u7528\u968f\u673a\u5b57\u7b26\u4e32\u586b\u5145\u3002\n# \u7528\u4e8ezfs\u6587\u4ef6\u635f\u574f\u81ea\u6108\u6d4b\u8bd5\u3002\n\n# \u811a\u672c\u6267\u884c\u65b9\u5f0f\uff1asudo bash mk_dummy_file.sh\n\nDIRECTORY=&quot;\/iotdata\/tf&quot;\nFILE_COUNT=150\nBLOCK_SIZE=1\nMIN_BLOCK_COUNT=1\nMAX_BLOCK_COUNT=10240\n\ngen_rand_int() {\n\n    # \u751f\u6210\u6307\u5b9a\u8303\u56f4\u7684\u968f\u673a\u6574\u6570\n    min=$1\n    max=$(($2-$min+1))\n    num=$(cat \/dev\/urandom | head -n 10 | cksum | awk -F &#039; &#039; &#039;{print $1}&#039;)\n    echo $(($num%$max+$min))\n\n}\n\nmake_dummy_file() {\n\n    # \u6279\u91cf\u751f\u6210\u6d4b\u8bd5\u6587\u4ef6\uff0c\u5927\u5c0f1k~10MB\u968f\u673a\uff0c\u5185\u5bb9\u4f7f\u7528\u968f\u673a\u5b57\u7b26\u4e32\u586b\u5145\u3002\n    for n in $(seq 1 $1)\n    do\n        echo &quot;loop count = ${n}&quot;\n        dummy_file=$2\/$n.bin\n        sudo dd if=\/dev\/urandom of=${dummy_file} bs=${3}k \\\n        count=$(gen_rand_int $4 $5)\n        # \u5199\u5165\u5236\u4f5c\u7684\u6587\u4ef6\u7684md5\u503c\u5230\u672c\u5730\u6587\u4ef6\uff0c\u7528\u4e8e\u540e\u7eed\u7684\u6587\u4ef6\u5b8c\u6574\u6027\u6821\u9a8c\n        sudo md5sum ${dummy_file} | sudo tee -a \/opt\/md5sum_results.txt\n    done\n\n}\n\n[ -d $DIRECTORY ] &amp;&amp; sudo rm -rf $DIRECTORY\/*.bin\n[ ! -d $DIRECTORY ] &amp;&amp; sudo mkdir -p $DIRECTORY\nsudo rm -f \/opt\/md5sum_results.txt 2&gt;\/dev\/null\n\nmake_dummy_file $FILE_COUNT $DIRECTORY $BLOCK_SIZE $MIN_BLOCK_COUNT \\\n$MAX_BLOCK_COUNT\n\nexit 0\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531021218448.png\" alt=\"image-20240531021218448\" \/><\/p>\n<h2>\u5bfc\u51fa\u6c60<\/h2>\n<p>\u5bfc\u51fa\u6c60\u540e\uff0c\u6c60\u5c31\u4e0d\u5b58\u5728\u4e86\u3002<\/p>\n<pre><code class=\"language-bash\">df -hT\n# \u91cd\u542f\u7cfb\u7edf\uff0c\u4e0d\u7136\u5bfc\u51fa\u6c60\u62a5\u9519\u201cpool is busy\u201d\nsudo init 6\nsudo umount -l \/iotdata\nsudo zpool export iotdata\nsudo zpool status -v\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531021538570.png\" alt=\"image-20240531021538570\" \/><\/p>\n<h2>\u6a21\u62df\u6587\u4ef6\u635f\u574f<\/h2>\n<p>\u4f7f\u7528dd\u5c06\u5e95\u5c42\u7684\u6570\u636e\u5757sector\u5199\u5165\u968f\u673a\u5185\u5bb9\uff0c\u6a21\u62df\u6587\u4ef6\u635f\u574f\uff0c\u4f7f\u7528\u811a\u672c\u5b9e\u73b0\uff0c\u5185\u5bb9\u5982\u4e0b\uff0c<\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\n\n# @Time         : 2024\/5\/30 20:04\n# @Author       : Attaboy\n# @Email        : slum2183@163.com\n# @File         : randomDD.sh\n# @Software     : PyCharm\n\n# \u968f\u673a\u635f\u574f\u6587\u4ef6\uff0c\u4f7f\u7528dd\u547d\u4ee4\u5199\u7a7a\u6570\u636e\u5230zfs\u6587\u4ef6\u7cfb\u7edf\u4ee5\u4e0b\u7684\u5e95\u5c42sector\n\nDISK_NAME=&quot;\/dev\/sdb&quot;\n\ngen_rand_int() {\n\n    # \u751f\u6210\u6307\u5b9a\u8303\u56f4\u7684\u968f\u673a\u6574\u6570\n    min=$1\n    max=$(($2-$min+1))\n    num=$(cat \/dev\/urandom | head -n 10 | cksum | awk -F &#039; &#039; &#039;{print $1}&#039;)\n    echo $(($num%$max+$min))\n\n}\n\nfor i in $(seq 1 100)\ndo\n    random_seek_num=$(gen_rand_int 1 999999)\n    random_count_num=$(gen_rand_int 5 9)\n    sudo dd if=\/dev\/urandom of=${DISK_NAME} bs=512 seek=${random_seek_num} \\\ncount=${random_count_num}\ndone\n\nexit 0\n<\/code><\/pre>\n<p>\u6ce8\u610fsdb\u662f\u8981\u635f\u574f\u7684\u786c\u76d8\uff0c\u6839\u636e\u81ea\u5df1\u7684\u8bbe\u5907\u800c\u5b9a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531021831085.png\" alt=\"image-20240531021831085\" \/><\/p>\n<h2>\u5bfc\u5165\u6c60<\/h2>\n<pre><code class=\"language-bash\">sudo zpool import\nsudo zpool import iotdata\n<\/code><\/pre>\n<p>\u6ce8\u610f\u6b64\u65f6\u8fd8\u6ca1\u6709\u68c0\u6d4b\u5230\u635f\u574f\u7684\u6587\u4ef6\uff0c\u56e0\u4e3a\u62a5\u9519\u662f0\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022136396.png\" alt=\"image-20240531022136396\" \/><\/p>\n<p>\u4f7f\u7528md5\u6821\u9a8c\u6587\u4ef6\u7684\u5b8c\u6574\u6027\u5168\u90e8OK\uff0c<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022304318.png\" alt=\"image-20240531022304318\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022336288.png\" alt=\"image-20240531022336288\" \/><\/p>\n<p>\u8bf4\u660ezfs\u4ece\u5197\u4f59\u76d8\u62ff\u5230\u4e86\u5b8c\u6574\u7684\u6570\u636e\u3002<\/p>\n<p>\u56e0\u4e3a\u89e6\u53d1\u4e86\u6587\u4ef6\u8bbf\u95ee\uff0c\u73b0\u5728\u518d\u6b21\u67e5\u770b\u6c60\u7684\u72b6\u6001\u5c31\u4f1a\u663e\u793a\u9519\u8bef\u7684\u6587\u4ef6\u6821\u9a8c\uff0c\u5982\u4e0b\u56fe\uff0c<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022551724.png\" alt=\"image-20240531022551724\" \/><\/p>\n<p>\u5c06\u6570\u636e\u540c\u6b65\u5230\u635f\u574f\u7684\u5b58\u50a8\u8bbe\u5907\uff0c<\/p>\n<pre><code class=\"language-bash\">sudo zpool scrub iotdata<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022833407.png\" alt=\"image-20240531022833407\" \/><\/p>\n<p>\u4fee\u590d\u5b8c\u6210\u540e\u6211\u4eec\u53ef\u4ee5\u6d88\u9664\u9519\u8bef\u8b66\u544a\uff0c<\/p>\n<pre><code class=\"language-bash\">sudo zpool clear iotdata<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/minio.peloo.cn\/blog\/image-20240531022938644.png\" alt=\"image-20240531022938644\" \/><\/p>\n<h1>FAQ<\/h1>\n<h2>zfs\u7684\u4e00\u4e9b\u6982\u5ff5<\/h2>\n<p>\u8be6\u89c1\u5b98\u65b9\u6587\u6863<\/p>\n<p><a href=\"http:\/\/www.giis.co.in\/Zfs_ondiskformat.pdf\">http:\/\/www.giis.co.in\/Zfs_ondiskformat.pdf<\/a><\/p>\n<h2>ZFS Recordsize \u548c TXG \u63a2\u7d22<\/h2>\n<p><a href=\"https:\/\/tim-tang.github.io\/blog\/2016\/06\/01\/zfs-recordsize-txg\">https:\/\/tim-tang.github.io\/blog\/2016\/06\/01\/zfs-recordsize-txg<\/a><\/p>\n<h2>zfs\u7684\u5e38\u89c1\u64cd\u4f5c<\/h2>\n<p>\u8be6\u89c1\u5b98\u65b9\u6587\u6863<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/cd\/E26926_01\/html\/E25826\/gbchy.html#gazqr\">https:\/\/docs.oracle.com\/cd\/E26926_01\/html\/E25826\/gbchy.html#gazqr<\/a><\/p>\n<h2>dd \u547d\u4ee4\u4e2d\u7684 skip \u548c seek \u7406\u89e3<\/h2>\n<p>skip=xxx \u662f\u5728\u5907\u4efd\u65f6\u5bf9if \u540e\u9762\u7684\u90e8\u5206\u4e5f\u5c31\u662f\u539f\u6587\u4ef6\u8df3\u8fc7\u591a\u5c11\u5757\u518d\u5f00\u59cb\u5907\u4efd\uff1b<\/p>\n<p>seek=xxx\u5219\u662f\u5728\u5907\u4efd\u65f6\u5bf9of \u540e\u9762\u7684\u90e8\u5206\u4e5f\u5c31\u662f\u76ee\u6807\u6587\u4ef6\u8df3\u8fc7\u591a\u5c11\u5757\u518d\u5f00\u59cb\u5199\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u6d4b\u8bd5\u5728\u786c\u76d8\u5197\u4f59\u7684zfs\u6587\u4ef6\u7cfb\u7edf\u4e0b\uff0c\u67d0\u4e2a\u786c\u76d8\u91cc\u7684\u6587\u4ef6\u635f\u574f\u540e\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u3002 \u73af\u5883\u4fe1\u606f \u7cfb\u7edf\uff1aubuntu22.04.4\uff0c\u4f7f\u7528VMware\u865a\u62df\u673a\u521b\u5efa\uff0c\u9664\u4e86\u7cfb\u7edf\u76d8\u4e4b\u5916\uff0c\u6dfb\u52a0\u53e6\u5916\u4e24\u4e2a\u76f8\u540c\u5927\u5c0f\u76841G\u865a\u62df\u78c1\u76d8\u3002 zfs\u7248\u672c\uff1a (py38) pc@vm-ubuntu2204:~$ zfs -V zfs-2.1.5-1ubuntu6~22.04.4 zfs-kmod-2.1.5-1ubuntu6~22.04.3 \u6a21\u62df\u8fc7\u7a0b \u5efa\u7acbzfs\u6c60\u548c\u6570\u636e\u96c6 \u5efa\u7acb\u4e24\u4e2a\u76d8\u7684\u6c60\uff0c\u6709\u786c\u76d8\u5197\u4f59\uff0craid-1\u6a21\u5f0f\u3002 sudo apt update -y sudo apt install zfsutils-linux -y sudo zpool create iotdata mirror \/dev\/sdh \/dev\/sdi sudo zfs create iotdata\/tf sudo zpool status -v \u751f\u6210\u6d4b\u8bd5\u6587\u4ef6 \u4f7f\u7528\u811a\u672c\u521b\u5efa150\u4e2a\u6587\u4ef6\uff0c\u5927\u5c0f1k~10MB\u968f\u673a\uff0c\u4e14\u751f\u6210\u6bcf\u4e2a\u6587\u4ef6\u7684md5\u6821\u9a8c\u503c\u5230\/opt\u76ee\u5f55\u4e0b\uff0c\u811a\u672c\u5185\u5bb9\u5982\u4e0b\uff0c #!\/bin\/bash # @Time : 2024\/5\/29 23:20 # @Author : Attaboy # @Email : slum2183@163.com #&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1645","post","type-post","status-publish","format-standard","hentry","category-os"],"aioseo_notices":[],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1645"}],"version-history":[{"count":2,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1645\/revisions"}],"predecessor-version":[{"id":1659,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1645\/revisions\/1659"}],"wp:attachment":[{"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}