{"id":3580,"date":"2018-07-17T13:05:54","date_gmt":"2018-07-17T05:05:54","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3580"},"modified":"2018-07-17T13:05:54","modified_gmt":"2018-07-17T05:05:54","slug":"centos6-9%e4%bd%bf%e7%94%a8rsyncsersync%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/hemanual\/centos6-9%e4%bd%bf%e7%94%a8rsyncsersync%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5\/","title":{"rendered":"CentOS6.9\u4f7f\u7528Rsync+sersync\u5b9e\u73b0\u6570\u636e\u5b9e\u65f6\u540c\u6b65"},"content":{"rendered":"<p> Sersync\u7b80\u4ecb<\/p>\n<p>        Sersync\u5229\u7528inotify\u4e0ersync\u5bf9\u670d\u52a1\u5668\u8fdb\u884c\u5b9e\u65f6\u540c\u6b65\uff0c\u5176\u4e2dinotify\u7528\u4e8e\u76d1\u63a7\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\uff0crsync\u662f\u76ee\u524d\u5e7f\u6cdb\u4f7f\u7528\u7684\u540c\u6b65\u7b97\u6cd5\uff0c\u5176\u4f18\u70b9\u662f\u53ea\u5bf9\u6587\u4ef6\u4e0d\u540c\u7684\u90e8\u5206\u8fdb\u884c\u64cd\u4f5c\uff0c\u6240\u4ee5\u5176\u4f18\u52bf\u5927\u5927\u8d85\u8fc7\u4f7f\u7528\u6302\u63a5\u6587\u4ef6\u7cfb\u7edf\u7684\u65b9\u5f0f\u8fdb\u884c\u955c\u50cf\u540c\u6b65\u3002\u7531\u91d1\u5c71\u7684\u5468\u6d0b\u5f00\u53d1\u5b8c\u6210\uff0c\u662f\u76ee\u524d\u4f7f\u7528\u8f83\u591a\u7684\u6587\u4ef6\u540c\u6b65\u5de5\u5177\u4e4b\u4e00\u3002\u8be5\u5de5\u5177\u548c\u5176\u4ed6\u7684\u5de5\u5177\u76f8\u6bd4\u6709\u5982\u4e0b\u4f18\u70b9\uff1a<\/p>\n<p>    sersync\u662f\u4f7f\u7528c++\u7f16\u5199\uff0c\u7531\u4e8e\u53ea\u540c\u6b65\u53d1\u751f\u66f4\u6539\u7684\u6587\u4ef6\uff0c\u56e0\u6b64\u6bd4\u5176\u4ed6\u540c\u6b65\u5de5\u5177\u66f4\u8282\u7ea6\u65f6\u95f4\u3001\u5e26\u5bbd\uff1b<\/p>\n<p>    \u5b89\u88c5\u65b9\u4fbf\u3001\u914d\u7f6e\u7b80\u5355\uff1b<\/p>\n<p>    \u4f7f\u7528\u591a\u7ebf\u7a0b\u8fdb\u884c\u540c\u6b65\uff0c\u80fd\u591f\u4fdd\u8bc1\u591a\u4e2a\u670d\u52a1\u5668\u5b9e\u65f6\u4fdd\u6301\u540c\u6b65\u72b6\u6001\uff1b<\/p>\n<p>    \u81ea\u5e26\u51fa\u9519\u5904\u7406\u673a\u5236\uff0c\u901a\u8fc7\u5931\u8d25\u961f\u5217\u5bf9\u51fa\u9519\u7684\u6587\u4ef6\u91cd\u65b0\u51fa\u9519\uff0c\u5982\u679c\u4ecd\u65e7\u5931\u8d25\uff0c\u5219\u6bcf10\u4e2a\u5c0f\u65f6\u5bf9\u540c\u6b65\u5931\u8d25\u7684\u6587\u4ef6\u91cd\u65b0\u540c\u6b65\uff1b<\/p>\n<p>    \u81ea\u5e26crontab\u529f\u80fd\uff0c\u53ea\u9700\u5728xml\u914d\u7f6e\u6587\u4ef6\u4e2d\u5f00\u542f\uff0c\u5373\u53ef\u6309\u60a8\u7684\u8981\u6c42\uff0c\u9694\u4e00\u6bb5\u65f6\u95f4\u6574\u4f53\u540c\u6b65\u4e00\u6b21\uff1b<\/p>\n<p>    \u81ea\u5e26socket\u4e0ehttp\u534f\u8bae\u6269\u5c55\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u7684\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\uff1b<\/p>\n<p>rsync+sersync\u4e0ersync+Inotify-tools\u533a\u522b<\/p>\n<p>Inotify-tools\u53ea\u80fd\u8bb0\u5f55\u4e0b\u88ab\u76d1\u542c\u7684\u76ee\u5f55\u53d1\u751f\u4e86\u53d8\u5316\uff08\u5305\u62ec\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\uff09\uff0c\u5e76\u6ca1\u6709\u628a\u5177\u4f53\u662f\u54ea\u4e2a\u6587\u4ef6\u6216\u8005\u54ea\u4e2a\u76ee\u5f55\u53d1\u751f\u4e86\u53d8\u5316\u8bb0\u5f55\u4e0b\u6765\uff1b<\/p>\n<p>rsync\u5728\u540c\u6b65\u7684\u65f6\u5019\uff0c\u5e76\u4e0d\u77e5\u9053\u5177\u4f53\u662f\u54ea\u4e2a\u6587\u4ef6\u6216\u8005\u54ea\u4e2a\u76ee\u5f55\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u6bcf\u6b21\u90fd\u662f\u5bf9\u6574\u4e2a\u76ee\u5f55\u8fdb\u884c\u540c\u6b65\uff0c\u5f53\u6570\u636e\u91cf\u5f88\u5927\u65f6\uff0c\u6574\u4e2a\u76ee\u5f55\u540c\u6b65\u975e\u5e38\u8017\u65f6\uff08rsync\u8981\u5bf9\u6574\u4e2a\u76ee\u5f55\u904d\u5386\u67e5\u627e\u5bf9\u6bd4\u6587\u4ef6\uff09\uff0c\u56e0\u6b64\uff0c\u6548\u7387\u5f88\u4f4e\u3002<\/p>\n<p>sersync\u662f\u57fa\u4e8eInotify\u5f00\u53d1\u7684\uff0c\u7c7b\u4f3c\u4e8eInotify-tools\u7684\u5de5\u5177\uff1b<\/p>\n<p>sersync\u53ef\u4ee5\u8bb0\u5f55\u4e0b\u88ab\u76d1\u542c\u76ee\u5f55\u4e2d\u53d1\u751f\u53d8\u5316\u7684\uff08\u5305\u62ec\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\uff09\u5177\u4f53\u67d0\u4e00\u4e2a\u6587\u4ef6\u6216\u67d0\u4e00\u4e2a\u76ee\u5f55\u7684\u540d\u5b57\uff1b<\/p>\n<p>rsync\u5728\u540c\u6b65\u7684\u65f6\u5019\uff0c\u53ea\u540c\u6b65\u53d1\u751f\u53d8\u5316\u7684\u8fd9\u4e2a\u6587\u4ef6\u6216\u8005\u8fd9\u4e2a\u76ee\u5f55\uff08\u6bcf\u6b21\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\u76f8\u5bf9\u6574\u4e2a\u540c\u6b65\u76ee\u5f55\u6570\u636e\u6765\u8bf4\u662f\u5f88\u5c0f\u7684\uff0crsync\u5728\u904d\u5386\u67e5\u627e\u6bd4\u5bf9\u6587\u4ef6\u65f6\uff0c\u901f\u5ea6\u5f88\u5feb\uff09\uff0c\u56e0\u6b64\uff0c\u6548\u7387\u5f88\u9ad8\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u5f53\u540c\u6b65\u7684\u76ee\u5f55\u6570\u636e\u91cf\u4e0d\u5927\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528Rsync+Inotify-tools\uff1b\u5f53\u6570\u636e\u91cf\u5f88\u5927\uff08\u51e0\u767eG\u751a\u81f31T\u4ee5\u4e0a\uff09\u3001\u6587\u4ef6\u5f88\u591a\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528Rsync+sersync\u3002<\/p>\n<p>\u5730\u5740\uff1ahttps:\/\/code.google.com\/p\/sersync\/\uff0c\u8981\u7ffb\u5899\u624d\u80fd\u4e0b\u8f7d<\/p>\n<p>            https:\/\/download.csdn.net\/detail\/hellopengyl\/9918625  <\/p>\n<p>\u5b89\u88c5\u3001\u914d\u7f6e<\/p>\n<p>\u548cInotify-tools\u4e00\u6837\uff0c\u53ea\u9700\u8981\u5728\u6570\u636e\u6e90\u7aef\u5b89\u88c5<\/p>\n<p>1\u3001\u67e5\u770b\u670d\u52a1\u5668\u5185\u6838\u662f\u5426\u652f\u6301inotify<br \/>\n[root@localhost src]# ll \/proc\/sys\/fs\/inotify    #\u67e5\u770b\u670d\u52a1\u5668\u5185\u6838\u662f\u5426\u652f\u6301inotify\uff0c\u51fa\u73b0\u4e0b\u9762\u7684\u5185\u5bb9\uff0c\u8bf4\u660e\u670d\u52a1\u5668\u5185\u6838\u652f\u6301inotify<br \/>\ntotal 0<br \/>\n-rw-r&#8211;r&#8211; 1 root root 0 Jul 27 10:32 max_queued_events<br \/>\n-rw-r&#8211;r&#8211; 1 root root 0 Jul 27 10:32 max_user_instances<br \/>\n-rw-r&#8211;r&#8211; 1 root root 0 Jul 27 10:32 max_user_watches<br \/>\n[root@localhost src]# uname -r        #Linux\u4e0b\u652f\u6301inotify\u7684\u5185\u6838\u6700\u5c0f\u4e3a2.6.13<br \/>\n2.6.32-642.el6.x86_64<br \/>\n[root@localhost src]# sysctl -a|egrep -i &#8220;max_queued_events|max_user_watches|max_user_instances&#8221;    #\u4fee\u6539inotify\u9ed8\u8ba4\u53c2\u6570\uff08inotify\u9ed8\u8ba4\u5185\u6838\u53c2\u6570\u503c\u592a\u5c0f\uff09<br \/>\nfs.inotify.max_user_instances = 128<br \/>\nfs.inotify.max_user_watches = 8192<br \/>\nfs.inotify.max_queued_events = 16384<br \/>\nfs.epoll.max_user_watches = 201420<br \/>\n[root@localhost src]# vim \/etc\/sysctl.conf<br \/>\nfs.inotify.max_user_instances = 65535<br \/>\nfs.inotify.max_user_watches = 99999999<br \/>\nfs.inotify.max_queued_events = 99999999<br \/>\n[root@localhost src]# cat \/proc\/sys\/fs\/inotify\/{max_user_instances,max_user_watches,max_queued_events}<br \/>\n65535<br \/>\n99999999<br \/>\n99999999<br \/>\n[root@localhost src]#<\/p>\n<p>max_queued_events inotify\u961f\u5217\u6700\u5927\u957f\u5ea6\uff0c\u5982\u679c\u503c\u592a\u5c0f\uff0c\u4f1a\u51fa\u73b0&#8221;** Event Queue Overflow **&#8221;\u9519\u8bef\uff0c\u5bfc\u81f4\u76d1\u63a7\u6587\u4ef6\u4e0d\u51c6\u786e<\/p>\n<p>max_user_watches \u8981\u540c\u6b65\u7684\u6587\u4ef6\u5305\u542b\u591a\u5c11\u76ee\u5f55\uff0c\u53ef\u4ee5\u7528\uff1afind \/home\/www.osyunwei.com -type d | wc -l\u7edf\u8ba1\uff0c\u5fc5\u987b\u4fdd\u8bc1max_user_watches\u503c\u5927\u4e8e\u7edf\u8ba1\u7ed3\u679c\uff08\u8fd9\u91cc\/home\/www.osyunwei.com\u4e3a\u540c\u6b65\u6587\u4ef6\u76ee\u5f55\uff09<\/p>\n<p>max_user_instances \u6bcf\u4e2a\u7528\u6237\u521b\u5efainotify\u5b9e\u4f8b\u6700\u5927\u503c<\/p>\n<p>2\u3001\u5b89\u88c5\u3001\u914d\u7f6esersync<br \/>\n[root@localhost src]# tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz<br \/>\n[root@localhost src]# mv GNU-Linux-x86 \/app\/sersync<br \/>\n[root@localhost src]# cd \/app\/sersync\/<br \/>\n[root@localhost sersync]# ls<br \/>\nconfxml.xml  sersync2<br \/>\n[root@localhost sersync]# cp confxml.xml{,.default}<br \/>\n[root@localhost sersync]# vim confxml.xml<\/p>\n<p>        #\u9488\u5bf9\u63d2\u4ef6\u7684\u4fdd\u7559\u5b57\u6bb5\uff0c\u4fdd\u7559\u9ed8\u8ba4\u5373\u53ef\u3002<br \/>\n        #\u5728sersync\u6b63\u5728\u8fd0\u884c\u7684\u63a7\u5236\u53f0\uff0c\u6253\u5370inotify\uff0crsync\u540c\u6b65\u547d\u4ee4<br \/>\n        #\u5bf9\u4e8exfs\u6587\u4ef6\u7cfb\u7edf\u7528\u6237\uff0c\u9700\u8981\u5c06\u8fd9\u4e2a\u9009\u9879\u5f00\u542f\u624d\u6b63\u5e38\u5de5\u4f5c<br \/>\n        #\u8fc7\u6ee4\u7cfb\u7edf\u7684\u4e34\u65f6\u6587\u4ef6\uff0c\u88ab\u8fc7\u6ee4\u7684\u6587\u4ef6\u4e0d\u4f1a\u88ab\u76d1\u63a7\u63d0\u9ad8,\u9ed8\u8ba4\u8fc7\u6ee4\u7cfb\u7edf\u7684\u4e34\u65f6\u6587\u4ef6(\u4ee5\u201c.\u201d\u5f00\u5934\uff0c\u4ee5\u201c\uff5e\u201d\u7ed3\u5c3e)<\/p>\n<p>        #inotify\u76d1\u63a7\u6587\u4ef6\u6a21\u5757<br \/>\n        #\u5982\u679c\u672c\u5730\u6587\u4ef6\u5220\u9664\uff0c\u4e0d\u9700\u8981\u5220\u9664\u8fdc\u7a0b\u6bb5\u7684\u6587\u4ef6\u53ef\u4ee5\u8bbe\u7f6e\u6210false<br \/>\n     #\u5982\u679c\u5c06createFolder\u8bbe\u4e3afalse\uff0c\u5219\u4e0d\u4f1a\u5bf9\u4ea7\u751f\u7684\u76ee\u5f55\u8fdb\u884c\u76d1\u63a7\uff0c\u8be5\u76ee\u5f55\u4e0b\u7684\u5b50\u6587\u4ef6\u4e0e\u5b50\u76ee\u5f55\u4e5f\u4e0d\u4f1a\u88ab\u76d1\u63a7\uff1b<br \/>\n      #\u628acreateFile\uff08\u76d1\u63a7\u6587\u4ef6\u4e8b\u4ef6\u9009\u9879\uff09\u8bbe\u7f6e\u4e3afalse\u6765\u63d0\u9ad8\u6027\u80fd\uff0c\u51cf\u5c11rsync\u901a\u8baf\uff1b\u56e0\u4e3a\u62f7\u8d1d\u6587\u4ef6\u5230\u76d1\u63a7\u76ee\u5f55\u4f1a\u4ea7\u751fcreate\u4e8b\u4ef6\u4e0eclose_write\u4e8b\u4ef6\uff0c\u6240\u4ee5\u5982\u679c\u5173\u95edcreate\u4e8b\u4ef6\uff0c\u53ea\u76d1\u63a7\u6587\u4ef6\u62f7\u8d1d\u7ed3\u675f\u65f6\u7684\u65f6\u95f4close_write\uff0c\u540c\u6837\u53ef\u4ee5\u5b9e\u73b0\u6587\u4ef6\u5b8c\u6574\u540c\u6b65\uff1b<\/p>\n<p>        #\u8fdb\u884c\u6570\u636e\u540c\u6b65\u7684\u6a21\u5757<br \/>\n        #\u5b9a\u4e49\u672c\u5730\u8981\u540c\u6b65\u7684\u76ee\u5f55<br \/>\n        #\u8fdc\u7a0b\u63a5\u53d7\u540c\u6b65\u7684IP\u548crsync\u6a21\u5757\u540d<br \/>\n        &lt;!&#8212;-&gt;<br \/>\n        &lt;!&#8212;-&gt;<\/p>\n<p>            #\u81ea\u5b9a\u4e49rsync\u53c2\u6570\uff0c\u9ed8\u8ba4\u662f-artuz<br \/>\n            #\u5f00\u542f\u7528\u6237\u8ba4\u8bc1\uff0c\u5b9a\u4e49\u7528\u6237\u540d\u5bc6\u7801<br \/>\n        <!-- port=874 --><br \/>\n        <!-- timeout=100 --><br \/>\n            #\u5f00\u542f\u4f1a\u4f7f\u7528rsync \uff0de ssh\u7684\u65b9\u5f0f\u8fdb\u884c\u4f20\u8f93<\/p>\n<p>    <!--default every 60mins execute once-->  #\u5bf9\u4e8e\u5931\u8d25\u7684\u4f20\u8f93\uff0c\u4f1a\u8fdb\u884c\u91cd\u65b0\u4f20\u9001\uff0c\u518d\u6b21\u540c\u6b65\u5931\u8d25\u540e\u65e5\u5fd7\u8bb0\u5f55\u5230\/tmp\/rsync_fail_log.sh\uff0c\u5e76\u4e14\u6bcf60\u5206\u949f\u5bf9\u5931\u8d25\u7684log\u8fdb\u884c\u91cd\u65b0\u540c\u6b65<br \/>\n    <!--600mins-->    #\u6bcf\u9694600s\u4f1a\u505a\u4e00\u6b21\u5b8c\u5168\u540c\u6b65<br \/>\n            \uff03\u5982\u679c\u5f00\u542f\u4e86filter\u6587\u4ef6\u8fc7\u6ee4\u529f\u80fd\uff0c\u90a3\u4e48crontab\u6574\u4f53\u540c\u6b65\u4e5f\u9700\u8981\u8bbe\u7f6e\u8fc7\u6ee4\uff0c\u5426\u5219\u867d\u7136\u5b9e\u65f6\u540c\u6b65\u7684\u65f6\u5019\u6587\u4ef6\u88ab\u8fc7\u6ee4\u4e86\uff0c\u4f46crontab\u6574\u4f53\u540c\u6b65\u7684\u65f6\u5019 \u5982\u679c\u4e0d\u5355\u72ec\u8bbe\u7f6ecrontabfilter\uff0c\u8fd8\u4f1a\u5c06\u9700\u8fc7\u6ee4\u7684\u6587\u4ef6\u540c\u6b65\u5230\u8fdc\u7a0b\uff0c<br \/>\n        \u3000\uff03crontab\u7684\u8fc7\u6ee4\u6b63\u5219\u4e0efilter\u8fc7\u6ee4\u7684\u4e0d\u540c\uff0c\u679c\u540c\u65f6\u5f00\u542f\u4e86filter\u4e0ecrontab\uff0c\u5219\u8981\u5f00\u542fcrontab\u7684crontabfilter\uff0c\u5e76\u6309\u793a\u4f8b\u8bbe\u7f6e\u4f7f\u5176\u4e0efilter\u7684\u8fc7\u6ee4\u4e00\u4e00\u5bf9\u5e94\u3002<\/p>\n<p>            \uff03\u5f53\u8bbe\u7f6e\u4e3atrue\u7684\u65f6\u5019\uff0c\u5c06\u6587\u4ef6\u540c\u6b65\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u540e\u4f1a\u8c03\u7528name\u53c2\u6570\u6307\u5b9a\u7684\u63d2\u4ef6\u3002<\/p>\n<p>        #name\u6307\u5b9a\u7684\u63d2\u4ef6<br \/>\n    #\u5f53\u6587\u4ef6\u540c\u6b65\u5b8c\u6210\u540e\uff0c\u4f1a\u8c03\u7528command\u63d2\u4ef6\uff0c\u4f8b\u5982\u540c\u6b65\u6587\u4ef6\u662ffile.txt\uff0cfile.txt\u6587\u4ef6\u5728\u6539\u52a8\u4e4b\u540e\uff0c\u8c03\u7528rsync\u540c\u6b65\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u540e\uff0c\u8c03\u7528command\u63d2\u4ef6\uff0c\u6267\u884c\/bin\/sh file.txt suffix &gt;\/dev\/null 2&gt;&amp;1<br \/>\n    #\u5982\u679csuffix \u8bbe\u7f6e\u4e86\uff0c\u5219\u4f1a\u653e\u5728inotify\u4e8b\u4ef6file.txt\u4e4b\u540e,\u5982\u679cignoreError\u4e3atrue\uff0c\u5219\u4f1a\u6dfb\u52a0&gt;\/dev\/null 2&gt;&amp;1<br \/>\n     <!--prefix \/opt\/tongbu\/mmm.sh suffix--><\/p>\n<p>            #\u5f53filter\u4e3ature\uff0cinclude\u53ef\u4ee5\u53ea\u5bf9\u6b63\u5219\u5339\u914d\u5230\u7684\u6587\u4ef6\uff0c\u8c03\u7528command\u3002<\/p>\n<p>        #http\u63d2\u4ef6\uff0c\u53ef\u4ee5\u5411\u6307\u5b9a\u57df\u540d\u7684\u4e3b\u673apost,inotify\u76d1\u63a7\u7684\u4e8b\u4ef6\u3002<br \/>\n        #socket\u63d2\u4ef6\uff0c\u5f00\u542f\u8be5\u6a21\u5757\uff0c\u5219\u5411\u6307\u5b9aip\u4e0e\u7aef\u53e3\u53d1\u9001inotify\u6240\u4ea7\u751f\u7684\u6587\u4ef6\u8def\u5f84\u4fe1\u606f<\/p>\n<p>    #\u5728\u540c\u6b65\u8fc7\u7a0b\u4e2d\u5c06\u6587\u4ef6\u53d1\u9001\u5230\u76ee\u7684\u670d\u52a1\u5668\u540e\u5237\u65b0cdn\u63a5\u53e3\u3002\u5982\u679c\u4e0d\u60f3\u4f7f\u7528\uff0c\u5219\u8bbe\u7f6e<br \/>\n    #\u8be5\u6a21\u5757\u6839\u636echinaCDN\u7684\u534f\u8bae\uff0c\u8fdb\u884c\u8bbe\u8ba1\uff0c\u5f53\u6709\u6587\u4ef6\u4ea7\u751f\u7684\u65f6\u5019\uff0c\u5c31\u5411cdn\u63a5\u53e3\u53d1\u9001\u9700\u8981\u5237\u65b0\u7684\u8def\u5f84\u4f4d\u7f6e<\/p>\n<p>      #\u9700\u8981\u76d1\u63a7\u7684\u76ee\u5f55<br \/>\n            #cdnifo\u6807\u7b7e\u5236\u5b9a\u4e86cdn\u63a5\u53e3\u7684\u57df\u540d\uff0c\u7aef\u53e3\u53f7\uff0c\u4ee5\u53ca\u7528\u6237\u540d\u4e0e\u5bc6\u7801\u3002<\/p>\n<p>        #sendurl\u6807\u7b7e\u662f\u9700\u8981\u5237\u65b0\u7684url\u7684\u524d\u7f00<br \/>\n        &lt;sendurl base=&quot;<br \/>\n        #regexurl\u6807\u7b7e\u4e2d\u7684\uff0cregex\u5c5e\u6027\u4e3atrue\u65f6\u5019\uff0c\u4f7f\u7528match\u5c5e\u6027\u7684\u6b63\u5219\u8bed\u53e5\u5339\u914dinotify\u8fd4\u56de\u7684\u8def\u5f84\u4fe1\u606f\uff0c\u5e76\u5c06\u6b63\u5219\u5339\u914d\u5230\u7684\u90e8\u5206\u4f5c\u4e3aurl\u4e00\u90e8\u5206\uff0c<\/p>\n<p>            #\u5982\u679c\u4ea7\u751f\u6587\u4ef6\u4e8b\u4ef6\u4e3a\uff1a\/data0\/htdoc\/cms.xoyo.com\/site\/jx3.xoyo.com\/image\/a\/123.txt<br \/>\n            #\u7ecf\u8fc7\u4e0a\u9762\u7684match\u6b63\u5219\u5339\u914d\u540e\uff0c\u6700\u540e\u5237\u65b0\u7684\u8def\u5f84\u662f:https:\/\/pic.xoyo.com\/cms\/jx3\/a\/123.txt;<br \/>\n            #\u5982\u679cregex\u5c5e\u6027\u4e3afalse\uff0c\u6700\u540e\u5237\u65b0\u7684\u8def\u5f84\u662fhttps:\/\/pic.xoyo.com\/cms\/jx3.xoyo.com\/images\/a\/123.txt;<\/p>\n<p>[root@localhost sersync]# \/app\/sersync\/sersync2 -d -r -n 8 -o \/app\/sersync\/confxml.xml<br \/>\nset the system param<br \/>\nexecute\uff1aecho 50000000 &gt; \/proc\/sys\/fs\/inotify\/max_user_watches<br \/>\nexecute\uff1aecho 327679 &gt; \/proc\/sys\/fs\/inotify\/max_queued_events<br \/>\nparse the command param<br \/>\noption: -d    run as a daemon<br \/>\noption: -r    rsync all the local files to the remote servers before the sersync work<br \/>\noption: -n    thread num is\uff1a  8<br \/>\noption: -o    config xml name\uff1a  \/app\/sersync\/confxml.xml<br \/>\nparse xml config file<br \/>\nhost ip : localhost  host port: 8008<br \/>\nOpen debug, you will see debug infomation<br \/>\ndaemon start\uff0csersync run behind the console<br \/>\nStart the crontab    Every 600 minutes rsync all the files to the remote servers entirely<br \/>\nuse rsync password-file :<br \/>\nuser is    rsync<br \/>\npasswordfile is   \/etc\/rsyncd.secret<br \/>\nconfig xml parse success<br \/>\nplease set \/etc\/rsyncd.conf max connections=0 Manually<br \/>\nsersync working thread 10  = 1(primary thread) + 1(fail retry thread) + 8(daemon sub threads)<br \/>\nMax threads numbers is: 18 = 10(Thread pool nums) + 8(Sub threads)<br \/>\nplease according your cpu \uff0cuse -n param to adjust the cpu rate<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nrsync the directory recursivly to the remote servers once<br \/>\nworking please wait&#8230;<br \/>\nexecute command: cd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8211;delete .\/ rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncrontab command:cd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8211;delete .\/ rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\nrun the sersync:<br \/>\nwatch path is: \/app\/rsync_client<br \/>\nadd watch: \/app\/rsync_client return wd is: 1<br \/>\nadd watch: \/app\/rsync_client\/test return wd is: 2<br \/>\n[root@localhost sersync]#<\/p>\n<p>-d     \u540e\u53f0\u542f\u52a8 <\/p>\n<p>-r    \u540c\u6b65\u524d\u5c06\u5df2\u5b58\u5728\u7684\u6587\u4ef6\u5168\u90e8\u540c\u6b65\u8fc7\u53bb,\u5982\u679c\u8bbe\u7f6e\u4e86\u8fc7\u6ee4\u5668\uff0c\u5373\u5728xml\u6587\u4ef6\u4e2d\uff0cfilter\u4e3atrue\uff0c\u5219\u6682\u65f6\u4e0d\u80fd\u4f7f\u7528-r\u53c2\u6570\u8fdb\u884c\u6574\u4f53\u540c\u6b65\uff1b<\/p>\n<p>-n    \u5f00\u542f\u7684\u7ebf\u7a0b\u603b\u6570\u9ed8\u8ba410 <\/p>\n<p>-o    \u6307\u5b9a\u914d\u7f6e\u6587\u4ef6,\u6307\u5b9a -o \u53c2\u6570\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4ece\u800c\u5b9e\u73b0sersync\u591a\u8fdb\u7a0b\u591a\u5b9e\u4f8b\u7684\u6570\u636e\u540c\u6b65<\/p>\n<p>-m    \u4e0d\u8fdb\u884c\u540c\u6b65\uff0c\u53ea\u8fd0\u884c\u63d2\u4ef6 .\/sersync -m pluginName \u4f8b\u5982\uff1a.\/sersync -m command\uff0c\u5219\u5728\u76d1\u63a7\u5230\u4e8b\u4ef6\u540e\uff0c\u4e0d\u5bf9\u8fdc\u7a0b\u76ee\u6807\u670d\u52a1\u5668\u8fdb\u884c\u540c\u6b65\uff0c\u800c\u662f\u76f4\u63a5\u8fd0\u884ccommand\u63d2\u4ef6<\/p>\n<p>[root@localhost sersync]# cat monitor_sersync.sh #\u76d1\u63a7Sersync\u8fd0\u884c\u72b6\u6001\u7684\u811a\u672c\uff0c\u5982\u679c\u670d\u52a1\u505c\u6b62\u4e86\u5c31\u91cd\u542f\u670d\u52a1<br \/>\n#!\/bin\/bash<br \/>\nserver_file=&#8221;\/app\/sersync\/sersync2&#8243;<br \/>\nconf_file=&#8221;\/app\/sersync\/confxml.xml&#8221;<br \/>\noptions=&#8221;-d -r -n 8 -o&#8221;<br \/>\nproc_num=$(ps -ef|grep -i sersync2|grep -v &#8220;grep&#8221;|wc -l)<br \/>\nif [ $proc_num -lt 1 ];then<br \/>\n    cd $(dirname $server_file)<br \/>\n    nohup $server_file $options $conf_file &amp;<br \/>\nelse<br \/>\n   exit 0;<br \/>\nfi<br \/>\n[root@localhost sersync]# chmod +x monitor_sersync.sh<br \/>\n[root@localhost sersync]# crontab -l<br \/>\n*\/5 * * * *  \/app\/sersync\/monitor_sersync.sh<br \/>\n[root@localhost sersync]# \/etc\/init.d\/crond restart<br \/>\n[root@localhost sersync]# vim \/etc\/rc.d\/rc.local    \uff03\u8bbe\u7f6e\u5f00\u673a\u81ea\u52a8\u8fd0\u884c\u811a\u672c<br \/>\n\/app\/sersync\/sersync2 -d -r -n 8 -o \/app\/sersync\/confxml.xml<br \/>\n[root@localhost sersync]#<\/p>\n<p>\u6d4b\u8bd5<\/p>\n<p>\u5728\u5ba2\u6237\u7aef\u76d1\u63a7\u7684\u76ee\u5f55\/app\/rsync_client\u521b\u5efa\u6587\u4ef6\uff0c\u7136\u540e\u67e5\u770b\u670d\u52a1\u5668\u7aefapp_rsync_server\u6a21\u5757\u5bf9\u5e94\u7684\u76ee\u5f55\u662f\u5426\u540c\u6b65\u66f4\u65b0<br \/>\n[root@localhost rsync_client]# touch file{1..9}<br \/>\ninotify wd:1   name:file1  mask:256<br \/>\ninotify wd:1   name:file1  mask:8<br \/>\ninotify wd:1   name:file2  mask:256<br \/>\ninotify wd:1   name:file2  mask:8<br \/>\ninotify wd:1   name:file3  mask:256<br \/>\ninotify wd:1   name:file3  mask:8<br \/>\ninotify wd:1   name:file4  mask:256<br \/>\ninotify wd:1   name:file4  mask:8<br \/>\ninotify wd:1   name:file5  mask:256<br \/>\n[root@localhost rsync_client]# cd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file2&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ninotify wd:1   name:file5  mask:8<br \/>\ninotify wd:1   name:file6  mask:256<br \/>\ninotify wd:1   name:file6  mask:8<br \/>\ninotify wd:1   name:file7  mask:256<br \/>\ninotify wd:1   name:file7  mask:8<br \/>\ninotify wd:1   name:file8  mask:256<br \/>\ninotify wd:1   name:file8  mask:8<br \/>\ninotify wd:1   name:file9  mask:256<br \/>\ninotify wd:1   name:file9  mask:8<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file1&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file3&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file4&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file5&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file6&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file7&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file8&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\ncd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file9&#8221; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<br \/>\n[root@localhost rsync_client]# touch file1<br \/>\ninotify wd:1   name:file1  mask:8<br \/>\n[root@localhost rsync_client]# cd \/app\/rsync_client &amp;&amp; rsync -artuz -R &#8220;.\/file1&#8243; rsync@10.15.43.100::app_rsync_server &#8211;password-file=\/etc\/rsyncd.secret<\/p>\n<p>[root@localhost sersync]#<\/p>\n<p>\u538b\u6d4b<\/p>\n<p>\u5199\u516510K\u4e2a\u6587\u4ef6\u6279\u91cf\u540c\u6b65\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<p>[root@localhost rsync_client]# for n in {1..10000};do dd if=\/dev\/zero of=\/app\/rsync_client\/&#8221;$n&#8221;.txt bs=1M count=5;done<\/p>\n<p>\u67e5\u770b\u540c\u6b65\u901f\u5ea6\uff0c\u5f5310K\u4e2a\u6587\u4ef6\u540c\u6b65\u5b8c\u540e\uff0c\u5728\/app\/rsync_server\u91cc\u53d1\u73b0\u624d\u540c\u6b65\u4e86600\u591a\u4e2a\u6587\u4ef6<\/p>\n<p>\u591a\u5b9e\u4f8b\u60c5\u51b5<\/p>\n<p>\u914d\u7f6e\u591a\u4e2aconfxml.xml\u6587\u4ef6\uff08\u6bd4\u5982\uff1awww\u3001bbs\u3001blog&#8230;.\u7b49\u7b49\uff09\uff0c\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u540c\u6b65\u5bf9\u5e94\u7684\u5b9e\u4f8b\u6587\u4ef6<br \/>\n[root@localhost rsync_client]# \/app\/sersync\/sersync2 -d -r -n 8 -o \/app\/sersync\/www_confxml.xml<br \/>\n[root@localhost rsync_client]# \/app\/sersync\/sersync2 -d -r -n 8 -o \/app\/sersync\/bbs_confxml.xml<br \/>\n[root@localhost rsync_client]# \/app\/sersync\/sersync2 -d -r -n 8 -o \/app\/sersync\/blog_confxml.xml<\/p>\n<p>\u6587\u7ae0\u94fe\u63a5\uff1ahttps:\/\/www.centoschina.cn\/shell\/programming\/9368.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sersync\u7b80\u4ecb Sersync\u5229\u7528inotify\u4e0ersync\u5bf9\u670d\u52a1\u5668\u8fdb\u884c\u5b9e\u65f6\u540c\u6b65\uff0c\u5176\u4e2dinotify\u7528\u4e8e\u76d1 &#8230; <a title=\"CentOS6.9\u4f7f\u7528Rsync+sersync\u5b9e\u73b0\u6570\u636e\u5b9e\u65f6\u540c\u6b65\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/hemanual\/centos6-9%e4%bd%bf%e7%94%a8rsyncsersync%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5\/\" aria-label=\"\u9605\u8bfb CentOS6.9\u4f7f\u7528Rsync+sersync\u5b9e\u73b0\u6570\u636e\u5b9e\u65f6\u540c\u6b65\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,49,5],"tags":[848],"class_list":["post-3580","post","type-post","status-publish","format-standard","hentry","category-hemanual","category-linux","category-jishu","tag-rsyncsersync"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3580"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3580\/revisions"}],"predecessor-version":[{"id":3581,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3580\/revisions\/3581"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}