> [root@localhost ~]# yum install rsync
> [root@localhost ~]# mkdir /etc/rsyncd         #创建配置目录
> [root@localhost ~]# touch /etc/rsyncd/rsyncd.conf              #创建主配置文件
> [root@localhost ~]# touch /etc/rsyncd/rsyncd.secrets          #创建用户密码文件
> [root@localhost ~]# chmod 600 /etc/rsyncd/rsyncd.secrets  #用户密码文件权限设置
> [root@localhost ~]# touch /etc/rsyncd/rsyncd.motd            #服务器欢迎信息
> root@localhost ~]# vim /etc/rsyncd/rsyncd.conf 
> # Minimal configuration file for rsync daemon 
> # See rsync(1) and rsyncd.conf(5) man pages for help
> # This line is required by the /etc/init.d/rsyncd script 
> pid file = /var/run/rsyncd.pid 
> port = 873   ##监听端口 
> address = 192.168.1.1  ##监听地址 
> #uid = nobody 
> #gid = nobody   
> uid = root 
> gid = root
> use chroot = yes   ##是否限制在指定目录,为了安装,一般需要启用 
> read only = no
> #limit access to private LANs 
> hosts allow=192.168.1.0/255.255.255.0   ##允许网段 
> 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
> ##定义一个同步目录
> [webhome] 
> path = /data
> list=yes 
> ignore errors 
> auth users = nobody 
> secrets file = /etc/rsyncd/rsyncd.secrets  ##指定上述账号密码文件 
> comment = web home
> exclude =   /web/   ##排除目录
> 编辑/etc/rsyncd/rsyncd.secrets文件:
> #Account and password 
> apache:password123
> 注意:这里账号虽然用的是系统账号,但是密码是自定义的密码。
> 
> 启动使rsync生效:
> [root@localhost ~]# /usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf 
> 
> 设置为开机启动:
> [root@localhost ~]# echo "/usr/bin/rsync --deamon --config=/etc/rsyncd/rsyncd.conf" >> /etc/rc.d/rc.local 
> 客户端安装同上,额外只需配置一个密码文件,具体如下:
> 
> 
> [root@localhost ~]# mkdir /etc/rsyncd
> [root@localhost ~]# echo "password123" > /etc/rsyncd/rsyncd.password   #创建密码文件,密码为服务器端rsyncd.secrets文件中的密码。
> [root@localhost ~]# chmod 600 /etc/rsyncd/rsyncd.password#一定是只读的,
> 同步:
> [root@localhost ~]# rsync -avzP --password-file=/etc/rsyncd/rsyncd.password apache@192.168.1.1::webhome  /var/www/html/

Source: xundaoinfo