天天看點

rsync 資料同步

rsync 是個優秀的資料同步工具,通過先進的校驗算法,能夠比較檔案差別,實作增量傳輸,進而減少資料傳輸量。

 環境:centos 6.3 x64

服務端:192.168.1.2

用戶端:192.168.1.3

安裝服務端

  1. yum install rsync 

建立配置檔案/etc/rsyncd.conf

  1. uid = nobody 
  2. gid = nobody 
  3. use chroot = no 
  4. max connections = 512 
  5. log file = /var/log/rsyncd.log 
  6. pid file = /var/run/rsyncd.pid 
  7. lock file = /var/run/rsyncd.lock 
  8. [download] 
  9. path=/download/ 
  10. ignore errors = yes 
  11. read only= yes 
  12. list = no 
  13. auth users = admin 
  14. secrets file =/etc/rsyncd.passwd 
  15. hosts allow = 192.168.0.0/16 

根據上文,建立密碼檔案

  1. echo admin:2w3e4r5t > /etc/rsyncd.passwd 
  2. 這裡要求使用者名和密碼 

啟動服務端

  1. rsync --daemon 

至此,服務端配置完畢(記得在防火牆上開啟873端口)

在另一台機器安裝用戶端

  1. yum install rsync  

建立密碼檔案

  1. echo 2w3e4r5t > /etc/rsyncd.passwd  
  2. 這裡隻需要密碼 
  1. rsync -avz --delete --password-file=/etc/rsyncd.passwd [email protected]::download /download/ 

繼續閱讀