rsync?常見錯誤與解決方法整理
我們都是通過錯誤日志查看
在rsyncd.log里面或.err文件里面,大家可以用記事本打開查看。
注意windows下面我們需要給SvcwRsync用戶,管理同步目錄的所有權(quán)限,基本上這樣就可以了,如果前期沒有加權(quán)限,而且目錄文件已經(jīng)很多了,建議直接將SvcwRsync設置管理員即可。但這樣會有一些安全風險,最好限制用戶登陸。
sync使用時的常見問題
錯誤1: rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receiver=3.0.2]
解決:很大可能是服務器端沒有開啟 rsync 服務,一般開啟服務即可。 或者開啟了防火墻指定的端口873無法訪問或者機房攔截源ip。
錯誤2:@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:服務器端同步目錄沒有權(quán)限,cwrsync默認用戶是Svcwrsync。為同步目錄添加用戶Svcwrsync權(quán)限。
錯誤3:@ERROR: failed to open lock file
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:服務器端配置文件 rsyncd.conf中添加 lock file = rsyncd.lock 即可解決。
錯誤4:@ERROR: invalid uid nobody
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.2]
解決:在rsyncd.conf文件中添加下面兩行即可解決問題
UID = 0
GID = 0
錯誤5:@ERROR: auth failed on module test2
rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=3.0.2]
解決:服務端沒有指定正確的secrets file,請在 [test2]配置段添加如下配置行:
auth users = coldstar #同步使用的帳號
secrets file = rsyncd.secrets #密碼文件
錯誤6:password file must not be other-accessible
解決:客戶端的pass文件要求權(quán)限為600, chmod 600 /etc/rsync.pass 即可。
錯誤7:rsync: chdir /cygdrive/c/work failed
: No such file or directory (2)
解決:服務器端同步文件夾路徑或名稱寫錯了,檢查path。
rsyncserver 服務啟動時報錯“rsyncserver服務啟動后又停止了。
一些服務自動停止,如果它們沒有什么可做的,例如“性能日志和警報”服務。”
解決方法:將安裝目錄下的rsyncd.pid文件刪除,再重新啟動RsyncServer服務。一般是異常關(guān)機導致的。
或者通過計劃任務定時執(zhí)行這個bat就可以自動開啟rsync服務了
@echo off for /f "usebackq" %%i in (`"tasklist|find /c "cygrunsrv.exe""`) do ( set chkstat=%%i ) if %chkstat% == 0 ( del "e:\Program Files (x86)\ICW\rsyncd.pid" /f net start RsyncServer echo ================ >> rsync%date:~0,10%.log echo %date% %time% check rsync service stop >> rsync%date:~0,10%.log echo restart rsync service! >> rsync%date:~0,10%.log echo ================ >> rsync%date:~0,10%.log )
如果日志文件過大會導致同步慢等問題,大家可以用下面的批處理
原理就是先判斷服務器是不是正常運行,運行的時候停止服務,然后將日志與pid文件刪除,再重新啟動即可,一般幾天一次就可以了。
@echo off for /f "usebackq" %%i in (`"tasklist|find /c "cygrunsrv.exe""`) do ( set chkstat=%%i ) if %chkstat% == 1 ( net stop RsyncServer del "D:\Program Files (x86)\ICW\rsyncd.pid" /f del "D:\Program Files (x86)\ICW\rsyncd.log" /f net start RsyncServer echo ================ >> rsync%date:~0,10%.log echo %date% %time% check rsync service stop >> rsync%date:~0,10%.log echo restart rsync service! >> rsync%date:~0,10%.log echo ================ >> rsync%date:~0,10%.log )
錯誤列表
問題一:
@ERROR: chroot failed
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器端的目錄不存在或無權(quán)限,創(chuàng)建目錄并修正權(quán)限可解決問題。
問題二:
@ERROR: auth failed on module tee
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器端該模塊(tee)需要驗證用戶名密碼,但客戶端沒有提供正確的用戶名密碼,認證失敗。
提供正確的用戶名密碼解決此問題。
問題三:
@ERROR: Unknown module ‘tee_nonexists’
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器不存在指定模塊。提供正確的模塊名或在服務器端修改成你要的模塊以解決問題。
問題1:
在client上遇到問題:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
rsync: could not open password file "/etc/rsync.pas": No such file or directory (2)
Password:
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
遇到這個問題:client端沒有設置/etc/rsync.pas這個文件,而在使用rsync命令的時候,加了這個參數(shù)--
password-file=/etc/rsync.pas
問題2:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
遇到這個問題:client端已經(jīng)設置/etc/rsync.pas這個文件,里面也設置了密碼111111,和服務器一致,但是
服務器段設置有錯誤,服務器端應該設置/etc/rsync.pas ,里面內(nèi)容root:111111 ,這里登陸名不可缺少
問題3:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
遇到這個問題,是因為服務器端的/home/backup 其中backup這個目錄并沒有設置,所以提示:chdir failed
問題4:
rsync: write failed on "/home/backup2010/wensong": No space left on device (28)
rsync error: error in file IO (code 11) at receiver.c(302) [receiver=3.0.7]
rsync: connection unexpectedly closed (2721 bytes received so far) [generator]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [generator=3.0.7]
磁盤空間不夠,所以無法操作。
可以通過df /home/backup2010 來查看可用空間和已用空間
問題5:網(wǎng)絡收集問題
1、權(quán)限問題
類似如下的提示:rsync: opendir "/kexue" (in dtsChannel) failed: Permission denied (13)注意查看同步的目錄權(quán)限是否為755
2、time out
rsync: failed to connect to 203.100.192.66: Connection timed out (110)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
檢查服務器的端口netstat –tunlp,遠程telnet測試。
可能因為客戶端或者服務端的防火墻開啟 導致無法通信,可以設置規(guī)則放行 rsync(873端口) 或者直接關(guān)閉防火墻。
還有一種在同步過程中可能會提示沒有權(quán)限 (將同步目錄加上SvcwRsync全部權(quán)限即可,更簡單的方法就是將SvcwRsync設為管理員即可)
3、服務未啟動
rsync: failed to connect to 10.10.10.170: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
啟動服務:rsync --daemon --config=/etc/rsyncd.conf
4、磁盤空間滿
rsync: recv_generator: mkdir "/teacherclubBackup/rsync……" failed: No space left on device (28)
*** Skipping any contents from this failed directory ***
5、Ctrl+C或者大量文件
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [receiver=3.0.5]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [generator=3.0.5]
說明:導致此問題多半是服務端服務沒有被正常啟動,到服務器上去查查服務是否有啟動,然后查看下 /var/run/rsync.pid 文件是否存在,最干脆的方法是殺死已經(jīng)啟動了服務,然后再次啟動服務或者讓腳本加入系統(tǒng)啟動服務級別然后shutdown -r now服務器
6、xnetid啟動
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.5]
查看rsync日志
rsync: unable to open configuration file "/etc/rsyncd.conf": No such file or directory
xnetid查找的配置文件位置默認是/etc下,根據(jù)具體情況創(chuàng)建軟鏈接。例如:
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
或者更改指定默認的配置文件路徑,在/etc/xinetd.d/rsync配置文件中。
Rsync configure:
配置一:
ignore errors
說明:這個選項最好加上,否則再很多crontab的時候往往發(fā)生錯誤你也未可知,因為你不可能天天去看每時每刻去看log,不加上這個出現(xiàn)錯誤的幾率相對會很高,因為任何大點的項目和系統(tǒng),磁盤IO都是一個瓶頸
Rsync error:
錯誤一:
@ERROR: auth failed on module xxxxx
rsync: connection unexpectedly closed (90 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
說明:這是因為密碼設置錯了,無法登入成功,檢查一下rsync.pwd,看客服是否匹配。還有服務器端沒啟動rsync 服務也會出現(xiàn)這種情況。
錯誤二:
password file must not be other-accessible
continuing without password file
Password:
說明:這是因為rsyncd.pwd rsyncd.sec的權(quán)限不對,應該設置為600。如:chmod 600 rsyncd.pwd
錯誤三:
@ERROR: chroot failed
rsync: connection unexpectedly closed (75 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
說明:這是因為你在 rsync.conf 中設置的 path 路徑不存在,要新建目錄才能開啟同步
錯誤四:
rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
說明:防火墻問題導致,這個最好先徹底關(guān)閉防火墻,排錯的基本法就是這樣,無論是S還是C,還有ignore errors選項問題也會導致
錯誤五:
@ERROR: access denied to www from unknown (192.168.1.123)
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(359)
說明:此問題很明顯,是配置選項host allow的問題,初學者喜歡一個允許段做成一個配置,然后模塊又是同一個,致使導致
錯誤六:
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(244) [generator=2.6.9]
rsync error: received SIGUSR1 (code 19) at main.c(1182) [receiver=2.6.9]
說明:導致此問題多半是服務端服務沒有被正常啟動,到服務器上去查查服務是否有啟動,然后查看下 /var/run/rsync.pid 文件是否存在,最干脆的方法是殺死已經(jīng)啟動了服務,然后再次啟動服務或者讓腳本加入系統(tǒng)啟動服務級別然后shutdown -r now服務器
錯誤七:
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(604) [sender=2.6.9]
說明:原數(shù)據(jù)目錄里沒有數(shù)據(jù)存在
rsync 錯誤與解決方法整理補充篇
由于我們經(jīng)常使用rsync進行服務器文件的同步工作,但在配置過程中,會出現(xiàn)很多問題,下面的錯誤基本上都是通過客戶端返回的錯誤進行分析。
另外查找錯誤過程中也學到了一個查看錯誤的方法-查看系統(tǒng)日志,我們操作的每步都會在日志上有說明,有時候報錯看不懂,日志上都寫的清清楚楚。
命令:cat /var/log/messages
問題一:
@ERROR: auth failed on module bachup
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:服務器端該模塊(backup)需要驗證用戶名密碼,但客戶端沒有提供正確的用戶名密碼,認證失敗。 提供正確的用戶名密碼解決此問題。
這個問題比較蠢,如果可能你和我一樣明明在模塊里寫了密碼文件,怎么都不通,這個時候我勸你先檢查一下所寫模塊中是不是和下圖一樣。比如,某處多了個s。
問題二:110錯誤 -time out
rsync: failed to connect to 203.100.192.66: Connection timed out (110)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.8]
原因:
檢查服務器的端口netstat –tunlp,遠程telnet測試。 可能因為客戶端或者服務端的防火墻開啟 導致無法通信,可以設置規(guī)則放行 rsync(873端口) 或者直接關(guān)閉防火墻或者ip安全策略(機房的防火漆可能攔截了,可以找機房)。
在這里博主是重啟過服務器,然后就報110了,直接開啟rsync服務就行。
命令:service rsyncd start
問題三:113錯誤 -防火墻
rsync: failed to connect to 218.107.243.2: No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
原因:
防火墻問題導致,這個很簡單,關(guān)閉防火墻就可以。不過博主還是被困在這里幾個小時,因為linux防火墻分兩種:
-iptable和-firewall
認識到這個問題首先查看系統(tǒng)的防火墻種類,查看防火墻狀態(tài)即可
service iptable status
firewall-cmd --state
確定防火墻種類后再按對應方法將防火墻關(guān)閉即可。
問題四:1516錯誤
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1516) [Receiver=3.0.9]
解決:這個問題錯誤差別很大,可查看系統(tǒng)日志查看錯誤,再搜索解決方法。
注意:一般這種情況都建立在可以連通的基礎。去服務端查看系統(tǒng)日志,可以查看相關(guān)錯誤。
命令:cat /var/log/massages
cat /var/log/rsyncd.log
相關(guān)文章
DELL R730服務器配置RAID與安裝服務器系統(tǒng)以及域的控制詳細圖文教程
這篇文章主要為大家分享一下DELL R730服務器配置RAID與安裝服務器系統(tǒng)以及域的控制的圖文教程,需要的朋友可以參考下2021-03-03SVN無法提交出現(xiàn) Can''t set file "/db/txn_current" read-write :拒絕訪問
這篇文章主要介紹了SVN無法提交出現(xiàn) Can't set file "/db/txn_current" read-write :拒絕訪問的相關(guān)資料,需要的朋友可以參考下2016-12-12windows下文件同步工具 CwRsync 4.0.2 安裝配置方法(圖文)
這篇文章主要介紹了CwRsync 4.0.2 安裝配置方法,需要的朋友可以參考下2015-01-01windows服務器之win2003,win2008R2,win2012,win2016,win2019系統(tǒng)版本區(qū)別
windows服務器版有window2003,windows server2008,windows server2012 R2,windows server2016,windows 2019他們有什么不同,如何選擇適合自己的服務器系統(tǒng),需要的朋友可以參考下2020-02-02