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 [email protected]::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/ [email protected]::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 [email protected]:/data03/rsync /opt/nodes01/rsync/ [email protected]'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