欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用rsync實(shí)現(xiàn)windows與linux文件同步的方法

 更新時(shí)間:2011年02月21日 20:30:18   作者:  
windows做為文件服務(wù)器,使用rsync的windows服務(wù)版本,然后配置好就可以了。需要的朋友可以參考下。
windows做為文件服務(wù)器,使用rsync的windows服務(wù)版本:cwRsyncServer 下載地址:http://rsync.samba.org

安裝過(guò)程要設(shè)置用于系統(tǒng)服務(wù)的帳號(hào)和密碼,可以默認(rèn)。
注:此帳號(hào)用于啟用crsync server服務(wù),需要分配給帳號(hào)對(duì)要同步文件的相應(yīng)權(quán)限,否則無(wú)法操作被同步的文件。

安裝完成后修改配置文件 rsyncd.conf, 配置文件內(nèi)容如下:
復(fù)制代碼 代碼如下:

port = 52326
use chroot = false
strict modes = false
#hosts allow = * #允許所有的訪(fǎng)問(wèn)
hosts allow = 192.168.10.2 #指定特定的IP允許訪(fǎng)問(wèn)
log file = rsyncd.log
lock file = rsyncd.lock
max connections = 10
UID = 0
GID = 0
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/c/work
read only = false
transfer logging = no

[test2]
path = /cygdrive/d/wwwroot/yanghengfei_com
read only = yes
transfer logging = no
auth users = coldstar #同步使用的帳號(hào)
secrets file = rsyncd.secrets #密碼文件

注:
rsyncd.secrets配置文件的格式為 用戶(hù)名:密碼,如:
coldstar:123456

即添加了一個(gè)用戶(hù) coldstar,密碼為 123456。

Linux服務(wù)器上執(zhí)行同步命令:

rsync -vzrtopg --progress --delete rsync://coldstar@192.168.10.1:52326/test2 /root/test2

然后在password: 提示符下輸入密碼即可。

也可以把密碼寫(xiě)入配置文件引用,如:
rsync -vzrtopg --progress --delete --password-file=/etc/rsync.pass rsync://coldstar@192.168.10.1:52326/test2 /www/users/yanghengfei_com

將以上命令寫(xiě)入計(jì)劃任務(wù),每1分鐘執(zhí)行,即可實(shí)現(xiàn)實(shí)時(shí)同步的效果。

注:
上面這個(gè)命令行中-vzrtopg里的v是verbose,z是壓縮,r是recursive,topg都是保持文件原有屬性如屬主、時(shí)間的參數(shù)。-- progress是指顯示出詳細(xì)的進(jìn)度情況,--delete是指如果服務(wù)器端刪除了這一文件,那么客戶(hù)端也相應(yīng)把文件刪除,保持真正的一致。

附,rsync使用時(shí)的常見(jiàn)問(wèn)題:

錯(cuò)誤1: 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]
解決:很大可能是服務(wù)器端沒(méi)有開(kāi)啟 rsync 服務(wù)。開(kāi)啟服務(wù)。 或者開(kāi)啟了防火墻指定的端口無(wú)法訪(fǎng)問(wèn)。

錯(cuò)誤2:@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:服務(wù)器端同步目錄沒(méi)有權(quán)限,cwrsync默認(rèn)用戶(hù)是Svcwrsync。為同步目錄添加用戶(hù)Svcwrsync權(quán)限。

錯(cuò)誤3:@ERROR: failed to open lock file
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2]
解決:服務(wù)器端配置文件 rsyncd.conf中添加 lock file = rsyncd.lock 即可解決。

錯(cuò)誤4:@ERROR: invalid uid nobody
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.2]
解決:在rsyncd.conf文件中添加下面兩行即可解決問(wèn)題
UID = 0
GID = 0

錯(cuò)誤5:@ERROR: auth failed on module test2
rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=3.0.2]
解決:服務(wù)端沒(méi)有指定正確的secrets file,請(qǐng)?jiān)?[test2]配置段添加如下配置行:
auth users = coldstar #同步使用的帳號(hào)
secrets file = rsyncd.secrets #密碼文件

錯(cuò)誤6:password file must not be other-accessible
解決:客戶(hù)端的pass文件要求權(quán)限為600, chmod 600 /etc/rsync.pass 即可。

相關(guān)文章

最新評(píng)論