1.环境
server:eth0 192.168.4.44
client:eth0 192.168.4.150
[root@master ~]# yum install -y xinetd rsync [root@master ~]# /etc/init.d/xinetd start [root@Nodes01 ~]# yum install -y xinetd rsync [root@Nodes01 ~]# /etc/init.d/xinetd start
2.rsync服务端配置
/etc/rsyncd.conf内容如下
uid=root gid=root use chroot=no max connections=10 strict modes=yes #同步目录 [rsync] path=/data03/rsync/ ignore errors read only=no list=no #用户 auth users=user #密码文件位置 secrets file=/etc/rsync.pass hosts allow=192.168.4.0/255.255.255.0 pid file=/var/run/rsyncd.pid lock file=/var/run/rsync.lock log file=/var/log/rsyncd.log
/etc/rsync.pass内容如下
user:12345678
开启程序
[root@master ~]# rsync --daemon --config=/etc/rsyncd.conf &
3.客户端配置使用
密码文件/etc/rsync.pass内容如下
12345678
验证同步文件
将server上rsync目录内容同步到客户端
[root@Nodes01 ~]# rsync -auzv --progress --delete --password-file=/etc/rsync.pass user@192.168.4.44::rsync /opt/nodes01/rsync/ receiving incremental file list ./ rsync.txt 15 100% 14.65kB/s 0:00:00 (xfer#1, to-check=0/2) sent 77 bytes received 173 bytes 500.00 bytes/sec total size is 15 speedup is 0.06
将client的/opt/test内容同步到server上的rsync
[root@Nodes01 opt]# rsync -auzv --progress --delete --password-file=/etc/rsync.pass /opt/test/ user@192.168.4.44::rsync sending incremental file list ./ deleting tests.txt deleting rsync.txt nginx-1.4.2.tar.gz 767688 100% 12.30MB/s 0:00:00 (xfer#1, to-check=1/3) rpmforge-release-0.5.2-1.el6.rf.i686.rpm 12376 100% 177.73kB/s 0:00:00 (xfer#2, to-check=0/3) sent 780514 bytes received 49 bytes 1561126.00 bytes/sec total size is 780064 speedup is 1.00
由于以上是明文传输的,现在来看看基于ssh方式
[root@Nodes01 opt]# rsync -av root@192.168.4.44:/data03/rsync /opt/nodes01/rsync/ root@192.168.4.44's password: receiving incremental file list rsync/ rsync/ip-tun.sh rsync/ip_forward~ rsync/ipp.txt rsync/ipvs.sh rsync/ipvsadm.sh sent 110 bytes received 957 bytes 304.86 bytes/sec total size is 617 speedup is 0.58