{"id":43690,"date":"2024-10-06T03:37:50","date_gmt":"2024-10-05T19:37:50","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43690\/"},"modified":"2024-10-06T03:37:50","modified_gmt":"2024-10-05T19:37:50","slug":"centos-7-0-%e4%b8%8b-rsync-sersync-%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e5%af%a6%e6%99%82%e5%a2%9e%e9%87%8f%e5%90%8c%e6%ad%a5%e5%82%99%e4%bb%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43690\/","title":{"rendered":"CentOS 7.0 \u4e0b Rsync + sersync \u5be6\u73fe\u6578\u64da\u5be6\u6642\u589e\u91cf\u540c\u6b65\u5099\u4efd"},"content":{"rendered":"<h1 id=\"centos-7-0-%e4%b8%8b-rsync-sersync-%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e5%af%a6%e6%99%82%e5%a2%9e%e9%87%8f%e5%90%8c%e6%ad%a5%e5%82%99%e4%bb%bd-LDSidXTXFJ\">CentOS 7.0 \u4e0b Rsync + sersync \u5be6\u73fe\u6578\u64da\u5be6\u6642\u589e\u91cf\u540c\u6b65\u5099\u4efd<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u7684\u5b89\u5168\u6027\u548c\u53ef\u7528\u6027\u81f3\u95dc\u91cd\u8981\u3002\u5c0d\u65bc\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u4f86\u8aaa\uff0c\u5be6\u6642\u589e\u91cf\u5099\u4efd\u662f\u4e00\u7a2e\u6709\u6548\u7684\u6578\u64da\u4fdd\u8b77\u7b56\u7565\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7.0 \u74b0\u5883\u4e0b\uff0c\u5229\u7528 Rsync \u548c sersync \u5be6\u73fe\u6578\u64da\u7684\u5be6\u6642\u589e\u91cf\u540c\u6b65\u5099\u4efd\u3002<\/p>\n<h2 id=\"rsync-%e7%b0%a1%e4%bb%8b-LDSidXTXFJ\">Rsync \u7c21\u4ecb<\/h2>\n<p>Rsync \u662f\u4e00\u500b\u5f37\u5927\u7684\u6587\u4ef6\u50b3\u8f38\u5de5\u5177\uff0c\u5ee3\u6cdb\u7528\u65bc Unix \u548c Linux \u7cfb\u7d71\u3002\u5b83\u7684\u4e3b\u8981\u7279\u9ede\u662f\u80fd\u5920\u9ad8\u6548\u5730\u540c\u6b65\u6587\u4ef6\u548c\u76ee\u9304\uff0c\u4e26\u4e14\u652f\u6301\u589e\u91cf\u5099\u4efd\u3002Rsync \u53ea\u6703\u50b3\u8f38\u8b8a\u66f4\u7684\u90e8\u5206\uff0c\u9019\u6a23\u53ef\u4ee5\u7bc0\u7701\u5e36\u5bec\u548c\u6642\u9593\u3002<\/p>\n<h3 id=\"rsync-%e7%9a%84%e5%9f%ba%e6%9c%ac%e7%94%a8%e6%b3%95-LDSidXTXFJ\">Rsync \u7684\u57fa\u672c\u7528\u6cd5<\/h3>\n<p>Rsync \u7684\u57fa\u672c\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>rsync [\u9078\u9805] \u6e90 \u76ee\u6a19<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5c07\u672c\u5730\u76ee\u9304\u540c\u6b65\u5230\u9060\u7a0b\u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>rsync -avz \/local\/dir user@remote:\/remote\/dir<\/code><\/pre>\n<ul>\n<li><strong>-a<\/strong>\uff1a\u6b78\u6a94\u6a21\u5f0f\uff0c\u4fdd\u7559\u6587\u4ef6\u5c6c\u6027\u3002<\/li>\n<li><strong>-v<\/strong>\uff1a\u986f\u793a\u8a73\u7d30\u904e\u7a0b\u3002<\/li>\n<li><strong>-z<\/strong>\uff1a\u58d3\u7e2e\u6578\u64da\u4ee5\u7bc0\u7701\u5e36\u5bec\u3002<\/li>\n<\/ul>\n<h2 id=\"sersync-%e7%b0%a1%e4%bb%8b-LDSidXTXFJ\">sersync \u7c21\u4ecb<\/h2>\n<p>sersync \u662f\u4e00\u500b\u57fa\u65bc Rsync \u7684\u5be6\u6642\u6578\u64da\u540c\u6b65\u5de5\u5177\uff0c\u5c08\u70ba\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u5be6\u6642\u5099\u4efd\u7684\u5834\u666f\u8a2d\u8a08\u3002\u5b83\u80fd\u5920\u76e3\u63a7\u6587\u4ef6\u7cfb\u7d71\u7684\u8b8a\u5316\uff0c\u4e26\u81ea\u52d5\u89f8\u767c Rsync \u9032\u884c\u589e\u91cf\u5099\u4efd\u3002<\/p>\n<h3 id=\"sersync-%e7%9a%84%e5%ae%89%e8%a3%9d-LDSidXTXFJ\">sersync \u7684\u5b89\u88dd<\/h3>\n<p>\u5728 CentOS 7.0 \u4e0a\u5b89\u88dd sersync\uff0c\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\uff1a<\/p>\n<pre><code>yum install sersync<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 sersync \u670d\u52d9\uff1a<\/p>\n<pre><code>systemctl start sersync<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-rsync-%e5%92%8c-sersync-LDSidXTXFJ\">\u914d\u7f6e Rsync \u548c sersync<\/h2>\n<p>\u8981\u5be6\u73fe\u6578\u64da\u7684\u5be6\u6642\u589e\u91cf\u540c\u6b65\u5099\u4efd\uff0c\u9996\u5148\u9700\u8981\u914d\u7f6e Rsync \u548c sersync\u3002\u4ee5\u4e0b\u662f\u57fa\u672c\u7684\u914d\u7f6e\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e9%85%8d%e7%bd%ae-rsync-LDSidXTXFJ\">1. \u914d\u7f6e Rsync<\/h3>\n<p>\u5728\u4f3a\u670d\u5668\u4e0a\u5275\u5efa\u4e00\u500b Rsync \u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 \/etc\/rsyncd.conf\uff1a<\/p>\n<pre><code>\nuid = nobody\ngid = nobody\nuse chroot = no\nmax connections = 5\ntimeout = 300\n\n[backup]\n    path = \/path\/to\/backup\n    comment = Backup Directory\n    read only = no\n    list = yes\n<\/code><\/pre>\n<h3 id=\"2-%e9%85%8d%e7%bd%ae-sersync-LDSidXTXFJ\">2. \u914d\u7f6e sersync<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5275\u5efa sersync \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982 \/etc\/sersync\/sersync.conf\uff1a<\/p>\n<pre><code>\n{\n    \"version\": \"1.0\",\n    \"sync\": [\n        {\n            \"source\": \"\/path\/to\/source\",\n            \"target\": \"user@remote:\/path\/to\/target\",\n            \"rsync\": {\n                \"options\": \"-avz\"\n            }\n        }\n    ]\n}\n<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e5%8b%95-sersync-LDSidXTXFJ\">3. \u555f\u52d5 sersync<\/h3>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 sersync \u670d\u52d9\uff1a<\/p>\n<pre><code>systemctl start sersync<\/code><\/pre>\n<h2 id=\"%e7%9b%a3%e6%8e%a7%e5%92%8c%e7%b6%ad%e8%ad%b7-LDSidXTXFJ\">\u76e3\u63a7\u548c\u7dad\u8b77<\/h2>\n<p>\u5728\u5be6\u65bd\u5be6\u6642\u589e\u91cf\u5099\u4efd\u5f8c\uff0c\u5b9a\u671f\u6aa2\u67e5\u540c\u6b65\u72c0\u614b\u548c\u65e5\u8a8c\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b sersync \u7684\u65e5\u8a8c\uff1a<\/p>\n<pre><code>tail -f \/var\/log\/sersync.log<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u6839\u64da\u9700\u8981\u8abf\u6574 Rsync \u548c sersync \u7684\u914d\u7f6e\uff0c\u4ee5\u78ba\u4fdd\u6700\u4f73\u6027\u80fd\u548c\u6578\u64da\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-LDSidXTXFJ\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4f7f\u7528 Rsync \u548c sersync\uff0c\u60a8\u53ef\u4ee5\u5728 CentOS 7.0 \u74b0\u5883\u4e0b\u5be6\u73fe\u9ad8\u6548\u7684\u6578\u64da\u5be6\u6642\u589e\u91cf\u540c\u6b65\u5099\u4efd\u3002\u9019\u4e0d\u50c5\u80fd\u5920\u4fdd\u8b77\u60a8\u7684\u6578\u64da\uff0c\u9084\u80fd\u63d0\u9ad8\u6578\u64da\u7684\u53ef\u7528\u6027\u548c\u53ef\u9760\u6027\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u5b89\u5168\u7684\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u7684\u7528\u6236\u4f86\u8aaa\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5e6b\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3\u548c\u5be6\u65bd\u6578\u64da\u5099\u4efd\u7b56\u7565\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to achieve real-time incremental data backup on CentOS 7.0 using Rsync and sersync for efficient data synchronization.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43690","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43690"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43690\/revisions"}],"predecessor-version":[{"id":43691,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43690\/revisions\/43691"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}