1. 程式人生 > >中小型規模網站集群架構:Rsync錯誤集

中小型規模網站集群架構:Rsync錯誤集

中小型規模網站集群架構:rsync錯誤集

常見問題

3.1.1 rsync服務端排錯思路

查看rsync服務配置文件路徑是否正確,正確的默認路徑為:/etc/rsyncd.conf
查看配置文件裏host allow,host deny,允許的IP網段是否是允許客戶端訪問的IP網段。
查看配置文件中path參數裏的路徑是否存在,權限是否正確(正常應為配置文件中的UID參數對應的屬主和組)
查看rsync服務是否啟動。查看命令為:ps -ef | grep rsync。端口是否存在netstat -plunt| grep 873
查看iptables防火墻和selinux是否開啟允許rsync服務通過,也可考慮關閉。
查看服務端rsync配置的密碼文件是否為600的權限,密碼文件格式是否正確,正確格式用戶名:密碼,文件路徑和配置文件裏的secrect files參數對應。

如果是推送數據,要查看下,配置rsyncd.conf文件中用戶是否對模塊下目錄有可讀寫的權限。

3.1.2 rsync客戶端排錯思路

查看客戶端rsync配置的密碼文件是否為600的權限,密碼文件格式shfou 正確,註意:僅需要有密碼,並且和服務端的mima 一直
用telnet鏈接rsync服務器IP地址873查看服務是否啟動(可測試服務端防火墻是否阻擋)
客戶端執行命令是rsync -avz /etc/hosts [email protected]::backup
此命令的細節要記清楚,尤其是雙冒號

3.2 No route to host問題

[[email protected]
/* */ ~]# rsync -avz /etc/hosts [email protected]::backup rsync: failed to connect to 172.16.1.41: No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(124) [sender=3.0.6]

解決方案
服務端關閉防火墻

3.3 執行命令錯誤導致的報錯

[[email protected] ~]# rsync -avz /etc/hosts [email protected]
/* */::/backup ERROR: The remote path must start with a module name not a / rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]

解決:
rsync命令語法理解錯誤:/backup 必須是模塊,也就是不能“/”

3.4 @ERROR: auth failed on module backup

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backup
Password: 
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
[[email protected] ~]#

解決:
1.賬號rsync_backup或者密碼123456錯誤了。
2.指定的密碼文件和實際的名稱不一致。
secrets file = /etc/rsync.password
3.密碼文件的權限忘記改為600
4.密碼文件多了一個空格。 vi時候用set list或者用cat -A

3.5 @ERROR: Unknown module ‘backupa‘

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backupa
@ERROR: Unknown module ‘backupa‘
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
[[email protected] ~]#

解決:
文件的模塊和命令的模塊不匹配

3.6 權限問題

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backup
Password: 
sending incremental file list
rsync: ERROR: cannot stat destination "." (in backup): Permission denied (13)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(554) [receiver=3.0.6]
rsync: connection unexpectedly closed (5 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]


解決:

共享目錄的屬主和屬組不正確,不是rsync

共享目錄的權限不正確。不是755

3.7 沒有創建對應的目錄

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backup
Password: 
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]

解決:
看配置文件的目錄和創建的目錄是否對應(相同)
或者目錄沒有創建

3.8 ID或者用戶組和用戶組不存在

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backup
Password: 
@ERROR: invalid uid rsync
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]

解決:
創建rsync目錄

3.9 客戶端已經配置了密碼文件,但免密鑰登錄方式,依舊需要輸入密碼

[[email protected] ~]# rsync -avz /etc/hosts [email protected]::backup --password-file=/etc/rsync.password 
password file must not be other-accessible
continuing without password file
Password: 
sending incremental file list
hosts
rsync: mkstemp ".hosts.xWBidH" (in backup) failed: Permission denied (13)
 
sent 196 bytes  received 27 bytes  89.20 bytes/sec
total size is 349  speedup is 1.57
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]

解決:
客戶端的密碼文件權限不是600
chmod 600 /etc/rsync.password

3.10 傳輸慢

看日誌文件

2017/03/08 20:15:49 [25053] params.c:Parameter() - Ignoring badly formed line in configuration file: ignore errors
2017/03/08 20:15:49 [25053] name lookup failed for 172.16.1.31: Name or service not known
2017/03/08 20:15:49 [25053] connect from UNKNOWN (172.16.1.31)
2017/03/08 20:15:49 [25053] rsync to backup/ from [email protected] (172.16.1.31)
2017/03/08 20:15:49 [25053] receiving file list
2017/03/08 20:15:49 [25053] rsync: mkstemp ".hosts.q63Fzr" (in backup) failed: Permission denied (13)
2017/03/08 20:15:49 [25053] sent 173 bytes  received 253 bytes  total size 349

解決:
配置本地域名解析/etc/hosts

172.16.1.31  nfs01

修改後

2017/03/08 20:17:46 [25056] params.c:Parameter() - Ignoring badly formed line in configuration file: ignore errors
2017/03/08 20:17:46 [25056] connect from nfs01 (172.16.1.31)
2017/03/08 20:17:46 [25056] rsync to backup/ from [email protected] (172.16.1.31)
2017/03/08 20:17:46 [25056] receiving file list
2017/03/08 20:17:46 [25056] rsync: mkstemp ".hosts.CmOBRm" (in backup) failed: Permission denied (13)
2017/03/08 20:17:46 [25056] sent 173 bytes  received 253 bytes  total size 349

3.11 客戶端目錄權限644+rsync使用了avz參數

推送之後會給服務端的/backup目錄修改權限。使服務端權限變成644導致傳輸失敗。

sh [[email protected] ~]# echo 123456>/etc/rsync.password ash: 123456: Bad file descriptor


3.12

問題,服務沒啟動

[[email protected] scripts]# rsync -avz /etc/hosts [email protected]::allbackup
rsync: failed to connect to 172.16.1.41: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(124) [sender=3.0.6]

解決:
rsync --daemon

未知錯誤

[[email protected] scripts]# rsync -az -delete  /data/   [email protected]::nfsbackup --password-file=/etc/rsync.password
rsync: Failed to exec lete: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

解決:重新寫一下命令,就OK?

本文出自 “小菜鳥” 博客,請務必保留此出處http://baishuchao.blog.51cto.com/12918589/1948091

中小型規模網站集群架構:Rsync錯誤集