Server setup
0)vi
/etc/xinetd.d/rsync
and ensure following:
disable = no
1)vi /etc/rsyncd.conf
--------------
uid = nobody
gid = nobody
use chroot = no
max connections = 50
port = 873
address = 0.0.0.0
log file =
/var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
#hosts allow = 1.2.3.123/32
[main]
path =
/data/upload
comment = main server data
dir
read only = yes
dont compress =
*.gz *.tgz *.zip *.z *.bz2 *.tbz
auth users = imguser
secrets file = /etc/rsyncd.users
*************************
2)
echo ‘imguser:1234‘
>> /etc/rsyncd.users
chmod 600
/etc/rsyncd.users #important!can‘t use 777 or 700,otherwise will
happen---auth failed on module
3)
yum -y install xinetd
chkconfig xinetd on
chkconfig sshd on
service xinetd
restart
service sshd restart
netstat
-ano|grep :873
4)
setsebool -P rsync_disable_trans
on
*************
Client setup
rsync -avz
imguser@10.68.229.204::cms /data/upload/
vi
/data/run.rsync.cms
#!/bin/bash
if [ `netstat -anp | grep rsync | wc
-l` -gt 0
] ; then
echo "Prev rsync still running. Skip now.
`date`" >> /var/log/rsyncd-messages.log
exit
1
else
RDIR=‘main/‘
LDIR=‘/data/upload/‘
RADD=‘10.68.229.204‘
BAKUSER=‘imguser‘
PROG=‘/usr/bin/rsync‘
OPTIONS=‘-arHvz
--checksum‘
export RSYNC_PASSWORD=‘1234‘
$PROG $OPTIONS
$BAKUSER@$RADD::$RDIR $LDIR
fi
6)
crontab -e
#sync
every 5 seconds.
*/1 * * * * sleep 5 &&
/data/run.rsync.cms
refer: http://m.oschina.net/blog/91042
原文:http://www.cnblogs.com/youcanwin/p/3571334.html