驚!Rsync 文件同步竟遭遇失?。渴职咽纸棠闩挪?,告別同步煩惱!
2024-11-08 14:11:38
Jinyu
問題
rsync客戶端:拋錯異常退出
發(fā)布失敗截圖如下:
# 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]
執(zhí)行第二,甚至第三次時,才成功:
# 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
網(wǎng)上搜了下,發(fā)現(xiàn)已經(jīng)有人發(fā)現(xiàn) rsync 類似問題了,引用其博客:
盡管您可能已經(jīng)在rsyncd服務的后端進程中設置了--timeout選項(即在rsyncd.conf配置中),然而,在某些情況下(under the circumstances),這個選項可能根本不起作用,一些極不穩(wěn)定的網(wǎng)絡導致大量TCP超時連接,進而導致 rsync 進程失敗,雖然斷裂的 TCP 連線已經(jīng)消失,但 rsync 應用進程卻可能因為種種原因(如因等候I/O中斷而處于不可中斷狀態(tài)),而遺留在系統(tǒng)之中,并最終變成為僵尸進程(zombie process)。
按照其手冊頁的解釋,rsync 命令本身的 timeout 預設為0,也就是沒有逾時設置,因此運行中的 rsync 進程將會永久地等待遠端的反應。在rsyncd服務后端進程的 rsyncd.conf中設置timeout選項,同時在rsync客戶端命令行中使用timeout選項,實踐證明是可杜絕此問題的。
--timeout
參數(shù),再次執(zhí)行后確實能夠異常退出了:# 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, " 东明县| 陕西省| 息烽县| 奉贤区| 安顺市| 连山| 临沧市| 黔东| 永川市| 成武县| 双柏县| 邮箱| 眉山市| 木兰县| 常州市| 泸定县| 洮南市| 安宁市| 伊金霍洛旗| 湖北省| 牡丹江市| 云浮市| 德格县| 吉林市| 左云县| 敦煌市| 灵台县| 鹤庆县| 荥阳市| 海淀区| 天等县| 澳门| 新密市| 五家渠市| 葫芦岛市| 石门县| 阿拉善右旗| 乌鲁木齐县| 合江县| 平乐县| 怀集县|