rsync的配置環境
軟體平台:windows2003
軟體版本:cwRsync_2.0.10_Installer cwRsync_Server_2.0.10_Installer
硬體平台:dell2950 cpu1.6G*4 記憶體:4G 硬碟:1G*6 RAID5
===安裝===
在WINDOWS環境下安裝rsync要安裝服務端和用戶端
伺服器端安裝:運行cwRsync_Server_2.0.10_Installer
用戶端安裝:運行cwRsync _2.0.10_Installe
安裝步驟和安裝伺服器端是一樣的這裡就不詳細描述
===配置===
配置和我們在linux下面的配置一樣,在安裝目錄中找到rsync.conf檔案進行配置:
Rsync.conf檔案:
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
uid = administrator
gid = administrator
use chroot = no
max connections =4
syslog facility = local5
[test]
path =/cygdrive/d/wlk
comment=/cygdrive/d/wlk comment = BACKUP CLIENT IS SOLARIS 8 E250
ignore errors # 可以忽略一些無關的IO錯誤
read only = yes # 唯讀
list = no # 不允許列檔案
auth users = inburst # 認證的使用者名稱,如果沒有這行,
則表明是匿名
secrets file = etc/inburst.pas # 認證檔案名稱
在server端產生一個密碼檔案etc/inburst.pas
開啟記事本
inburst:hack
儲存在安裝路徑下面的etc檔案加下面檔案明儲存為inburst.pas
在服務中把RsyncServer啟動,啟動類型修改為自動
這樣伺服器端就安裝設定好了
從client端進行測試
下面這個命令列中-vzrtopg裡的v是verbose,z是壓縮,r是recursive,topg都是保持檔案原有屬性如屬主、時間
的參數。–progress是指顯示
出詳細的進度情況,–delete是指如果伺服器端刪除了這一檔案,那麼用戶端也相應把檔案刪除,保持真正的一致。
後面的inburst@ip中,
inburst是指定密碼檔案中的使用者名稱,之後的::inburst這一inburst是模組名,也就是在/etc/rsyncd.conf中自訂
的名稱。最後的/tmp是備份
到本地的目錄名。
在這裡面,還可以用-e ssh的參數建立起加密的串連。可以用–password-file=/password/path/file來指定密碼文
件,這樣就可以在指令碼中使
用而無需互動式地輸入驗證密碼了,這裡需要注意的是這份密碼檔案許可權屬性要設得只有屬主可讀。
在用戶端運行CMD
rsync -av 10.0.0.16::401 /cygdrive/h/401
複製代碼 代碼如下:
@echo off
rsync -ztruvoglp --progress --delete --password-file=wtjb51.pas /cygdrive/f/webroot/jb51/ wtjb51@221.192.1.1::dddown
wtjb51.pas的內容
複製代碼 代碼如下:
jb51:www.jb51.net
jb51是使用者名稱,後面的是密碼
/cygdrive/f/webroot/jb51/中的f代表的是F盤,其它盤自行修改即可。
rsync使用時的常見問題
錯誤1: rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receive r=3.0.2]
解決:很大可能是伺服器端沒有開啟 rsync 服務。開啟服務。
錯誤2:@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:伺服器端同步處理目錄沒有許可權,cwrsync預設使用者是Svcwrsync。為同步目錄添加使用者Svcwrsync許可權。
錯誤3:@ERROR: failed to open lock file
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:設定檔 rsync.conf中添加 lock file = rsyncd.lock 即可解決。
錯誤4: rsync: could not open password file "/cygwin/e/Setting/Rsync/rsync_db.pwd": No such file or directory (2)
解決:密碼檔案的目錄一定要存在,而且要用POSIX風格的寫法:/cygdrive/e/Setting/Rsync/rsync_db.pwd
錯誤5:@ERROR: auth failed on module data_backup rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
解決:密碼錯誤,輸入正確的密碼即可。使用者名稱和密碼如果都正確,可能是遠程rsync伺服器的帳戶密碼檔案的許可權必須為600。
錯誤6: password file must not be other-accessible
解決:這是因為rsyncd.pwd rsyncd.sec的許可權不對,應該設定為600。如:chmod 600 rsyncd.pwd, Windows下應將密碼檔案的所有者改成程式啟動並執行使用者。
錯誤7:@ERROR: invalid uid nobody . rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
解決:在rsyncd.conf檔案中添加下面兩行即可
uid = 0
gid = 0
問題8: @ERROR: chroot failed
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:伺服器端的目錄不存在或無許可權。建立目錄並修正許可權可解決問題。
問題9:@ERROR: Unknown module ‘tee_nonexists'
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:伺服器不存在指定模組。提供正確的模組名或在伺服器端修改成你要的模組以解決問題。
問題10:rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
原因:對方沒開機、防火牆阻擋、通過的網路上有防火牆阻擋,都有可能。關閉防火牆,其實就是把tcp udp的873或者指定的rsync連接埠開啟。
問題11:rsync error: error starting client-server protocol (code 5) at main.c(1524) [Receiver=3.0.7]
原因:/etc/rsyncd.conf設定檔內容有錯誤。請正確核對設定檔。
問題12:rsync: chown "" failed: Invalid argument (22)
原因:許可權無法複製。去掉同步許可權的參數即可。(這種情況多見於Linux向Windows的時候)
問題13:@ERROR: daemon security issue -- contact admin
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]
原因:同步的目錄裡面有軟串連檔案,需要伺服器端的/etc/rsyncd.conf開啟use chroot = yes。掠過軟串連檔案。
問題14:rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receiver=3.0.2]
解決:很大可能是伺服器端沒有開啟 rsync 服務,開啟服務。
rsyncserver 服務啟動時報錯“rsyncserver服務啟動後又停止了。一些服務自動停止,如果它們沒有什麼可做的,例如“效能記錄檔及警示”服務。”
解決方案:將安裝目錄下的rsyncd.pid檔案刪除,再重新啟動RsyncServer服務。一般是異常關機導致的。