天天看点

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

继续阅读