驚!Rsync 文件同步竟遭遇失?。渴职咽纸棠闩挪?,告別同步煩惱!
2024-11-08 14:11:38
Jinyu
問題
rsync客戶端:拋錯異常退出
發布失敗截圖如下:
# rsync -avz --delete --exclude='.git' --exclude='.svn' rsync://<rsync_srv>:<rsync_port>/path/to/folder /tmp/rsync-test
receiving incremental file list
...
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [receiver=3.0.6]
rsync: connection unexpectedly closed (99 bytes received so far) [generator]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [generator=3.0.6]
rsync客戶端:進程僵死
# rsync -avzP --delete--exclude='.git' --exclude='.svn' rsync://<rsync_srv>:<rsync_port>/path/to/folder /tmp/rsync-test
Password:
receiving incremental file list
./
<rsync-test-pkg>-SNAPSHOT.jar
^C
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(551) [generator=3.0.9]
rsync error: received SIGUSR1 (code 19) at main.c(1298) [receiver=3.0.9]
執行第二,甚至第三次時,才成功:
# rsync -avzP --delete--exclude='.git' --exclude='.svn' rsync://<rsync_srv>:<rsync_port>/path/to/folder /tmp/rsync-test
Password:
receiving incremental file list
./
<rsync-test-pkg>-SNAPSHOT.jar
60606801 100% 16.13MB/s0:00:03 (xfer#1, to-check=0/3)
sent 21035 bytesreceived 43167123 bytes5758421.07 bytes/sec
total size is 60607326speedup is 1.40
網上搜了下,發現已經有人發現 rsync 類似問題了,引用其博客:
盡管您可能已經在rsyncd服務的后端進程中設置了--timeout選項(即在rsyncd.conf配置中),然而,在某些情況下(under the circumstances),這個選項可能根本不起作用,一些極不穩定的網絡導致大量TCP超時連接,進而導致 rsync 進程失敗,雖然斷裂的 TCP 連線已經消失,但 rsync 應用進程卻可能因為種種原因(如因等候I/O中斷而處于不可中斷狀態),而遺留在系統之中,并最終變成為僵尸進程(zombie process)。
按照其手冊頁的解釋,rsync 命令本身的 timeout 預設為0,也就是沒有逾時設置,因此運行中的 rsync 進程將會永久地等待遠端的反應。在rsyncd服務后端進程的 rsyncd.conf中設置timeout選項,同時在rsync客戶端命令行中使用timeout選項,實踐證明是可杜絕此問題的。
--timeout
參數,再次執行后確實能夠異常退出了:# rsync -avzP --timeout=60 --delete--exclude='.git' --exclude='.svn' rsync://<rsync_srv>:<rsync_port>/path/to/folder /tmp/rsync-testPassword: receiving incremental file list./<rsync-test-pkg>-SNAPSHOT.jar2011425333% 19.18MB/s0:00:02[receiver] io timeout after 60 seconds -- exitingrsync error: timeout in data send/receive (code 30) at io.c(140) [receiver=3.0.9]rsync: connection unexpectedly closed (115 bytes received so far) [generator]rsync error: error in rsync protocol data stream (code 12) at io.c(605) [generator=3.0.9]
rsync服務端:異常日志
2018/10/26 14:40:30 [4228] name lookup failed for <rsync-client>: Name or service not known
2018/10/26 14:40:30 [4228] connect from UNKNOWN (<rsync-client>)
2018/10/26 14:40:30 [4228] rsync on path/to/folder from UNKNOWN (<rsync-client>)
2018/10/26 14:40:30 [4228] building file list
2018/10/26 14:40:35 [4228] rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection timed out (110)
2018/10/26 14:40:35 [4228] rsync error: error in rsync protocol data stream (code 12) at io.c(1525) [sender=3.0.6]
rsync客戶端:strace排查
lstat("<rsync-test-pkg>-SNAPSHOT.jar", 0x7fff7d6e0000) = -1 ENOENT (No such file or directory)select(5, [4], [3], [3], {30, 0}) = 2 (in [4], out [3], left {29, 999998})select(5, [4], [], NULL, {30, 0}) = 1 (in [4], left {29, 999999})read(4, " 主站蜘蛛池模板: 乐平市| 遵义市| 从化市| 阿合奇县| 昌都县| 惠来县| 韩城市| 广南县| 湟中县| 义乌市| 浮山县| 霍林郭勒市| 桦川县| 棋牌| 苏尼特右旗| 丽江市| 思南县| 五指山市| 峡江县| 朝阳区| 荃湾区| 房山区| 上高县| 水城县| 通化县| 绵阳市| 吉隆县| 章丘市| 陆丰市| 桐梓县| 宜宾市| 都兰县| 泊头市| 泽库县| 龙井市| 清原| 灵宝市| 西吉县| 日喀则市| 清流县| 图木舒克市|