1.修改配置文件,增加两个模块
[root@rsync-A ~]# cat /etc/rsyncd.conf
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_liang
secrets file = /etc/rsync.password
[liang]
path = /liang1/
[liang2]
path = /liang2/
[liang3]
path = /liang3/
2.创建目录,授权
[root@rsync-A ~]# mkdir /liang2 /liang3
[root@rsync-A ~]# chown rsync.rsync /liang2
[root@rsync-A ~]# chown rsync.rsync /liang3
3.重启rsync服务
[root@rsync-A ~]# /etc/init.d/rsyncd restart
rsync restart ... [ OK ]
4.测试
4.1查看客户端/data1目录
[root@rsync-B ~]# ll /data1
total 0
-rw-r--r-- 1 500 500 0 Jul 22 22:47 a
-rw-r--r-- 1 root root 0 Jul 23 03:43 a.txt
-rw-r--r-- 1 500 500 0 Jul 22 22:47 b
-rw-r--r-- 1 root root 0 Jul 23 03:43 b.txt
-rw-r--r-- 1 500 500 0 Jul 22 22:47 c
-rw-r--r-- 1 root root 0 Jul 23 03:43 c.txt
-rw-r--r-- 1 500 500 0 Jul 22 22:47 d
-rw-r--r-- 1 root root 0 Jul 23 03:43 d.txt
4.2将/data1推送到服务端模块liang2
[root@rsync-B ~]# rsync -avz /data1/ rsync_liang@10.0.0.129::liang2 --password-file=/etc/rsync.password
sending incremental file list
./
a
a.txt
b
b.txt
c
c.txt
d
d.txt
sent 393 bytes received 163 bytes 1112.00 bytes/sec
total size is 0 speedup is 0.00
服务端查看模块liang2的目录
[root@rsync-A ~]# ll /liang2
total 0
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 a
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 a.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 b
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 b.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 c
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 c.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 d
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 d.txt
4.3将/data1推送到服务端模块liang3
[root@rsync-B ~]# rsync -avz /data1/ rsync_liang@10.0.0.129::liang3 --password-file=/etc/rsync.password
sending incremental file list
./
a
a.txt
b
b.txt
c
c.txt
d
d.txt
sent 393 bytes received 163 bytes 1112.00 bytes/sec
total size is 0 speedup is 0.00
到服务端查看模块liang3的目录
[root@rsync-A ~]# ll /liang3
total 0
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 a
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 a.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 b
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 b.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 c
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 c.txt
-rw-r--r-- 1 rsync rsync 0 Jul 22 22:47 d
-rw-r--r-- 1 rsync rsync 0 Jul 23 03:43 d.txt