{"id":3152,"date":"2024-03-05T22:36:43","date_gmt":"2024-03-05T14:36:43","guid":{"rendered":"https:\/\/www.yaoge123.com\/blog\/?p=3152"},"modified":"2026-02-25T21:20:04","modified_gmt":"2026-02-25T13:20:04","slug":"%e5%bc%80%e6%ba%90%e9%95%9c%e5%83%8f%e7%ab%99%e7%bc%93%e5%ad%98%e5%8a%a0%e9%80%9f","status":"publish","type":"post","link":"https:\/\/www.yaoge123.com\/blog\/archives\/3152","title":{"rendered":"\u5f00\u6e90\u955c\u50cf\u7ad9\u7f13\u5b58\u52a0\u901f"},"content":{"rendered":"\n<p>\u9664\u4e86\u67d0\u4e9b\u571f\u8c6a\u7ad9\u7528\u5168\u95ea\u4ee5\u5916\uff0c\u5927\u591a\u6570\u5f00\u6e90\u955c\u50cf\u7ad9\u90fd\u662f\u4ee5\u673a\u68b0\u76d8\u4e3a\u4e3b\uff0c\u5f53\u5e26\u5bbd\u5145\u88d5\u7684\u65f6\u5019IO\u663e\u7136\u4f1a\u6210\u4e3a\u74f6\u9888\uff0c\u90a3\u4e48\u91c7\u7528\u5c11\u91cf\u7684SSD\u6765\u63d0\u5347\u6027\u80fd\u51e0\u4e4e\u662f\u552f\u4e00\u7684\u529e\u6cd5\u3002\u52a0SSD\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>lvmcache bcache bcachefs\uff1a\u56e0\u5728\u7528ZFS\u6240\u4ee5\u6ca1\u6709\u6d4b\u8bd5\u8fd9\u7c7b\u65b9\u6848\uff0c\u770b\u4e0a\u53bb\u6bd4\u8f83\u590d\u6742\uff1b<\/li>\n\n\n\n<li>ZFS L2ARC\uff1a\u5b9e\u9645\u6d4b\u8bd5\u57fa\u672c\u65e0\u6548\u679c\uff0czpool iostat \u770bL2ARC\u8bfb\u53d6\u5f88\u5c11\uff1b<\/li>\n\n\n\n<li>nginx proxy_cache\uff1a\u6548\u679c\u663e\u8457\uff0c\u4f46\u662f\u5fc5\u987b\u7528\u53cd\u4ee3\u3002<\/li>\n<\/ol>\n\n\n\n<p>proxy_cache\u914d\u7f6e\u5728\u524d\u7aefnginx\u4e0a\uff0c\u524d\u7aefnginx\u8bbf\u95eeSSD\uff0c\u524d\u7aefnginx\u9700\u8981\u7f16\u8bd1\u5b89\u88c5<a href=\"https:\/\/github.com\/nginx-modules\/ngx_cache_purge\/\">ngx_cache_purge<\/a>\u4ee5\u4fbf\u4e3b\u52a8\u6e05\u9664\u7f13\u5b58\u3002\u524d\u7aefnginx\u53cd\u4ee3\u7ed9\u540e\u7aefnginx\uff0c\u540e\u7aefnginx\u8bbf\u95ee\u673a\u68b0\u76d8\u63d0\u4f9b\u5b9e\u9645\u7684\u6570\u636e\u3002\u5f53\u7136\u4e5f\u53ef\u4ee5\u4e00\u4e2anginx\u540c\u65f6\u8bbf\u95eeSSD\u548c\u673a\u68b0\u76d8\uff0c\u8fd9\u4e2anginx\u81ea\u5df1\u53cd\u4ee3\u7ed9\u81ea\u5df1\uff0c\u56e0\u4e3a\u53ea\u6709\u53cd\u4ee3\u4e86\u624d\u80fd\u7f13\u5b58\uff0c\u524d\u7aefnginx\u7f13\u5b58\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>mirror.conf<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>http {\n    \u2026\u2026\n    map $http_origin $good_origin {\n        ~*(&#91;.|\/]|^)mirrorz.org$ 1;\n        ~*(\/|^)mirrors.cernet.edu.cn$ 1;\n        default 0;\n    }\n    upstream zfs_server {\n        server 192.168.10.10:80;\n        keepalive 300;\n    }\n    proxy_cache_path \/cache levels=1:2 use_temp_path=off keys_zone=mirror:128m inactive=28d max_size=8192g;\n    \u2026\u2026\n}\nserver {\n    listen 80;\n    listen &#91;::]:80;\n    listen 443 ssl;\n    listen &#91;::]:443 ssl;\n    listen *:443 quic;\n    listen &#91;::]:443 quic;\n    server_name mirror.nju.edu.cn mirrors.nju.edu.cn;\n    \u2026\u2026\n    location \/ {\n        include conf.d\/proxy_zfs;\n    }\n    location \/.mirrorz\/ {\n        if ($good_origin) {\n            add_header 'Access-Control-Allow-Origin' \"$http_origin\" always;\n            add_header 'Vary' \"Origin\";\n            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-TUNA-MIRROR-ID';\n            add_header X-Cache-Status $upstream_cache_status;\n        }\n        include conf.d\/proxy_zfs;\n    }\n    \u2026\u2026\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>proxy_zfs<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>proxy_pass http:\/\/zfs_server;\nproxy_redirect ~*^http:\/\/&#91;^\/]+(:\\d+)?(\/.*)$ $2;\nproxy_http_version 1.1;\nproxy_set_header Connection \"\";\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\nproxy_connect_timeout 600s;\nproxy_read_timeout 600s;\nproxy_send_timeout 600s;\nproxy_cache mirror;\nproxy_cache_key $uri;\nproxy_cache_valid 200 7d;\nproxy_cache_valid 301 302 1d;\nproxy_cache_valid any 1m;\nproxy_cache_lock on;\nproxy_cache_lock_timeout 600s;\nproxy_cache_lock_age 600s;\nproxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;\nproxy_cache_revalidate on;\ncache_purge_response_type text;\nproxy_cache_purge PURGE from 127.0.0.1 192.168.10.10;\nadd_header X-Cache-Status $upstream_cache_status;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>proxy_cache_path\uff1a<br \/>use_temp_path=off \u4e34\u65f6\u6587\u4ef6\u76f4\u63a5\u653e\u5230 cache \u76ee\u5f55\u4e2d\uff0c\u9632\u6b62\u6587\u4ef6\u5728 temp_path \u548c cache_path \u4e4b\u95f4\u79fb\u52a8\u3002\u7f13\u5b58\u6587\u4ef6\u4f1a\u5148\u653e\u5728 temp_path \u4e2d\uff0c\u4e0b\u8f7d\u5b8c\u4e86\u518d\u79fb\u52a8\u5230 cache_path \u4e0b\uff0c\u8bbe\u5b9a\u6210 off \u6bd4\u8f83\u7b80\u5355\u5b89\u5168\u3002<br \/>keys_zone=mirror:128m \u5185\u5b58\u7f13\u5b58\u533a\u540d\u79f0\u662f mirror \u5bb9\u91cf\u662f128MB\uff0c\u6bcfMB\u5185\u5b58\u53ef\u4ee5\u7f13\u5b58\u516b\u5343\u4e2akey\uff0c\u53ef\u4ee5\u4f30\u7b97\u4e00\u4e0bkey\u7684\u6570\u91cf\u8bbe\u5b9a\u7f13\u5b58\u533a\u5927\u5c0f\u3002<br \/>inactive=28d \u8d85\u8fc728\u5929\u6ca1\u6709\u8bbf\u95ee\u7684\u7f13\u5b58\u4f1a\u88ab\u5220\u9664\uff0c\u65e0\u8bba\u662f\u5426 valid\uff0c\u9632\u6b62\u7f13\u5b58\u88ab\u957f\u671f\u672a\u7528\u7684\u6570\u636e\u5360\u7528\u3002<br \/>max_size=8192g \u8981\u6bd4\u7f13\u5b58\u76ee\u5f55 \/cache \u5bb9\u91cf\u5c0f\uff0c\u5982\u679c\u7f13\u5b58\u7528\u5c3d nginx \u4f1a\u62a5\u9519 [crit] \u2026\u2026 failed (2: No such file or directory) \u800c\u4e14\u4f1a\u76f4\u63a5\u65ad\u5f00\u5ba2\u6237\u7aef\u94fe\u63a5\u3002<\/li>\n\n\n\n<li>proxy_cache mirror\uff1a\u5339\u914d\u524d\u9762 proxy_cache_path \u7684\u5185\u5b58\u7f13\u5b58\u533a\u540d\u79f0\u3002<\/li>\n\n\n\n<li>proxy_cache_key $uri\uff1a\u8bf7\u6c42\u7684URL\uff0c\u7528\u8fd9\u4e2aURL\u7528\u4f5c\u7f13\u5b58\u7684key\uff0c\u53bb\u6389\u4e86\u53c2\u6570\u540e\u7684\u771f\u5b9e\u6587\u4ef6\u8def\u5f84\u3002\u53ea\u8981\u8fd9\u4e2akey\u6837\u5219nginx\u7528\u7f13\u5b58\u4e2d\u4e00\u6837\u7684\u6570\u636e\u56de\u590d\u3002<\/li>\n\n\n\n<li>proxy_cache_valid 200 7d; proxy_cache_valid 301 302 1d; proxy_cache_valid any 1m;\uff1aHTTP\u72b6\u6001\u7801200\u7684\u7f13\u5b587\u5929\u3001301\/302\u7684\u7f13\u5b5824\u5c0f\u65f6\u3001\u5176\u5b83\u7684\u7f13\u5b581\u5206\u949f\uff0c\u7f13\u5b58\u8fbe\u5230\u8fd9\u4e2a\u65f6\u95f4\u5c31\u4f1a\u88ab\u629b\u5f03\uff0c\u9632\u6b62\u6570\u636e\u88ab\u957f\u671f\u7f13\u5b58\u4e0d\u80fd\u5f97\u5230\u66f4\u65b0\u3002<\/li>\n\n\n\n<li>proxy_cache_lock on\uff1a\u5f53\u6709\u591a\u4e2a\u8bf7\u6c42\u540c\u4e00\u4e2a\u6587\u4ef6\u65f6\uff08\u540c\u4e00\u4e2akey\uff09\uff0c\u53ea\u6709\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u4ece\u53cd\u4ee3\u4e2d\u83b7\u53d6\uff0c\u901a\u8fc7\u52a0\u9501\u8ba9\u540e\u7eed\u7684\u8bf7\u6c42\u7b49\u5f85\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e\u4ece\u7f13\u5b58\u4e2d\u83b7\u53d6\uff0c\u9632\u6b62\u5e76\u53d1\u4ece\u540e\u7aef\u4e2d\u8bf7\u6c42\u540c\u4e00\u4e2a\u6587\u4ef6\uff0c\u52a0\u91cd\u540e\u7aef\u8d1f\u8f7d\u3002<\/li>\n\n\n\n<li>proxy_cache_lock_age 600s\uff1a\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u9501\u5b9a600\u79d2\uff0c\u5230\u671f\u540e\u5c31\u91ca\u653e\u9501\uff0c\u4e0b\u4e00\u4e2a\u8bf7\u6c42\u53d1\u9001\u5230\u540e\u7aef\u3002<\/li>\n\n\n\n<li>proxy_cache_lock_timeout 600s\uff1a\u540e\u7eed\u7684\u8bf7\u6c42\u5982\u679c\u7b49\u5f85600\u79d2\u8fd8\u672a\u4ece\u7f13\u5b58\u4e2d\u83b7\u53d6\uff0c\u5c31\u76f4\u63a5\u4ece\u540e\u7aef\u83b7\u53d6\uff0c\u4f46\u662f\u4e0d\u7f13\u5b58\u3002<\/li>\n\n\n\n<li>proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504\uff1a\u5f53\u8bf7\u6c42\u540e\u7aef\u65f6\u51fa\u73b0\u9519\u8bef\uff08error\uff09\u6216\u8d85\u65f6\uff08timeout\uff09\u65f6\u4f7f\u7528\u8fc7\u671f\u7f13\u5b58\uff0c\u51fa\u73b0\u4e00\u4e9b5xx\u9519\u8bef\u4e5f\u7528\u8fc7\u671f\u7f13\u5b58\uff0c\u8fc7\u671f\u7684\u7f13\u5b58\u603b\u6bd4\u6ca1\u6709\u597d\u3002<\/li>\n\n\n\n<li>proxy_cache_revalidate on\uff1a\u66f4\u65b0\u7f13\u5b58\u65f6\u4f7f\u7528 If-Modified-Since \u548c If-None-Match \u8bf7\u6c42\u540e\u7aef\uff0c\u540e\u7aef\u53ef\u4ee5\u8fd4\u56de304\u800c\u975e200\u51cf\u5c11\u4f20\u8f93\u3002<\/li>\n\n\n\n<li>cache_purge_response_type text\uff1a\u6e05\u9664\u7f13\u5b58\u540e\u8fd4\u56de\u6587\u672c\u683c\u5f0f\u7684\u7ed3\u679c\u3002<\/li>\n\n\n\n<li>proxy_cache_purge PURGE from 127.0.0.1 192.168.10.10\uff1a\u4f7f\u7528PURGE\u8fd9\u4e2aHTTP\u65b9\u6cd5\u6e05\u9664\u7f13\u5b58\uff0c\u5141\u8bb8\u672c\u5730\u548c192.168.10.10\u6765\u6e05\u9664\u3002<\/li>\n\n\n\n<li>add_header X-Cache-Status $upstream_cache_status\uff1a\u6dfb\u52a0HTTP\u5934X-Cache-Status\u4ee5\u4fbf\u5ba2\u6237\u7aef\u77e5\u9053\u7f13\u5b58\u60c5\u51b5\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u540e\u7aefnginx\u53ef\u80fd\u9700\u8981\u8bbe\u5b9a\u67d0\u4e9b\u6587\u4ef6\u7684\u4e0d\u7f13\u5b58\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    root \/mirror;\n    \u2026\u2026\n    location ~ ^\/no_cache\/ {\n        expires -1;\n        \u2026\u2026\n    }\n    \u2026\u2026\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>expires -1\uff1a\u8d1f\u503c\u7981\u7528\u7f13\u5b58\uff0c\u901a\u8fc7\u6dfb\u52a0HTTP\u5934 Cache-Control: no-cache \u548c Expires\uff0cExpires\u88ab\u8bbe\u5b9a\u4e3a\u5f53\u524d\u65f6\u95f4\u4e4b\u524d\uff0c\u8fd9\u6837\u524d\u7aefnginx\u5c31\u4e0d\u4f1a\u7f13\u5b58 mirrorz \u7684URL\u4e86\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7f16\u8f91 tunasync worker \u7684\u914d\u7f6e\u6587\u4ef6\u6dfb\u52a0\u4e00\u4e2a\u811a\u672c\uff0c\u4f7f\u5f97\u6bcf\u4e2a\u540c\u6b65\u4f5c\u4e1a\u7ed3\u675f\u540e\u5747\u6e05\u9664\u524d\u7aef\u4e0a\u8fd9\u4e2a\u955c\u50cf\u7684\u6240\u6709\u7f13\u5b58\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#tunasync worker\u7684\u914d\u7f6e\u6587\u4ef6\n&#91;global]\n\u2026\u2026\nexec_on_success = &#91; \"\/home\/mirror\/postexec.sh\" ]\nexec_on_failure = &#91; \"\/home\/mirror\/postexec.sh\" ]\n\u2026\u2026\n\n#\u4e0a\u8ff0\u7684postexec.sh\u811a\u672c\u5185\u5bb9\n#!\/bin\/bash\nMIRROR_DIR=\"\/mirror\/\"\nDIR=\"${TUNASYNC_WORKING_DIR\/\"$MIRROR_DIR\"\/}\"\n\/usr\/bin\/curl --silent --output \/dev\/null --request PURGE \"https:\/\/mirror.nju.edu.cn\/$DIR\/*\"\n<\/code><\/pre>\n\n\n\n<p>\u955c\u50cf\u7ad9\u67d0\u4e9b\u72b6\u6001\u6587\u4ef6\u4f1a\u9891\u7e41\u7684\u5468\u671f\u66f4\u65b0\uff0c\u6bcf\u6b21\u66f4\u65b0\u540e\u90fd\u7528 <code>curl --silent --output \/dev\/null --request PURGE \"https:\/\/mirror.nju.edu.cn\/status\/*\"<\/code> \u6e05\u9664\u4e00\u4e0b\u7f13\u5b58\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9664\u4e86\u67d0\u4e9b\u571f\u8c6a\u7ad9\u7528\u5168\u95ea\u4ee5\u5916\uff0c\u5927\u591a\u6570\u5f00\u6e90\u955c\u50cf\u7ad9\u90fd\u662f\u4ee5\u673a\u68b0\u76d8\u4e3a\u4e3b\uff0c\u5f53\u5e26\u5bbd\u5145\u88d5\u7684\u65f6\u5019IO\u663e\u7136\u4f1a\u6210\u4e3a\u74f6\u9888\uff0c\u90a3\u4e48\u91c7\u7528\u5c11\u91cf\u7684 [&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_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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[8],"tags":[],"class_list":["post-3152","post","type-post","status-publish","format-standard","hentry","category-network"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paOwEq-OQ","_links":{"self":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts\/3152","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=3152"}],"version-history":[{"count":10,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts\/3152\/revisions"}],"predecessor-version":[{"id":3432,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/posts\/3152\/revisions\/3432"}],"wp:attachment":[{"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/media?parent=3152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/categories?post=3152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yaoge123.com\/blog\/wp-json\/wp\/v2\/tags?post=3152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}