{"id":52376,"date":"2024-12-03T13:32:50","date_gmt":"2024-12-03T05:32:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52376\/"},"modified":"2024-12-03T13:32:50","modified_gmt":"2024-12-03T05:32:50","slug":"linux%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%bd%91%e9%a1%b5%e8%87%aa%e5%8a%a8%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52376\/","title":{"rendered":"linux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>linux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65<\/h1>\n<p>\u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300alinux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002<\/p>\n<p>\u4f7f\u7528\u591a\u4e2aweb\u670d\u52a1\u5668\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\uff0c\u4e3a\u4e86\u4fdd\u6301\u524d\u7aefweb\u670d\u52a1\u5668\u4e0a\u8d44\u6e90\u7684\u4e00\u81f4\u6027\u53ef\u4ee5\u901a\u8fc7rsync\u5728\u4e3b\u670d\u52a1\u5668\u4e0a(\u53ef\u5199\u5165\u6570\u636e)\u5c06\u66f4\u65b0\u8fc7\u7684\u6587\u4ef6\u540c\u6b65\u5230\u5176\u4ed6\u4ece\u670d\u52a1\u5668(\u53ea\u8bfb\u670d\u52a1\u5668)\uff0c\u4f46\u662f\u4e0d\u80fd\u81ea\u52a8\u7684\u8fdb\u884c\u5b9e\u65f6\u540c\u6b65\uff0c\u4f7f\u7528inotify\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65<\/p>\n<p>\u4e3b\u670d\u52a1\u5668\uff1a192.168.6.205 inotify<br \/>\u4ece\u670d\u52a1\u5668\uff1a192.168.6.36 rsync<\/p>\n<p><strong>1\u3001\u5728\u4ece\u670d\u52a1\u5668\u4e0a\u914d\u7f6ersync\uff0c\u5f00\u542frsync\u670d\u52a1\uff0c\u8ba9\u4e3b\u670d\u52a1\u53ef\u4ee5\u5c06\u8d44\u6e90\u540c\u6b65\u5230\u8be5\u670d\u52a1\u5668\u4e0a<\/strong><\/p>\n<p>vim \/etc\/rsyncd.conf<br \/>uid = nginx<br \/>gid = nginx<br \/>port = 873<br \/>host all = 192.168.6.205<br \/>use chroot = on<br \/>max connections = 4<br \/>timeout = yes<br \/>[wordpress]<br \/>path = \/usr\/local\/nginx\/html\/wordpress<br \/>comment = rsync files<br \/>ignore errors<br \/>read only = no<br \/>list = yes<br \/>auth users = rsync<br \/>secrets file = \/etc\/rsync.passwd<\/p>\n<p>\u521b\u5efa\/etc\/rsync.passwd\u5bc6\u7801\u914d\u7f6e\u6587\u4ef6<br \/>vim \/etc\/rsync.passwd<br \/>#\u7528\u6237:\u5bc6\u7801<br \/>rsync:rsync<\/p>\n<p><strong>2\u3001\u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5inotify-tools<\/strong><\/p>\n<p>tar -zxvf inotify-tools-3.14.tar.gz<br \/>cd inotify-tools-3.14<br \/>.\/configure \u2013prefix=\/usr\/local\/inotify<br \/>make &amp;&amp; make install<\/p>\n<p>\u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u914d\u7f6ersync\u5bc6\u7801\u6587\u4ef6\uff0c\u7528\u4e8e\u5c06\u6570\u636e\u540c\u6b65\u5230\u4ece\u670d\u52a1\u5668<br \/>vim \/etc\/rsync.passwd<br \/>#\u5bc6\u7801<br \/>rsync<\/p>\n<p>\u521b\u5efa\u811a\u672c<br \/>vim inotifyrsync.sh<\/p>\n<p>#!\/bin\/bash<br \/>host=192.168.6.36<br \/>src=\/usr\/local\/nginx\/html\/wordpress\/<br \/>dst=wordpress<br \/>user=rsync<br \/>inotifywait=\/usr\/local\/inotify\/bin\/inotifywait<br \/>rsync=\/usr\/bin\/rsync<br \/>$inotifywait -mrq \u2013timefmt &#8216;%d\/%m\/%y %h:%m&#8217; \u2013format &#8216;%t %w%f&#8217; -e modify,delete,create,attrib&nbsp; $src&nbsp; | while read files<br \/>do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $rsync -vzrtopg \u2013delete \u2013progress \u2013password-file=\/etc\/rsync.passwd $src $user@$host::$dst<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;${files} was rsynced&#8221; &gt;&gt;\/tmp\/rsync.log 2&gt;&amp;1<br \/>&nbsp;&nbsp; done<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300alinux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65 \u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300alinux\u5982\u4f55\u5b9e\u73b0\u7f51\u9875\u81ea\u52a8\u540c\u6b65\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002 \u4f7f\u7528\u591a\u4e2aweb\u670d\u52a1\u5668\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\uff0c\u4e3a\u4e86\u4fdd\u6301\u524d\u7aefweb\u670d\u52a1\u5668\u4e0a\u8d44\u6e90\u7684\u4e00\u81f4\u6027\u53ef\u4ee5\u901a\u8fc7rsync\u5728\u4e3b\u670d\u52a1\u5668\u4e0a(\u53ef\u5199\u5165\u6570\u636e)\u5c06\u66f4\u65b0\u8fc7\u7684\u6587\u4ef6\u540c\u6b65\u5230\u5176\u4ed6\u4ece\u670d\u52a1\u5668(\u53ea\u8bfb\u670d\u52a1\u5668)\uff0c\u4f46\u662f\u4e0d\u80fd\u81ea\u52a8\u7684\u8fdb\u884c\u5b9e\u65f6\u540c\u6b65\uff0c\u4f7f\u7528inotify\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65 \u4e3b\u670d\u52a1\u5668\uff1a192.168.6.205 inotify\u4ece\u670d\u52a1\u5668\uff1a192.168.6.36 rsync 1\u3001\u5728\u4ece\u670d\u52a1\u5668\u4e0a\u914d\u7f6ersync\uff0c\u5f00\u542frsync\u670d\u52a1\uff0c\u8ba9\u4e3b\u670d\u52a1\u53ef\u4ee5\u5c06\u8d44\u6e90\u540c\u6b65\u5230\u8be5\u670d\u52a1\u5668\u4e0a vim \/etc\/rsyncd.confuid = nginxgid = nginxport = 873host all = 192.168.6.205use chroot = onmax connections = 4timeout = yes[wordpress]path = \/usr\/local\/nginx\/html\/wordpresscomment = rsync filesignore errorsread only = nolist = yesauth users = rsyncsecrets file = \/etc\/rsync.passwd \u521b\u5efa\/etc\/rsync.passwd\u5bc6\u7801\u914d\u7f6e\u6587\u4ef6vim \/etc\/rsync.passwd#\u7528\u6237:\u5bc6\u7801rsync:rsync 2\u3001\u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5inotify-tools tar -zxvf inotify-tools-3.14.tar.gzcd inotify-tools-3.14.\/configure \u2013prefix=\/usr\/local\/inotifymake &amp;&amp; make install \u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u914d\u7f6ersync\u5bc6\u7801\u6587\u4ef6\uff0c\u7528\u4e8e\u5c06\u6570\u636e\u540c\u6b65\u5230\u4ece\u670d\u52a1\u5668vim [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-52376","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52376","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52376"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52376\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}