一,环境描述:

192.168.1.10  rsyncd服务端

192.168.1.2,192.168.1.3 rsyncd客户端


二,配置:

192.168.1.10 服务端配置:


1,rsyncd.conf 配置:

[root@localhost ~]# cat /etc/rsyncd.conf 

# write by Chris on 20140915

# rsync服务端配置文件


uid = www

gid = www

use chroot = no

max connections = 1024

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log

hosts allow = 192.168.1.2

hosts allow = 192.168.1.3


[test]

path = /www/test/

comment = test

ignore errors = true

read only = no

list = no

auth users = www

secrets file = /etc/rsync.pass


2,rsync.pass 文件属性和账号密码:


[root@localhost ~]# ll /etc/rsync.pass

-rw------- 1 root root 15 Sep 15 00:07 /etc/rsync.pass

[root@localhost ~]# cat /etc/rsync.pass

www:xvdaf+Ax8


192.168.1.2,192.168.1.3 客户端同步命令:

remoteip="192.168.1.10"

appName="test"

/usr/bin/rsync -avz --password-file=$HOME/.rsync.pas --exclude-from=exclude.txt www@${remoteip}::test /www/${appName}


执行结果:

192.168.1.3 客户端正常同步

192.168.1.2 客户端报错如下

rsync   www@${remoteip}::test  @ERROR: Unknown module 'test'  不认识我的模块


解决:

rsyncd.conf 文件

hosts allow = 192.168.1.2

hosts allow = 192.168.1.3

修改为

hosts allow = 192.168.1.2,192.168.1.3


即将允许客户端IP列表并排一行,使用逗号隔开,经验证同步正常。