Linux下架設rsync伺服器

來源:互聯網
上載者:User

Linux下架設rsync伺服器  rsync 是一個Unix系統下的檔案同步和傳輸工具。rsync是用 “rsync 演算法”提供了一個客戶機和遠程檔案伺服器的檔案同步的快速方法。Some features of rsync includersync 包括如下的一些特性:* can update whole directory trees and filesystems能更新整個目錄和樹和檔案系統;* optionally preserves symbolic links, hard links, file ownership, permissions, devices and times有選擇性的保持符號鏈鏈、永久連結、檔案屬於、許可權、裝置以及時間等;* requires no special privileges to install對於安裝來說,無任何特殊許可權要求;* internal pipelining reduces latency for multiple files對於多個檔案來說,內部流水線減少檔案等待的延時;* can use rsh, ssh or direct sockets as the transport能用rsh、ssh 或直接連接埠做為傳輸入連接埠;* supports anonymous rsync which is ideal for mirroring支援匿名rsync 同步檔案,是理想的鏡像工具; 安裝配置過程:一。建相應的檔案及檔案夾[root@estals60:~]#mkdir /etc/rsyncd  --在/etc目錄下建立一個rsyncd的目錄,我們用來存放rsyncd.conf 和rsyncd.secrets檔案;[root@estals60:~]#touch /etc/rsyncd/rsyncd.conf  --建立rsyncd.conf ,這是rsync伺服器的設定檔;[root@estals60:~]#touch /etc/rsyncd/rsyncd.secrets --建立rsyncd.secrets ,這是使用者密碼檔案;[root@estals60:~]#chmod 600 /etc/rsyncd/rsyncd.secrets  --為了密碼的安全性,我們把許可權設為600;[root@estals60:~]#ls -lh /etc/rsyncd/rsyncd.secrets-rw------- 1 root root 14 2007-07-15 10:21 /etc/rsyncd/rsyncd.secrets[root@estals60:~]#touch /etc/rsyncd/rsyncd.motd 二。 修改 rsyncd.conf 和rsyncd.secrets 和rsyncd.motdrsyncd.conf 是rsync伺服器主要設定檔,我們來個簡單的樣本;比如我們要備份伺服器上的 /nsn_talko_production/talko/var/www/html/Talko/talko.next/repository/ # Minimal configuration file for rsync daemon# See rsync(1) and rsyncd.conf(5) man pages for help# This line is required by the /etc/init.d/rsyncd scriptpid file = /var/run/rsyncd.pidport = 873address = estals60#uid = nobody#gid = nobodyuid = rootgid = rootuse chroot = yesread only = yes#limit access to private LANshosts allow=* #192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0#hosts deny=*max connections = 5motd file = /etc/rsyncd/rsyncd.motd #This will give you a separate log file#log file = /var/log/rsync.log#This will log every file transferred - up to 85,000+ per user, per sync#transfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300[P_repositor]path = /nsn_talko_production/talko/var/www/html/Talko/talko.next/repository/list=yes      --list 意思是把rsync 伺服器上提供同步資料的目錄在伺服器上模組是否顯示列出來。預設是yes 。如果你不想列出來,就no ;如果是no是比較安全的,至少別人不知道你的伺服器上提供了哪些目錄。你自己知道就行了ignore errors                               --忽略IO錯誤auth users = root                           --使用者帳號 (這個必須得是系統中已經存在的帳號)secrets file = /etc/rsyncd/rsyncd.secrets   --存放密碼的地方comment = P_repositor          --相當於是一種介面名字,等服務跑起來了用戶端可以直接用這名字調用相關伺服器的檔案夾內容資訊#exclude =   beinan/  samba/    --無視這兩個檔案夾的內容 rsyncd.secrets的內容如下類似root:123456yofee:123456 rsyncd.motd 檔案它是定義rysnc 伺服器資訊的,也就是使用者登入資訊。比如讓使用者知道這個伺服器是誰提供的等.++++++++++++++++++++++++++++ Yofee Packages rsync    ++++++++++++++++++++++++++++ 三、啟動rsync伺服器[root@estals60:~]#/usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf 四、防火牆的設定[root@estals60:~]#iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT[root@estals60:~]#iptables -L  查看一下防火牆是不是開啟了 873連接埠; 五、執行同步命令rsync -avzP root@estals60::P_repositor /nsn_talko/talko/var/www/html/Talko/talko.next/這時會要求輸入root的密碼,然後就沒啥問題了。另外其實也可以考慮把他建在系統任務裡面定時運行。道理都是一樣的,用crontab,這裡就不再重述了。 ######################uid = nobodygid = nobodyuse chroot = noread only = falsemax connections = 5port = 873motd file = /etc/rsyncd/rsyncd.motdpid file = /tmp/rsyncd.pidlock file = /tmp/rsync.locklog format = %t %a %m %f %blog file = /tmp/rsyncd.logtimeout = 300[update]path = /data/autoupdate/ignore errors = yeslist = falsecomment = updatesecrets file = /etc/rsyncd/rsyncd.secretshosts allow = *#hosts deny = 0.0.0.0/32########################################### 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.