{"id":301,"date":"2021-07-28T14:13:34","date_gmt":"2021-07-28T06:13:34","guid":{"rendered":"http:\/\/egonlin.com\/?p=301"},"modified":"2024-03-21T15:52:24","modified_gmt":"2024-03-21T07:52:24","slug":"sersync","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=301","title":{"rendered":"sersync"},"content":{"rendered":"<h2>\u4e00\u3001NFS\u603b\u7ed3<\/h2>\n<h3>1.NFS\u4f18\u70b9<\/h3>\n<pre><code class=\"language-bash\">1.NFS\u6587\u4ef6\u7cfb\u7edf\u7b80\u5355\u6613\u7528\u3001\u65b9\u4fbf\u90e8\u7f72\u3001\u6570\u636e\u53ef\u9760\u3001\u670d\u52a1\u7a33\u5b9a\u3001\u6ee1\u8db3\u4e2d\u5c0f\u4f01\u4e1a\u9700\u6c42\u3002\n2.NFS\u6587\u4ef6\u7cfb\u7edf\u5185\u5b58\u653e\u7684\u6570\u636e\u90fd\u5728\u6587\u4ef6\u7cfb\u7edf\u4e4b\u4e0a\uff0c\u6240\u6709\u6570\u636e\u90fd\u662f\u80fd\u770b\u5f97\u89c1\u3002<\/code><\/pre>\n<h3>2.NFS\u7f3a\u70b9<\/h3>\n<pre><code class=\"language-bash\">1.\u5b58\u5728\u5355\u70b9\u6545\u969c, \u5982\u679c\u6784\u5efa\u9ad8\u53ef\u7528\u7ef4\u62a4\u9ebb\u70e6web-&gt;nfs()-&gt;backup\n2.NFS\u6570\u636e\u660e\u6587, \u5e76\u4e0d\u5bf9\u6570\u636e\u505a\u4efb\u4f55\u6821\u9a8c\u3002\n3.\u5ba2\u6237\u7aef\u6302\u8f7dNFS\u670d\u52a1\u6ca1\u6709\u5bc6\u7801\u9a8c\u8bc1, \u5b89\u5168\u6027\u4e00\u822c(\u5185\u7f51\u4f7f\u7528)<\/code><\/pre>\n<h3>3.NFS\u5e94\u7528\u5efa\u8bae<\/h3>\n<pre><code class=\"language-bash\">1.\u751f\u4ea7\u573a\u666f\u5e94\u5c06\u9759\u6001\u6570\u636e\u5c3d\u53ef\u80fd\u5f80\u524d\u7aef\u63a8, \u51cf\u5c11\u540e\u7aef\u5b58\u50a8\u538b\u529b\n2.\u5fc5\u987b\u5c06\u5b58\u50a8\u91cc\u7684\u9759\u6001\u8d44\u6e90\u901a\u8fc7CDN\u7f13\u5b58jpg\\png\\mp4\\avi\\css\\js\n3.\u5982\u679c\u6ca1\u6709\u7f13\u5b58\u6216\u67b6\u6784\u672c\u8eab\u5386\u53f2\u9057\u7559\u95ee\u9898\u592a\u5927, \u5728\u591a\u5b58\u50a8\u4e5f\u65e0\u7528<\/code><\/pre>\n<h2>\u4e8c\u3001Rsync+NFS \u89e3\u51b3\u5355\u70b9\u6545\u969c<\/h2>\n<h3>1.\u51c6\u5907\u73af\u5883<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u4e3b\u673a<\/th>\n<th>\u89d2\u8272<\/th>\n<th>IP<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>web01<\/td>\n<td>nfs\u5ba2\u6237\u7aef\u3001rsync\u5ba2\u6237\u7aef<\/td>\n<td>172.16.1.7\u300110.0.0.7<\/td>\n<\/tr>\n<tr>\n<td>nfs<\/td>\n<td>nfs\u670d\u52a1\u7aef\u3001rsync\u5ba2\u6237\u7aef<\/td>\n<td>172.16.1.31<\/td>\n<\/tr>\n<tr>\n<td>backup<\/td>\n<td>rsync\u670d\u52a1\u7aef<\/td>\n<td>172.16.1.41<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.web01\u642d\u5efa\u4e0a\u4f20\u4f5c\u4e1a\u4ee3\u7801<\/h3>\n<h4>1\uff09\u5173\u95ed\u9632\u706b\u5899\u548cselinux<\/h4>\n<h4>2\uff09\u5b89\u88c5httpd\u548cphp<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# yum install -y httpd php<\/code><\/pre>\n<h4>3\uff09\u914d\u7f6ehttpd<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# vim \/etc\/httpd\/conf\/httpd.conf\nUser www\nGroup www<\/code><\/pre>\n<h4>4\uff09\u521b\u5efa\u7528\u6237<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# groupadd www -g 666\n[root@web01 ~]# useradd www -u 666 -g 666<\/code><\/pre>\n<h4>5\uff09\u542f\u52a8\u670d\u52a1<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# systemctl start httpd\n\n#\u9a8c\u8bc1\u670d\u52a1\u542f\u52a8\n[root@web01 ~]# ps -ef | grep httpd<\/code><\/pre>\n<h4>6\uff09\u914d\u7f6e\u7f51\u7ad9\u4ee3\u7801<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# cd \/var\/www\/html\/\n[root@web01 html]# rz\n[root@web01 html]# ll\ntotal 28\n-rw-r--r--. 1 root root 26995 Nov 22 16:47 kaoshi.zip\n[root@web01 html]# unzip kaoshi.zip         \n[root@web01 html]# ll\ntotal 80\n-rw-r--r--. 1 root root 38772 Apr 27  2018 bg.jpg\n-rw-r--r--. 1 root root  2633 May  4  2018 index.html\n-rw-r--r--. 1 root root    52 May 10  2018 info.php\n-rw-r--r--. 1 root root 26995 Nov 22 16:47 kaoshi.zip\n-rw-r--r--. 1 root root  1192 Jan 10  2020 upload_file.php<\/code><\/pre>\n<h4>7\uff09\u4fee\u6539\u7ad9\u70b9\u76ee\u5f55\u6743\u9650<\/h4>\n<pre><code class=\"language-bash\">[root@web01 html]# chown -R www.www \/var\/www\/html\/<\/code><\/pre>\n<h3>3.NFS\u670d\u52a1\u5668\u642d\u5efaNFS\u670d\u52a1\u7aef<\/h3>\n<h4>1\uff09\u5173\u95ed\u9632\u706b\u5899\u548cselinux<\/h4>\n<h4>2\uff09\u5b89\u88c5NFS\u548crpcbind<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# yum install -y nfs-utils<\/code><\/pre>\n<h4>3\uff09\u914d\u7f6eNFS<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# vim \/etc\/exports\n\/data 172.16.1.0\/24(rw,sync,all_squash,anonuid=666,anongid=666)<\/code><\/pre>\n<h4>4\uff09\u521b\u5efa\u7528\u6237<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# groupadd www -g 666\n[root@nfs ~]# useradd www -u 666 -g 666<\/code><\/pre>\n<h4>5\uff09\u521b\u5efa\u76ee\u5f55\u5e76\u6388\u6743<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# mkdir \/data\n[root@nfs ~]# chown -R www.www \/data\/<\/code><\/pre>\n<h4>6\uff09\u542f\u52a8\u670d\u52a1<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# systemctl start nfs<\/code><\/pre>\n<h4>7\uff09\u9a8c\u8bc1\u914d\u7f6e<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# cat \/var\/lib\/nfs\/etab \n\/data   172.16.1.0\/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)<\/code><\/pre>\n<h3>4.web\u7aef\u6302\u8f7dNFS\u670d\u52a1\u5668<\/h3>\n<h4>1\uff09\u521b\u5efa\u6302\u8f7d\u76ee\u5f55\u5e76\u6388\u6743<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# mkdir \/var\/www\/html\/upload\n[root@web01 ~]# chown -R www.www \/var\/www\/html\/upload<\/code><\/pre>\n<h4>2\uff09\u5b89\u88c5rpcbind\u548cnfs<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# yum install -y nfs-utils rpcbind<\/code><\/pre>\n<h4>3\uff09\u67e5\u770b\u6302\u8f7d\u70b9<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# showmount -e 172.16.1.31\nExport list for 172.16.1.31:\n\/data 172.16.1.0\/24<\/code><\/pre>\n<h4>4\uff09\u6302\u8f7d<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# mount -t nfs 172.16.1.31:\/data \/var\/www\/html\/upload\n\n#\u9a8c\u8bc1\u6302\u8f7d\n[root@web01 ~]# df -h\nFilesystem         Size  Used Avail Use% Mounted on\n\/dev\/sda3           18G  1.7G   17G   9% \/\ndevtmpfs           476M     0  476M   0% \/dev\ntmpfs              487M     0  487M   0% \/dev\/shm\ntmpfs              487M  7.7M  479M   2% \/run\ntmpfs              487M     0  487M   0% \/sys\/fs\/cgroup\n\/dev\/sda1         1014M  127M  888M  13% \/boot\ntmpfs               98M     0   98M   0% \/run\/user\/0\n172.16.1.31:\/data   18G  1.6G   17G   9% \/var\/www\/html\/upload<\/code><\/pre>\n<h3>5.backup\u670d\u52a1\u5668\u642d\u5efarsync\u670d\u52a1\u7aef<\/h3>\n<h4>1\uff09\u5b89\u88c5<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# yum install -y rsync<\/code><\/pre>\n<h4>2\uff09\u914d\u7f6ersync<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# vim \/etc\/rsyncd.conf\nuid = www\ngid = www\nport = 873\nfake super = yes\nuse chroot = no\nmax connections = 200\ntimeout = 600\nignore errors\nread only = false\nlist = true\nauth users = rsync_backup\nsecrets file = \/etc\/rsync.passwd\nlog file = \/var\/log\/rsyncd.log\n#####################################\n[web_data]\ncomment = &quot;\u8be5\u5907\u4efd\u6587\u4ef6\u662fweb\u7aef\u6302\u8f7d\u5230nfs\u670d\u52a1\u5668\u7684\u6587\u4ef6&quot;\npath = \/data<\/code><\/pre>\n<h4>3\uff09\u521b\u5efa\u7528\u6237<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# groupadd www -g 666\n[root@backup ~]# useradd www -u 666 -g 666<\/code><\/pre>\n<h4>4\uff09\u521b\u5efa\u5bc6\u7801\u6587\u4ef6\u5e76\u6388\u6743<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# echo &quot;rsync_backup:123456&quot; &gt; \/etc\/rsync.passwd\n\n#\u6388\u6743\n[root@backup ~]# chmod 600 \/etc\/rsync.passwd<\/code><\/pre>\n<h4>5\uff09\u521b\u5efa\u771f\u5b9e\u76ee\u5f55\u5e76\u6388\u6743<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# mkdir \/data\n[root@backup ~]# chown -R www.www \/data\/<\/code><\/pre>\n<h4>6\uff09\u542f\u52a8\u670d\u52a1<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# systemctl start rsyncd\n\n#\u9a8c\u8bc1\u542f\u52a8\n[root@backup ~]# ps -ef | grep rsync\nroot      25733      1  0 15:24 ?        00:00:00 \/usr\/bin\/rsync --daemon --no-detach<\/code><\/pre>\n<h3>6.NFS\u670d\u52a1\u5668\u5b9e\u65f6\u5907\u4efddata\u76ee\u5f55\u5230rsync<\/h3>\n<h4>1\uff09\u5b89\u88c5inotify-tools<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# yum install -y inotify-tools<\/code><\/pre>\n<h4>2\uff09\u7f16\u5199\u811a\u672c<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# vim rsyn-inotify.sh\n#!\/bin\/bash\nexport RSYNC_PASSWORD=123456\ndir=\/data\n\/usr\/bin\/inotifywait -mrq --format &#039;%w %f&#039; -e create,delete,attrib,close_write $dir | while read line;do\n        cd $dir &amp;&amp; rsync -az -R --delete . rsync_backup@172.16.1.41::web_data &gt;\/dev\/null 2&gt;&amp;1\ndone &amp;<\/code><\/pre>\n<h4>3\uff09\u542f\u52a8\u811a\u672c<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# sh rsyn-inotify.sh \n[root@nfs ~]# ps -ef | grep rsyn\nroot       9224      1  0 15:30 pts\/0    00:00:00 sh rsyn-inotify.sh<\/code><\/pre>\n<h3>7.\u6d4b\u8bd5<\/h3>\n<pre><code class=\"language-bash\">1.\u8bbf\u95ee\u4ea4\u4f5c\u4e1a\u9875\u9762\uff08\u53ef\u4ee5\u914d\u7f6ewindows\u7684hosts   C:\\Windows\\System32\\drivers\\etc\uff09\n2.\u4e0a\u4f20\u4f5c\u4e1a\u6d4b\u8bd5\uff0c\u9875\u9762\u6210\u529f\n3.\u67e5\u770bweb\u670d\u52a1\u5668\u4e0a\u662f\u5426\u6709\u6587\u4ef6\n    [root@web01 ~]# ll \/var\/www\/html\/upload\n    total 32\n    -rw-r--r--. 1 www www 30419 Nov 23 15:41 2_nfs.jpg\n4.\u67e5\u770bNFS\u6302\u8f7d\u76ee\u5f55\u4e0b\u662f\u5426\u6709\u6587\u4ef6\n    [root@nfs ~]# ll \/data\/\n    total 32\n    -rw-r--r-- 1 www www 30419 Nov 23 15:41 2_nfs.jpg\n5.\u67e5\u770bbackup\u670d\u52a1\u5668\u4e0a\u662f\u5426\u6709\u6587\u4ef6\n    [root@backup ~]# ll \/data\/\n    total 100\n    -rw-r--r--. 1 www www 30419 Nov 23 15:41 2_nfs.jpg\n    -rw-r--r--. 1 www www 69097 Nov 23 15:43 3_nfs.jpg<\/code><\/pre>\n<h3>8.backup\u670d\u52a1\u5668\u5b89\u88c5NFS\u670d\u52a1\u7aef<\/h3>\n<h4>1\uff09\u5b89\u88c5NFS<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# yum install -y nfs-utils<\/code><\/pre>\n<h4>2\uff09\u914d\u7f6eNFS<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# cat \/etc\/exports\n\/data 172.16.1.0\/24(rw,sync,all_squash,anonuid=666,anongid=666)<\/code><\/pre>\n<h4>3\uff09\u542f\u52a8\u670d\u52a1<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# systemctl start nfs<\/code><\/pre>\n<h3>9.\u6545\u969c\u5207\u6362<\/h3>\n<h4>1\uff09NFS\u7aef\u641e\u4e8b\u60c5<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# systemctl stop nfs<\/code><\/pre>\n<h4>2\uff09\u5207\u6362\u6302\u8f7d\u7684\u673a\u5668<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# umount -lf \/var\/www\/html\/upload\n[root@web01 ~]# mount -t nfs 172.16.1.41:\/data \/var\/www\/html\/upload<\/code><\/pre>\n<h2>\u4e09\u3001sersync \u5b9e\u65f6\u540c\u6b65<\/h2>\n<h3>1.\u4ec0\u4e48\u662f\u5b9e\u65f6\u540c\u6b65<\/h3>\n<pre><code class=\"language-bash\">\u5b9e\u65f6\u540c\u6b65\u662f\u4e00\u79cd\u53ea\u8981\u5f53\u524d\u76ee\u5f55\u53d1\u751f\u53d8\u5316\u5219\u4f1a\u89e6\u53d1\u4e00\u4e2a\u4e8b\u4ef6\uff0c\u4e8b\u4ef6\u89e6\u53d1\u540e\u4f1a\u5c06\u53d8\u5316\u7684\u76ee\u5f55\u540c\u6b65\u81f3\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/code><\/pre>\n<h3>2.\u4e3a\u4ec0\u4e48\u4f7f\u7528<\/h3>\n<pre><code class=\"language-bash\">\u4fdd\u8bc1\u6570\u636e\u7684\u8fde\u7eed\u6027, \u51cf\u5c11\u4eba\u529b\u7ef4\u62a4\u6210\u672c,\u89e3\u51b3nfs\u5355\u70b9\u6545\u969c<\/code><\/pre>\n<h3>3.\u5b9e\u65f6\u540c\u6b65\u539f\u7406<\/h3>\n<pre><code class=\"language-bash\">\u5229\u7528inotify\u901a\u77e5\u63a5\u53e3\uff0c\u76d1\u63a7\u672c\u5730\u76ee\u5f55\u53d8\u5316\uff0c\u53ea\u8981\u76d1\u63a7\u76ee\u6807\u53d1\u751f\u53d8\u5316\uff0c\u5c31\u89e6\u53d1\u4e8b\u4ef6\uff0c\u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u3002<\/code><\/pre>\n<h3>4.\u5b9e\u65f6\u540c\u6b65\u5de5\u5177\u9009\u62e9<\/h3>\n<pre><code class=\"language-bash\">sersync + RSYNC(\u221a)\u3001inotify + rsync\n\nInotify\u662f\u4e00\u4e2a\u901a\u77e5\u63a5\u53e3\uff0c\u7528\u6765\u76d1\u63a7\u6587\u4ef6\u7cfb\u7edf\u7684\u5404\u79cd\u53d8\u5316\uff0c\u5982\u679c\u6587\u4ef6\u5b58\u53d6\uff0c\u5220\u9664\uff0c\u79fb\u52a8\u3002\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5b9e\u73b0\u6587\u4ef6\u5f02\u52a8\u544a\u8b66\uff0c\u589e\u91cf\u5907\u4efd\uff0c\u5e76\u9488\u5bf9\u76ee\u5f55\u6216\u6587\u4ef6\u7684\u53d8\u5316\u53ca\u65f6\u4f5c\u51fa\u54cd\u5e94\u3002rsync + inotify \u53ef\u4ee5\u505a\u5230\u5b9e\u65f6\u540c\u6b65\n\nsersync\u662f\u56fd\u4eba\u57fa\u4e8ersync+inotify-tools\u5f00\u53d1\u7684\u5de5\u5177\uff0c\u4e0d\u4ec5\u4fdd\u7559\u4e86\u4f18\u70b9\u540c\u65f6\u8fd8\u5f3a\u5316\u4e86\u5b9e\u65f6\u76d1\u63a7\uff0c\u6587\u4ef6\u8fc7\u6ee4\uff0c\u7b80\u5316\u914d\u7f6e\u7b49\u529f\u80fd\uff0c\u5e2e\u52a9\u7528\u6237\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\uff0c\u8282\u7701\u65f6\u95f4\u548c\u7f51\u7edc\u8d44\u6e90\u3002\n\nsersync\u9879\u76ee\u5730\u5740\uff1ahttps:\/\/github.com\/wsgzao\/sersync<\/code><\/pre>\n<h3>5.\u5b89\u88c5sersync<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u89d2\u8272<\/th>\n<th><\/th>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>NFS<\/td>\n<td>172.16.1.31<\/td>\n<td>nfs\/sersync<\/td>\n<\/tr>\n<tr>\n<td>backup<\/td>\n<td>172.16.1.41<\/td>\n<td>rsync-server<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1\uff09\u5b89\u88c5\u4f9d\u8d56\u73af\u5883<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# yum install -y inotify-tools rsync<\/code><\/pre>\n<h4>2\uff09\u4e0a\u4f20\u6216\u4e0b\u8f7dsersync\u5305<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# rz sersync2.5.4_64bit_binary_stable_final.tar.gz\n\n[root@nfs ~]# wget                                                                                          https:\/\/raw.githubusercontent.com\/wsgzao\/sersync\/master\/sersync2.5.4_64bit_binary_stable_final.tar.gz<\/code><\/pre>\n<h4>3\uff09\u89e3\u538b\u5b89\u88c5<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz<\/code><\/pre>\n<h4>4\uff09\u79fb\u52a8\u76ee\u5f55\u5e76\u6539\u540d<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# mv GNU-Linux-x86 \/usr\/local\/sersync<\/code><\/pre>\n<h4>5\uff09\u914d\u7f6esersync<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# confxml.xml confxml.bak                   #\u5907\u4efd\u914d\u7f6e\u6587\u4ef6\n[root@nfs ~]# vim \/usr\/local\/sersync\/confxml.xml\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;\n&lt;head version=&quot;2.5&quot;&gt;\n    &lt;host hostip=&quot;localhost&quot; port=&quot;8008&quot;&gt;&lt;\/host&gt;        #\u672c\u673aip\u5730\u5740\u548c\u7aef\u53e3\n    &lt;debug start=&quot;false&quot;\/&gt;                            #\u662f\u5426\u6253\u5f00\u8c03\u8bd5\u6a21\u5f0f\n    &lt;fileSystem xfs=&quot;false&quot;\/&gt;                         #\u662f\u5426\u652f\u6301xfs\u6587\u4ef6\u7cfb\u7edf\n    &lt;filter start=&quot;false&quot;&gt;                            #\u662f\u5426\u8fc7\u6ee4\uff0c\u662f\u5426\u6392\u9664\u540d\u79f0\u4e2d\u542b\u6709\u5236\u5b9a\u5b57\u7b26\u4e32\u7684\u6587\u4ef6\u7684\u540c\u6b65\n    &lt;exclude expression=&quot;(.*)\\.svn&quot;&gt;&lt;\/exclude&gt;\n    &lt;exclude expression=&quot;(.*)\\.gz&quot;&gt;&lt;\/exclude&gt;\n    &lt;exclude expression=&quot;^info\/*&quot;&gt;&lt;\/exclude&gt;\n    &lt;exclude expression=&quot;^static\/*&quot;&gt;&lt;\/exclude&gt;\n    &lt;\/filter&gt;\n    &lt;inotify&gt;\n        #inotify \u76d1\u63a7\u7684\u52a8\u4f5c\n        &lt;delete start=&quot;true&quot;\/&gt;                        #\u5220\u9664\u52a8\u4f5c\n        &lt;createFolder start=&quot;true&quot;\/&gt;                   #\u521b\u5efa\u6587\u4ef6\u5939\u52a8\u4f5c\n        &lt;createFile start=&quot;true&quot;\/&gt;                    #\u521b\u5efa\u6587\u4ef6\u52a8\u4f5c\n        &lt;closeWrite start=&quot;true&quot;\/&gt;                    #\u5199\u5165\u5b8c\u6210\u52a8\u4f5c\n        &lt;moveFrom start=&quot;true&quot;\/&gt;                      #\u79fb\u52a8\u6765\u81ea\u52a8\u4f5c\n        &lt;moveTo start=&quot;true&quot;\/&gt;                        #\u79fb\u52a8\u5230\u52a8\u4f5c\n        &lt;attrib start=&quot;true&quot;\/&gt;                        #\u5c5e\u6027\u88ab\u66f4\u6539\n        &lt;modify start=&quot;true&quot;\/&gt;                        #\u4fee\u6539\u52a8\u4f5c\n    &lt;\/inotify&gt;\n\n    &lt;sersync&gt;\n        &lt;localpath watch=&quot;\/data&quot;&gt;                       #\u76d1\u63a7\u7684\u76ee\u5f55\n            &lt;remote ip=&quot;172.16.1.41&quot; name=&quot;web_data&quot;\/&gt;            #\u8fdc\u7aefrsync\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u6a21\u5757\n        &lt;\/localpath&gt;\n        &lt;rsync&gt;\n            &lt;commonParams params=&quot;-az&quot;\/&gt;                #rsync\u7684\u53c2\u6570\n            &lt;auth start=&quot;true&quot; users=&quot;rsync_backup&quot; passwordfile=&quot;\/etc\/rsync.passwd&quot;\/&gt;\n            #\u5f00\u542f\u8ba4\u8bc1               #\u865a\u62df\u7528\u6237                   #\u6307\u5b9a\u865a\u62df\u7528\u6237\u7684\u5bc6\u7801\u6587\u4ef6\n            #\u5982\u679c\u8fdc\u7aefrsync\u670d\u52a1\u4e0d\u662f873\u7aef\u53e3\uff0c\u5219\u5f00\u542f\u5e76\u4fee\u6539\n            &lt;userDefinedPort start=&quot;false&quot; port=&quot;874&quot;\/&gt;&lt;!-- port=874             #\u5982\u679c\u8fdc\u7aefrsync\u670d\u52a1\u4e0d\u662f873\u7aef\u53e3\uff0c\u5219\u5f00\u542f\u5e76\u4fee\u6539\n            &lt;timeout start=&quot;false&quot; time=&quot;100&quot;\/&gt;&lt;!-- timeout=100 --&gt;         #\u8d85\u65f6\u65f6\u95f4\n            &lt;ssh start=&quot;false&quot;\/&gt;\n        &lt;\/rsync&gt;\n        #\u9519\u8bef\u65e5\u5fd7\u5b58\u50a8\u8def\u5f84\n        &lt;failLog path=&quot;\/tmp\/rsync_fail_log.sh&quot; timeToExecute=&quot;60&quot;\/&gt;&lt;!--default every 60mins execute once--&gt;        #\u5b9a\u65f6\u4efb\u52a1\uff0c\u5f00\u542f\u540e\uff0c600\u5206\u949f\u9ed8\u8ba4\u5168\u5907\u4e00\u6b21\n        #\u5b9a\u65f6\u4efb\u52a1\uff0c\u5f00\u542f\u540e\uff0c600\u5206\u949f\u9ed8\u8ba4\u5168\u5907\u4e00\u6b21\n        &lt;crontab start=&quot;false&quot; schedule=&quot;600&quot;&gt;&lt;!--600mins--&gt;        #\u5b9a\u65f6\u4efb\u52a1\uff0c\u5f00\u542f\u540e\uff0c600\u5206\u949f\u9ed8\u8ba4\u5168\u5907\u4e00\u6b21\n            &lt;crontabfilter start=&quot;false&quot;&gt;\n                &lt;exclude expression=&quot;*.php&quot;&gt;&lt;\/exclude&gt;\n                &lt;exclude expression=&quot;info\/*&quot;&gt;&lt;\/exclude&gt;\n            &lt;\/crontabfilter&gt;\n        &lt;\/crontab&gt;\n        &lt;plugin start=&quot;false&quot; name=&quot;command&quot;\/&gt;\n    &lt;\/sersync&gt;\n  &lt;plugin name=&quot;command&quot;&gt;  #\u6269\u5c55\u63d2\u4ef6\u529f\u80fd\u7684\u914d\u7f6e\u4e3e\u4f8b\n    &lt;param prefix=&quot;\/bin\/sh&quot; suffix=&quot;&quot; ignoreError=&quot;true&quot;\/&gt;  &lt;!--prefix \/opt\/tongbu\/mmm.sh suffix--&gt;\n    &lt;filter start=&quot;false&quot;&gt;\n        &lt;include expression=&quot;(.*)\\.php&quot;\/&gt;\n        &lt;include expression=&quot;(.*)\\.sh&quot;\/&gt;\n    &lt;\/filter&gt;\n    &lt;\/plugin&gt;\n\n    &lt;plugin name=&quot;socket&quot;&gt;      #\u6269\u5c55\u63d2\u4ef6\u529f\u80fd\u7684\u914d\u7f6e\u4e3e\u4f8b\n    &lt;localpath watch=&quot;\/opt\/tongbu&quot;&gt;\n        &lt;deshost ip=&quot;192.168.138.20&quot; port=&quot;8009&quot;\/&gt;\n    &lt;\/localpath&gt;\n    &lt;\/plugin&gt;\n    &lt;plugin name=&quot;refreshCDN&quot;&gt;              #\u6269\u5c55\u63d2\u4ef6\u529f\u80fd\u7684\u914d\u7f6e\u4e3e\u4f8b\n    &lt;localpath watch=&quot;\/data0\/htdocs\/cms.xoyo.com\/site\/&quot;&gt;\n        &lt;cdninfo domainname=&quot;ccms.chinacache.com&quot; port=&quot;80&quot; username=&quot;xxxx&quot; passwd=&quot;xxxx&quot;\/&gt;\n        &lt;sendurl base=&quot;http:\/\/pic.xoyo.com\/cms&quot;\/&gt;\n        &lt;regexurl regex=&quot;false&quot; match=&quot;cms.xoyo.com\/site([\/a-zA-Z0-9]*).xoyo.com\/images&quot;\/&gt;\n    &lt;\/localpath&gt;\n    &lt;\/plugin&gt;\n&lt;\/head&gt;\n<\/code><\/pre>\n<h4>6\uff09\u521b\u5efa\u865a\u62df\u7528\u6237\u5bc6\u7801\u6587\u4ef6<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# echo &#039;123456&#039; &gt; \/etc\/rsync.passwd\n[root@nfs ~]# chmod 600 \/etc\/rsync.passwd <\/code><\/pre>\n<h4>7\uff09\u542f\u52a8\u670d\u52a1<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# \/usr\/local\/sersync\/sersync2 -h\nset the system param\nexecute\uff1aecho 50000000 &gt; \/proc\/sys\/fs\/inotify\/max_user_watches\nexecute\uff1aecho 327679 &gt; \/proc\/sys\/fs\/inotify\/max_queued_events\nparse the command param\n_______________________________________________________\n\u53c2\u6570-d:\u542f\u7528\u5b88\u62a4\u8fdb\u7a0b\u6a21\u5f0f\n\u53c2\u6570-r:\u5728\u76d1\u63a7\u524d\uff0c\u5c06\u76d1\u63a7\u76ee\u5f55\u4e0e\u8fdc\u7a0b\u4e3b\u673a\u7528rsync\u547d\u4ee4\u63a8\u9001\u4e00\u904d\n\u53c2\u6570-n: \u6307\u5b9a\u5f00\u542f\u5b88\u62a4\u7ebf\u7a0b\u7684\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a10\u4e2a\n\u53c2\u6570-o:\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\uff0c\u9ed8\u8ba4\u4f7f\u7528confxml.xml\u6587\u4ef6\n\u53c2\u6570-m:\u5355\u72ec\u542f\u7528\u5176\u4ed6\u6a21\u5757\uff0c\u4f7f\u7528 -m refreshCDN \u5f00\u542f\u5237\u65b0CDN\u6a21\u5757\n\u53c2\u6570-m:\u5355\u72ec\u542f\u7528\u5176\u4ed6\u6a21\u5757\uff0c\u4f7f\u7528 -m socket \u5f00\u542fsocket\u6a21\u5757\n\u53c2\u6570-m:\u5355\u72ec\u542f\u7528\u5176\u4ed6\u6a21\u5757\uff0c\u4f7f\u7528 -m http \u5f00\u542fhttp\u6a21\u5757\n\u4e0d\u52a0-m\u53c2\u6570\uff0c\u5219\u9ed8\u8ba4\u6267\u884c\u540c\u6b65\u7a0b\u5e8f\n\n[root@nfs ~]# \/usr\/local\/sersync\/sersync2 -dro \/usr\/local\/sersync\/confxml.xml<\/code><\/pre>\n<h2>\u56db\u3001\u6269\u5c55\u5206\u4eab<\/h2>\n<h3>1.rsync\u914d\u7f6e\u591a\u4e2a\u6a21\u5757\u53ca\u76ee\u5f55<\/h3>\n<h4>1\uff09rsync\u670d\u52a1\u7aef<\/h4>\n<pre><code class=\"language-bash\">[root@backup ~]# vim \/etc\/rsyncd.conf \nuid = www\ngid = www\nport = 873\nfake super = yes\nuse chroot = no\nmax connections = 200\ntimeout = 600\nignore errors\nread only = false\nlist = true\nauth users = rsync_backup\nsecrets file = \/etc\/rsync.passwd\nlog file = \/var\/log\/rsyncd.log\n#####################################\n[web_data]\ncomment = &quot;\u8be5\u5907\u4efd\u6587\u4ef6\u662fweb\u7aef\u6302\u8f7d\u5230nfs\u670d\u52a1\u5668\u7684\u6587\u4ef6&quot;\npath = \/data\n\n[backup]\ncomment = &quot;\u8be5\u76ee\u5f55\u5907\u4efd\u670d\u52a1\u5668\u65e5\u5e38\u5907\u4efd\u6587\u4ef6&quot;\npath = \/backup\nauth users = rsync_user\nsecrets file = \/etc\/rsync.password<\/code><\/pre>\n<h4>2\uff09rsync\u5ba2\u6237\u7aef<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# rsync -avz . rsync_backup@172.16.1.41::web_data   \nPassword: 123456\nsending incremental file list\n.\/\nsent 47 bytes  received 23 bytes  28.00 bytes\/sec\ntotal size is 0  speedup is 0.00\n\n#\u4f7f\u7528\u4e24\u4e2a\u6a21\u5757\u63a8\u9001\n[root@nfs ~]# rsync -avz . rsync_user@172.16.1.41::backup\nPassword: 678910\nsending incremental file list\n.\/\nsent 47 bytes  received 23 bytes  20.00 bytes\/sec\ntotal size is 0  speedup is 0.00\n\n#\u4f7f\u7528\u5bc6\u7801\u6587\u4ef6\u63a8\u9001\n[root@nfs ~]# echo &#039;123456&#039; &gt; \/etc\/rsync.passwd\n[root@nfs ~]# echo &#039;678910&#039; &gt; \/etc\/rsync.password\n\n[root@nfs ~]# chmod 600 \/etc\/rsync.passwd\n[root@nfs ~]# chmod 600 \/etc\/rsync.password\n\n[root@nfs ~]# rsync -avz . rsync_backup@172.16.1.41::web_data --password-file=\/etc\/rsync.passwd\n[root@nfs ~]# rsync -avz . rsync_user@172.16.1.41::backup --password-file=\/etc\/rsync.password<\/code><\/pre>\n<h3>2.NFS\u914d\u7f6e\u591a\u4e2a\u6302\u8f7d\u76ee\u5f55<\/h3>\n<h4>1\uff09NFS\u914d\u7f6e\u591a\u4e2a\u53ef\u6302\u8f7d\u76ee\u5f55<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# vim \/etc\/exports\n\/data 172.16.1.0\/24(rw,sync,all_squash,anonuid=666,anongid=666)\n\/pic 172.16.1.0\/24(rw,sync,all_squash,anonuid=666,anongid=666)<\/code><\/pre>\n<h4>2\uff09NFS\u5ba2\u6237\u7aef\u67e5\u770b<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# showmount -e 172.16.1.31\nExport list for 172.16.1.31:\n\/pic  172.16.1.0\/24\n\/data 172.16.1.0\/24<\/code><\/pre>\n<h3>3.sersync\u914d\u7f6e\u542f\u52a8\u591a\u4e2a\u5b9e\u65f6\u5907\u4efd<\/h3>\n<h4>1\uff09\u7b2c\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# cat \/usr\/local\/sersync\/confxml.xml\n... ...\n    &lt;host hostip=&quot;localhost&quot; port=&quot;8008&quot;&gt;&lt;\/host&gt;\n        &lt;localpath watch=&quot;\/data&quot;&gt;\n        &lt;remote ip=&quot;172.16.1.41&quot; name=&quot;web_data&quot;\/&gt;\n    ... ...\n    &lt;rsync&gt;\n        &lt;commonParams params=&quot;-az&quot;\/&gt;\n        &lt;auth start=&quot;true&quot; users=&quot;rsync_backup&quot; passwordfile=&quot;\/etc\/rsync.passwd&quot;\/&gt;\n    ... ...\n... ...<\/code><\/pre>\n<h4>2\uff09\u7b2c\u4e8c\u4e2a\u914d\u7f6e\u6587\u4ef6<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# cat \/usr\/local\/sersync\/backup.xml\n... ...\n    &lt;host hostip=&quot;localhost&quot; port=&quot;8009&quot;&gt;&lt;\/host&gt;\n        &lt;localpath watch=&quot;\/backup&quot;&gt;\n        &lt;remote ip=&quot;172.16.1.41&quot; name=&quot;backup&quot;\/&gt;\n    ... ...\n    &lt;rsync&gt;\n        &lt;commonParams params=&quot;-az&quot;\/&gt;\n        &lt;auth start=&quot;true&quot; users=&quot;rsync_user&quot; passwordfile=&quot;\/etc\/rsync.password&quot;\/&gt;\n    ... ...\n... ...<\/code><\/pre>\n<h4>3\uff09\u542f\u52a8\u591a\u4e2asersync<\/h4>\n<pre><code class=\"language-bash\">[root@nfs ~]# \/usr\/local\/sersync\/sersync2 -dro \/usr\/local\/sersync\/confxml.xml\n[root@nfs ~]# \/usr\/local\/sersync\/sersync2 -dro \/usr\/local\/sersync\/backup.xml\n\n#\u67e5\u770b\u8fdb\u7a0b\n[root@nfs ~]# !ps\nps -ef | grep sersync\nroot       9601      1  0 17:03 ?        00:00:00 \/usr\/local\/sersync\/sersync2 -dro \/usr\/local\/sersync\/confxml.xml\nroot       9938      1  0 17:52 ?        00:00:00 \/usr\/local\/sersync\/sersync2 -dro \/usr\/local\/sersync\/backup.xml\nroot       9976   9270  0 17:56 pts\/1    00:00:00 grep --color=auto sersync<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001NFS\u603b\u7ed3 1.NFS\u4f18\u70b9 1.NFS\u6587\u4ef6\u7cfb\u7edf\u7b80\u5355\u6613\u7528\u3001\u65b9\u4fbf\u90e8\u7f72\u3001\u6570\u636e\u53ef\u9760\u3001\u670d\u52a1\u7a33\u5b9a\u3001\u6ee1\u8db3\u4e2d\u5c0f\u4f01\u4e1a\u9700\u6c42\u3002  [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[21,19,22,57,20],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/301"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301"}],"version-history":[{"count":1,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":8757,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/301\/revisions\/8757"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}