{"id":860,"date":"2014-08-23T22:16:46","date_gmt":"2014-08-23T13:16:46","guid":{"rendered":"http:\/\/tech.akat.info\/?p=860"},"modified":"2014-09-16T01:12:22","modified_gmt":"2014-09-15T16:12:22","slug":"lsync-rsync-%e3%81%a7%e5%90%8c%e6%9c%9f%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=860","title":{"rendered":"lsync + rsync \u3067\u540c\u671f\u3059\u308b"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>rsync\u306flinux\u3067\u3088\u304f\u5229\u7528\u3055\u308c\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u540c\u671f\u3055\u305b\u308b\u30b3\u30de\u30f3\u30c9<br \/>\nlsync(Live Syncing Daemon)\u306f\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u540c\u671f\u304c\u3067\u304d\u308b(Lua\u3092\u5229\u7528\u3057\u3066\u62e1\u5f35\u53ef\u80fd)\u30b3\u30de\u30f3\u30c9<br \/>\n\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u76e3\u8996\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u5897\u3048\u305f\u3089\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u9001\u308b<\/p>\n<p>hostsyn:sync\u5143\u306e\u30db\u30b9\u30c8<br \/>\nhosttarget\uff1async\u5148\u306e\u30db\u30b9\u30c8<br \/>\n\/var\/sync\uff1a \u540c\u671f\u3059\u308b\u30d5\u30a9\u30eb\u30c0<br \/>\n\u30a4\u30e1\u30fc\u30b8\uff1a<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/08\/2014-08-24_221740.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/08\/2014-08-24_221740.png\" alt=\"2014-08-24_221740\" width=\"713\" height=\"405\" class=\"alignnone size-full wp-image-867\" \/><\/a><\/p>\n<h1>\u8a2d\u5b9a-hostsyn-<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostsyn:\/home\/shimizu# aptitude install lsyncd rsync\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  lsyncd lua5.1{a} rsync\r\nroot@hostsyn:\/home\/shimizu# \/etc\/init.d\/lsyncd start # \u53cd\u5fdc\u304c\u306a\u3044\u305f\u3081\u78ba\u8a8d\u3059\u308b\u3068\r\nroot@hostsyn:\/home\/shimizu# lv \/etc\/init.d\/lsyncd # config(\/etc\/lsyncd\/lsyncd.conf.lua)\u304c\u306a\u3044\u305f\u3081\u3001\u9759\u304b\u306b\u7d42\u4e86\u3057\u3066\u3044\u305f\r\nroot@hostsyn:\/home\/shimizu# mkdir \/etc\/lsyncd\r\nroot@hostsyn:\/home\/shimizu# cp \/usr\/share\/doc\/lsyncd\/examples\/lrsync.lua \/etc\/lsyncd\/lsyncd.conf.lua\r\nroot@hostsyn:\/home\/shimizu# vi \/etc\/lsyncd\/lsyncd.conf.lua\r\n=====\r\n----\r\n-- User configuration file for lsyncd.\r\n--\r\n-- Simple example for default rsync.\r\n--\r\nsettings = {\r\n        logfile = &quot;\/var\/log\/lsyncd.log&quot;,\r\n        statusFile = &quot;\/tmp\/lsyncd.stat&quot;,\r\n        statusInterval = 1,\r\n}\r\n\r\nsync{\r\n        default.rsync,\r\n        source=&quot;\/var\/sync\/&quot;,\r\n        target=&quot;(hosttarget\u306eIP\u30a2\u30c9\u30ec\u30b9)::lsyncdModule&quot;,\r\n}\r\n=====\r\nroot@hostsyn:\/home\/shimizu# \/etc\/init.d\/lsyncd start\r\nroot@hostsyn:\/home\/shimizu# ps afx | grep &quot;&#x5B;l]sync&quot;\r\n18578 ?        Ss     0:00 \/usr\/bin\/lsyncd -pidfile \/var\/run\/lsyncd.pid \/etc\/lsyncd\/lsyncd.conf.lua\r\n18595 ?        S      0:00  \\_ \/usr\/bin\/rsync --delete --ignore-errors -lts -r \/var\/sync\/ 54.178.255.7::lsyncdModule\/\r\n<\/pre>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5b8c\u5168\u540c\u671f(rsync &#8211;delete)\u3059\u308b<br \/>\n\u907f\u3051\u305f\u3044\u5834\u5408\u306f\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b delete = false \u3092\u8a18\u8f09\u3059\u308b<\/p>\n<h1>\u8a2d\u5b9a-hosttarget-<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hosttarget:\/home\/shimizu# aptitude install rsync\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  rsync\r\nroot@hosttarget:\/home\/shimizu# vi \/etc\/default\/rsync\r\n=====\r\nRSYNC_ENABLE=true\r\n=====\r\nroot@hosttarget:\/home\/shimizu# \/etc\/init.d\/rsync start\r\n&#x5B;FAIL] Starting rsync daemon: rsync&#x5B;....] missing or empty config file \/etc\/rsyncd.conf ... failed!\r\n failed!\r\nroot@hosttarget:\/home\/shimizu# cp -p \/usr\/share\/doc\/rsync\/examples\/rsyncd.conf \/etc\/\r\nroot@hosttarget:\/home\/shimizu# vi \/etc\/rsyncd.conf\r\n====\r\nuid = root\r\ngid = root\r\n\r\n&#x5B;lsyncdModule]\r\n    path = \/var\/sync\/\r\n    hosts allow = (hostsync\u306eIP\u30a2\u30c9\u30ec\u30b9)\r\n    read only = no\r\n====\r\nroot@hosttarget:\/home\/shimizu# \/etc\/init.d\/rsync start\r\n&#x5B; ok ] Starting rsync daemon: rsync.\r\nroot@hosttarget:\/home\/shimizu# netstat -anp | grep &quot;rsync&quot;\r\ntcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      23433\/rsync\r\ntcp6       0      0 :::873                  :::*                    LISTEN      23433\/rsync\r\nunix  2      &#x5B; ]         DGRAM                    70600    23433\/rsync\r\n<\/pre>\n<h1>\u305d\u306e\u4ed6\u8a2d\u5b9a<\/h1>\n<p>\u540c\u671f\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u304c\u591a\u3044\u5834\u5408\u306f\u8a2d\u5b9a\u3092\u5909\u66f4\u3059\u308b<br \/>\n\u30ab\u30fc\u30cd\u30eb\u306e inotify \u304c\u540c\u671f\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u76e3\u8996\u3057\u3066\u304a\u308a\u3001\u76e3\u8996\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u6570\u306f\u8a2d\u5b9a\u5024\u306b\u3088\u308b(\u30c7\u30d5\u30a9\u30eb\u30c88192)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostsyn:\/var\/sync# sysctl -a | grep fs.inotify.max_user_watches\r\nfs.inotify.max_user_watches = 8192\r\nroot@hostsyn:\/var\/sync# vi \/etc\/sysctl.conf\r\n====\r\nfs.inotify.max_user_watches=524288\r\n====\r\nroot@hostsyn:\/var\/sync# sysctl -p\r\nfs.inotify.max_user_watches = 524288\r\n<\/pre>\n<h1>\u53c2\u8003URL<\/h1>\n<p>lsync\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<br \/>\nhttps:\/\/code.google.com\/p\/lsyncd\/<\/p>\n<p>\u8a2d\u5b9a\u304c\u308f\u304b\u308a\u3084\u3059\u304f\u304b\u304b\u308c\u3066\u3044\u308b\u30b5\u30a4\u30c8<br \/>\nhttp:\/\/www.very-cute.net\/wp\/lsyncd-rsyncd\/<\/p>\n<p>\u3068\u3066\u3082\u8a73\u7d30\u307e\u3067\u304b\u304b\u308c\u3066\u3044\u308b\u30b5\u30a4\u30c8<br \/>\nhttp:\/\/server-setting.info\/centos\/lsyncd-rsync-realtime.html<\/p>\n<p>\u540c\u671f\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3068\u6ce8\u610f\u70b9<br \/>\nhttp:\/\/www.hiratti.com\/server\/unix\/lsync_rsync_mirroring_caution<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 rsync\u306flinux\u3067\u3088\u304f\u5229\u7528\u3055\u308c\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u540c\u671f\u3055\u305b\u308b\u30b3\u30de\u30f3\u30c9 lsync(Live Syncing Daemon)\u306f\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u540c\u671f\u304c\u3067\u304d\u308b(Lua\u3092\u5229\u7528\u3057\u3066\u62e1\u5f35\u53ef\u80fd)\u30b3\u30de\u30f3\u30c9 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u76e3\u8996\u3057\u3001\u30d5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/860"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=860"}],"version-history":[{"count":8,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/860\/revisions"}],"predecessor-version":[{"id":869,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/860\/revisions\/869"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}