rsync 是個優秀的資料同步工具,通過先進的校驗算法,能夠比較檔案差別,實作增量傳輸,進而減少資料傳輸量。
環境:centos 6.3 x64
服務端:192.168.1.2
用戶端:192.168.1.3
安裝服務端
- yum install rsync
建立配置檔案/etc/rsyncd.conf
- uid = nobody
- gid = nobody
- use chroot = no
- max connections = 512
- log file = /var/log/rsyncd.log
- pid file = /var/run/rsyncd.pid
- lock file = /var/run/rsyncd.lock
- [download]
- path=/download/
- ignore errors = yes
- read only= yes
- list = no
- auth users = admin
- secrets file =/etc/rsyncd.passwd
- hosts allow = 192.168.0.0/16
根據上文,建立密碼檔案
- echo admin:2w3e4r5t > /etc/rsyncd.passwd
- 這裡要求使用者名和密碼
啟動服務端
- rsync --daemon
至此,服務端配置完畢(記得在防火牆上開啟873端口)
在另一台機器安裝用戶端
- yum install rsync
建立密碼檔案
- echo 2w3e4r5t > /etc/rsyncd.passwd
- 這裡隻需要密碼
- rsync -avz --delete --password-file=/etc/rsyncd.passwd [email protected]::download /download/