rsync

环境1:客户端向服务器主动拿文件

服务器:
yum install rsync
mkdir -pv /etc/rsyncd
vim /etc/rsyncd/rsync.conf
uid=root
gid=root
port=873
max connections=0   #limit client conection
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
motd file = /etc/rsyncd/rsyncd.motd
read only=yes
####limit user conn######
hosts allow=192.168.18.0/255.255.255.0
hosts deny=*
#transfer logging = yes
#log format = %t %a %m %f %b
#syslog facility = local3
#timeout = 300
[www]
path = /var/www/html
list = yes
ignore errors
auth users = kyo 
###username
secrets file = /etc/rsyncd/rsyncd.secrets(存放用户密码的文件,不一定是系统用户)
comment = www directory
exclude = a/ b/   #####a,b directory not backup
vim rsyncd.motd
aaaaaa
vim rsyncd.secrets
kyo:123
chmod 600 rsyncd.secrets
rsync --daemon –config=/etc/rsyncd/rsyncd.conf
lsof -i:873
客户端:
echo 123 > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd
mkdir -pv /tmp/www
rsync -avzP --delete --password-file=/etc/rsync.passwd [email protected]::www /tmp/www

环境2:服务器主动推送

服务器:
tar fvxz sersync.tar.gz
cd GNU-Linux-x86/sersync2
vim confxml.xml修改如下的参数
<sersync>
        <localpath watch="/tmp/www">
            <remote ip="192.168.18.105" name="www"/>
<commonParams params="-artuz"/>
           <auth start="true" users="kyo" passwordfile="/etc/rsync.pas"/>
<failLog path="/tmp/rsync_fail_log" timeToExecute="60"/>

vim /etc/rsync.pas
123
chmod 600 /etc/rsync.pas
./sersync2 -r
客户端:
echo 'kyo:123' > /etc/rsyncd/rsyncd.secrets
chmod 600 /etc/rsyncd/rsyncd.secrets
vim /etc/rsyncd/rsyncd.conf
uid=root
gid=root
port=873
max connections=0
use chroot = no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

motd file = /etc/rsyncd/rsyncd.motd
####limit user conn######
hosts allow=192.168.18.0/255.255.255.0
hosts deny=*

[www]
path = /tmp/www
list = yes
ignore errors
auth users = kyo
secrets file = /etc/rsyncd/rsyncd.secrets
comment = www directory
read only = no

rsync --daemon --config=/etc/rsyncd/rsyncd.conf
lsof -i:873

本文出自 “海纳百川” 博客,谢绝转载!

你可能感兴趣的:(rsync)