天天看點

rsync服務自動部署

#服務端:192.168.15.127

1、建立配置檔案

vim /etc/rsyncd.conf

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log

read only = no

max connections = 50

use chroot = yes

[mysql]

hosts allow = 192.168.15.0/24

path=/tmp/

uid = root

gid = root

secrets file=/etc/rsyncd.passwd

2、密鑰檔案/etc/rsyncd.passwd

echo "backup:123456" >>/etc/rsyncd.passwd

chmod 600 /etc/rsyncd.passwd

3、啟動

rsyncd --daemon

#centos6.4

rsync --daemon

#用戶端設定192.168.15.12

1、密鑰設定

echo "123456" >>/etc/rsyncd.passwd

2、推送檔案

rsync -vzrtopg /etc [email protected]::mysql --password-file=rsyncd.passwd

3、拉檔案

rsync -vzrtopg [email protected]::mysql /tmp/ --password-file=rsyncd.passwd

***************************

排除故障

1.@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)

這是因為密碼設錯了, 無法登入成功, 請檢查一下 rsyncd.scrt 中的密碼, 二端是否一緻?

2.password file must not be other-accessible

continuing without password file

Password:

這表示 rsyncd.scrt 的檔案權限屬性不對, 應設為 600。

3.@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)   

這通常是您的 rsyncd.conf 中的 path 路徑所設的那個目錄并不存在所緻.請先用 mkdir開設好要備份目錄

4.@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)

最後原因終于找到了。因為有兩個網段都需要同步該檔案夾内容,但沒有在hosts allow 後面添加另一個IP段

hosts allow = 192.168.1.0/24

改為

hosts allow = 192.168.1.0/24 192.168.2.0/24

重新啟動rsync服務,問題解決

5.rsync: failed to connect to 172.21.50.8: No route to host (113)

rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]

對方沒開機、防火牆阻擋、通過的網絡上有防火牆阻擋,都有可能。關閉防火牆,其實就是把tcp udp 的873端口打開

啟動服務:rsync --daemon --config=/etc/rsyncd.conf

6.@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指令的時候,加了這個參數--password-file=/etc/rsync.scrt

7.rsync: recv_generator: mkdir "/teacherclubBackup/rsync……" failed: No space left on device (28)

*** Skipping any contents from this failed directory ***

磁盤空間滿了

8.rsync: opendir "/kexue" (in dtsChannel) failed: Permission denied (13)

同步目錄的權限設定不對,改為755

繼續閱讀