今天在rsync同步的时候一直报错,报错内容如下:
@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段,而是另外添加一个配置如下:
[www]
path = /data/cms/webapp
hosts allow = 192.168.1.0/24
auth users = webapp
secrets file = /etc/app.pass
#[www]
#path = /data/cms/webapp
#hosts allow = 192.168.2.0/24
#auth users = webapp
#secrets file = /etc/app.pass
这样更改后导致前一段配置(也就是没有#号的一段)没有生效,服务器就只允许192.168.2.0网段同步。
解决方法如下:
将后一段注释或者直接删掉,在上一段的 hosts allow 后添加192.168.2.0 网段,结果如下
[www]
path = /data/cms/webapp
hosts allow = 192.168.1.0/24 192.168.2.0/24
auth users = webapp
secrets file = /etc/app.pass
重新启动rsync服务,问题解决。
网上总结rsync报错信息:
Rsync同步常见问题:
错误一:
@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 服务也会出现这种情况。
错误二:
password file must not be other-accessible
continuing without password file
Password:
解决:这是因为rsyncd.pwd rsyncd.sec的权限不对,应该设置为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]
解决:对方没开机、防火墙阻挡、通过的网络上有防火墙阻挡,都有可能。关闭防火墙,其实就是把tcp udp 的873端口打开。