windows下rsync的数据同步安装配置方法

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=wt.pas /cygdrive/f/webroot// wt@221.192.1.1::dddown

wt.pas的内容

复制代码 代码如下:
:www..net

是用户名,后面的是密码

/cygdrive/f/webroot//中的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服务。一般是异常关机导致的。