上接前文,前文提到web服务器附件不同步的问题,这里补上文件同步的配置。安装同步软件# 安装同步服务所需的软件yum -y install rsync配置密码本mkdir -p /etc/rsyncfg/# 注意:下面的两个SyncPwd必须一致echo ‘SyncName:SyncPwd’ > /etc/rsyncfg/server.pwdecho ‘SyncPwd’ > /etc/rsyncfg/client.pwd# 密码文件配置权限chmod 600 /etc/rsyncfg/server.pwdchmod 600 /etc/rsyncfg/client.pwd配置防火墙端口# 开启防火墙端口firewall-cmd –zone=public –add-port=873/tcp –permanentfirewall-cmd –reload配置同步软件# 编辑配置文件vim /etc/rsyncd.conf# 配置文件内容uid = rootgid = rootuse chroot = yesmax connections = 4exclude = lost+found/transfer logging = yestimeout = 900ignore nonreadable = yesdont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2[uploads]path = /home/wwwroot/PublishPath/uploadscomment = Host:192.168.6.100 uploads filesignore errorsread only = yeswrite only = nolist = noauth users = syncersecrets file = /etc/rsyncfg/server.pwdhosts allow = 192.168.6.110重启服务service rsyncd restart && service rsyncd status执行同步操作echo ’’ > /etc/rsyncfg/sync.logecho ‘rsync -auv –password-file=/etc/rsyncfg/client.pwd SyncName@192.168.6.100::uploads /home/wwwroot/PublishPath/uploads/’ > /etc/rsyncfg/sync.shchmod +x /etc/rsyncfg/sync.shcp /etc/rsyncfg/sync.sh /usr/sbin/配置计划任务crontab -e# 添加任务# * * * * * /etc/rsyncfg/sync.sh # 取消前面的注释即可# 重启定时任务服务service crond restart && service crond status问题汇总ERROR: auth failed on module XXX@ERROR: auth failed on module XXXrsync error: error starting client-server protocol (code 5) at main.c(xxx) [Receiver=x.x.x]1、密码输入错误:请再次确认你登录用户的密码无误2、secrets file格式错误:secrets file的文件格式是 upload:123456表示upload用户的rsync密码是1234563、配置文件写错:最坑爹的一个,看看自己模块配置下面的auth users、secrets file有没写错4、secrets file权限问题服务端的secrets file权限必须是600,可以使用chmod 600 /home/user/test/rsync/etc/test.pass5、secrets file文件拥有者与rsync运行者服务端rsync服务是以什么用户运行,则必须保证secrets file文件拥有者必须是同一个假设root运行rsync –daemon,则secrets file的owner也必须是root6、如果是以–password-file=file的方式附带密码确保客户端密码文件格式无误,与服务端的密码文件不同,客户端的不用加上用户名,即直接是 123456rsync: failed to connect to X.X.X.X Connection timed out (110)rsync: failed to connect to 192.168.6.100 (192.168.6.100): Connection timed out (110)rsync error: error in socket IO (code 10) at clientserver.c(125) [Receiver=3.1.2]端口不通,开启防火墙的873端口:firewall-cmd –zone=public –add-port=873/tcp –permanentfirewall-cmd –reloadERROR: password file must not be other-accessibleERROR: password file must not be other-accessiblersync error: syntax or usage error (code 1) at authenticate.c(196) [Receiver=3.1.2]密码本权限不对:chmod 600 /etc/rsyncfg/server.pwdchmod 600 /etc/rsyncfg/client.pwd