安装
yum install rsync
mkdir /etc/rsyncd
cd /etc/rsyncd
vi rsyncd.conf
pid file = /var/run/rsyncd.pid uid = root gid = root use chroot = no read only = yes #limit access to private LANs hosts allow=192.168.1.2/32,127.0.0.1/32 hosts deny=* max connections = 5 motd file = /etc/rsyncd/rsyncd.motd #This will give you a separate log file log file = /var/log/rsync.log #This will log every file transferred - up to 85,000+ per user, per sync transfer logging = yes log format = %t %a %m %f %b syslog facility = local3 timeout = 300 [ftp_home] path = /ftp_data/ftp_dir list=yes ignore errors auth users = ftpuser #secrets file = /etc/rsyncd/rsyncd.secrets comment = This is test data
启动服务
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf
关闭服务
kill `cat /var/run/rsyncd.pid`
查看服务
tail /var/log/rsync.log ps aux|grep rsync netstat -apn|grep 873
加入开机启动
echo "/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf" >> /etc/rc.local
同步数据
rsync --list-only ftpuser@127.0.0.1::ftp_home rsync -ave ssh root@127.0.0.1:/ftp_data/test1 .
注意server密码文件是"用户名:密码",客户端那边只用"密码"。两边都需要chmod 600 rsyncd.secrets
rsync -rtvzPL --include-from=rsync_include.lst --password-file=/etc/rsyncd.secrets /source_rsync/ gameserverlog@192.168.0.1::game_server_log_rsync vi rsync_include.lst + itemdata*.txt + data*.txt - *
查看服务器列表
rsync --list-only --password-file=rsyncd.secrets gameserverlog@192.168.0.1::gmweb_log_rsync
服务器配置文件
vi /etc/rsyncd.conf
[gmweb_log_rsync] comment = public archive path = /data/log/test1_vn lock file = /var/lock/log_rsyncd read only = no list = yes uid = jslog gid = jslog auth users =gameserverlog secrets file = /etc/rsyncd.secrets hosts allow=192.168.1.1 hosts deny =* timeout = 600 refuse options = checksum dry-run