Windows 之间用rsync同步数据(cwRsyncServer配置)

Windows 之间用rsync同步数据(cwRsyncServer配置)


作者:gotop


rsync是一款优秀的数据同步软件,在跨服务器,跨机房,跨国备份服务器的首选工具,下面就来介绍下如何配置安装cwRsyncServer很大多数软件一样是B/C架构,cwRsyncServer是rsync的windows版本

一,下载
官方下载地址:官方网站:http://rsync.samba.org/download.html
下载地址:
http://sourceforge.net/projects/sereds/files/cwRsync/4.1.0/

服务器版为:  cwRsyncServer_4.1.0_Installer.rar (3.65 MB, 下载次数: 91) 
客户端版为:  cwRsync_4.1.0_Installer.rar (3.4 MB, 下载次数: 153) 

二,安装

服务器IP:192.168.1.1
客户端IP:192.168.1.2

1,服务器安装

第一步:建立cwRsyncServer运行账户,这一步是必须的,否则你安装完连启动都启动不来哦
用户名:test
密码:test
并且加入管理员组!
注意:这个帐号只是安装和运行用的账户,别无它用

第二步:安装
安装如图:




输入刚刚建立的帐号

按照完毕后点击closed即可

第三步:配置
我们按照的路径是:E:\Program Files\ICW\
那我们就进入到这个目录
打开rsyncd.conf编辑内容如下:

use chroot = false
uid = 0
gid = 0
strict modes = false
log file = rsyncd.log
port = 10556
[www]
path = /cygdrive/c/www
read only = false
transfer logging = yes
auth users = testuser
secrets file = etc/testuser.pas
hosts allow = 192.168.1.2
hosts deny = 0.0.0.0/0

[mysql]
path = /cygdrive/d/MySQL/MySQL Server 5.0/data/bbs
auth users = testuser
secrets file = etc/testuser.pas
hosts allow = 192.168.1.2
hosts deny = 0.0.0.0/0

然后进入E:\Program Files\ICW\etc目录建立testuser.pas文本文件,注意文件全名为testuser.pas

输入:
testuser:123
即:用户名为:testuser
       密码为:123
这个用户才是客户端连接服务器是要认证的用户名和密码

第四步:启动服务
运行---cmd---services.msc
如图启动服务:


本地测试一下:telnet 127.0.0.1 10556

防火墙记得开启这个端口

2,客户端安装
解压:cwRsync_4.1.0_Installer.zip按照向导安装
按照完成后:
cd C:\Program Files\cwRsync\bin>

启动客户端连接服务器
rsync.exe -vzrtopg --progress --delete wodetop@192.168.1.1::www /cygdrive/e/databackup/www --port=10556
输入密码

3,设置计划任务,定时同步数据:

注意,计划任务这块要提示输入密码,下面是不用输入密码的脚本

@echo off
"c:\Program Files\cwRsync\bin\rsync.exe" -vzrtopg --progress --delete cnuser@192.168.1.1::www /cygdrive/e/databackup/www --port=10556 --password-file=/cygdrive/e/databackup/rsyncpwd.txt < E:\databackup\passwd.txt

复制代码


在E:\databackup目录下建立一个空文件名:rsyncpwd.txt 再建立个E:\databackup\passwd.txt 输入密码

否这回出现下面错误:password file must not be other-accessible

password file must be owned by root when running as root


楼下会给出常见的一些问题

 

 

安装完 cwRsync客户端后,开始写bat 执行文件,遇到的第一件事情就是就同步到本地时 目录不认识,报错如下:

The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1138) [Receiver=3.0.7]

主要原因是cwRsync 不能直接认识本地盘,必须加上 /cygdrive/g/test

意思为g:\test目录

客户端密码文件报错如下:

rsync password file must be owned by root when running as root

万能的GOOGLE告诉我,可以用一个变通的方式解决就是

@echo off
"C:\Program Files (x86)\cwRsync\bin\rsync" -rlptDzv --progress --delete "backup@192.88.88.128::test" /cygdrive/g/test --password-file=/cygdrive/g/rsync/passws.ps<g:\rsync\passwd.txt

在g:\rsync 下建立了一个文件,写入密码,然后同步密码最后在这个文件中输入即可。如上所例。

 

rsync问题小结

在用rsync同步数据的时候,经常会出现一些问题,我将遇到的总结如下:
1、权限问题
类似如下的提示:rsync: opendir "/kexue" (in dtsChannel) failed: Permission denied (13)注意查看同步的目录权限是否为755
2、time out
rsync: failed to connect to 203.100.192.66: Connection timed out (110)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
检查服务器的端口netstat –tunlp,远程telnet测试。
3、服务未启动
rsync: failed to connect to 10.10.10.170: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
启动服务:rsync --daemon --config=/etc/rsyncd.conf
4、磁盘空间满
rsync: recv_generator: mkdir "/teacherclubBackup/rsync……" failed: No space left on device (28)
*** Skipping any contents from this failed directory ***
5、Ctrl+C或者大量文件
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [receiver=3.0.5]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [generator=3.0.5]
6、xnetid启动
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [receiver=3.0.5]
查看rsync日志
rsync: unable to open configuration file "/etc/rsyncd.conf": No such file or directory
xnetid查找的配置文件位置默认是/etc下,根据具体情况创建软链接。例如:
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf

 

常见错误:

错误一
rsync: failed to connect to 96.44.169.178 (*inet_ntop failed*): Connection timed
out (116)
      1 [main] rsync 3468 exception::handle: Exception: STATUS_ACCESS_VIOLATION
    740 [main] rsync 3468 open_stackdumpfile: Dumping stack trace to rsync.exe.s
tackdump
1,防火墙问题
2,端口不对

错误二
@ERROR: auth failed on module www
rsync error: error starting client-server protocol (code 5) at main.c(1516) [Rec
eiver=3.0.8]
密码不对

错误三
@ERROR: invalid uid nobody
rsync error: error starting client-server protocol (code 5) at main.c(1516) [Rec
eiver=3.0.8]
UID不对,默认是nobody
解决方法:
uid = 0
gid = 0

错误四
receiving incremental file list
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(769) [receive
r=3.0.8]
rsync: connection unexpectedly closed (60 bytes received so far) [generator]
rsync error: error in rsync protocol data stream (code 12) at io.c(610) [generat
or=3.0.8]
可能原因:
1,磁盘挂载是用异步的(async)
然后,检查了/etc/fstab ,去掉async参数。

2,我在服务器上查看日志,看到有这么一行:
rsync: unable to open configuration file "/etc/rsyncd.conf": No such file or directory

于是我:
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf

3,同步文件数较多的目录出错
有个子目录中文件较多,也就8000来个吧,总是同步一半便退出。在批处理中加上-v参数,看到错误信息如下:
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection reset by peer (104)
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(768) [sender=
3.0.6]

这个问题有点头疼,在www.itefix.no网站论坛上也没能查出个所以然。

不过最终还是在samba.org上找到解决方案:

在客户端命令行中加上--no-iconv参数就可以了。

原以为是文件太多,缓冲区不够引起,但看这个解决方案,似乎是转换编码方面的bug了。

在rsync的文档中描述如下:
http://rsync.samba.org/ftp/rsync/rsync.html
--iconv=CONVERT_SPEC
Rsync can convert filenames between character sets using this option. Using a CONVERT_SPEC of "." tells rsync to look up the default character-set via the locale setting. Alternately, you can fully specify what conversion to do by giving a local and a remote charset separated by a comma in the order --iconv=LOCAL,REMOTE, e.g. --iconv=utf8,iso88591. This order ensures that the option will stay the same whether you're pushing or pulling files. Finally, you can specify either --no-iconv or a CONVERT_SPEC of "-" to turn off any conversion. The default setting of this option is site-specific, and can also be affected via the RSYNC_ICONV environment variable.

 

posted on 2012-10-20 19:40 小李弯刀 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/bluecobra/archive/2012/10/20/2732530.html

Windows 之间用rsync同步数据(cwRsyncServer配置)相关推荐

  1. rsync 同步数据记录_非初学者指南与Rsync同步数据

    rsync 同步数据记录 The rsync protocol can be pretty simple to use for ordinary backup/synchronization jobs ...

  2. rsync同步数据带端口同步加-e参数

    rsync在ssh认证方式下,可通过系统用户进行认证,即在rsync上通过ssh隧道进行传输,类似于scp工具. 此时同步操作不在局限于rsync中定义的同步文件夹.注意:ssh认证方式,不需要服务器 ...

  3. windows 2008 r2 NTP同步Internet时间配置

    windows 2008 r2 NTP同步Internet时间配置 一. NTP Client同步Internet时间 开始菜单---运行输入gpedit.msc打开本地组策略 在打开本地组策略,再依 ...

  4. rsync同步数据到内网

    最近公司要求将IDC的APP日志备份到公司办公网内部,思前想后,结合以前学过的知识,决定用rsync直接推送,即从APP服务器上直接将日志推送到公司内网.这样避免了在生产服务器上额外安装更多软件而且只 ...

  5. rsync 同步数据

    -av  常用参数 -l   同步软连接 -L   同步软连接的原文件 目录对目录同步,加"/",同步目录下所有的文件 --delete 强制目标远一致 -u    避免把目标上的 ...

  6. 用Aliyun E-MapReduce集群的sqoop工具和数据库同步数据如何配置网络

    如果您的E-MapReduce集群需要和集群之外的数据库同步数据,需要确保网络是联通的.本文就RDS,ecs自搭,云下私有数据库三种情况,分别介绍如何配置网络. 一.RDS 经典网络RDS 想要访问经 ...

  7. Python pandas在读取csv文件时(linux与windows之间传输),数据行数不一致的问题

    背景 最近在处理用户评论数据时,从Linux服务器上面用pandas导出的csv文件,下载到自己的Windows电脑,再用本地pandas读取时发现数据行数不一致的情况,比如在Linux服务器上面数据 ...

  8. rsync+inotify实现服务器之间文件实时同步--转

    之前做了"ssh信任与scp自动传输脚本"的技术文档,此方案是作为公司里备份的方法,但在实际的运行中,由于主服务器在给备份服务器传输的时候,我们的主服务器需要备份的文件是实时.不停 ...

  9. rsync+inotify实现服务器之间文件实时同步

    原文转自http://dl528888.blog.51cto.com/2382721/771533/ 之前做了"ssh信任与scp自动传输脚本"的技术文档,此方案是作为公司里备份的 ...

  10. 十八、Rsync 远程同步数据

    在linux系统下数据备份的工具.Rsync不仅可以远程同步数据(类似于scp [1]),当然还可以本地同步数据(类似于cp),但不同于cp或scp的一点是,rsync不像cp/scp一样会覆盖以前的 ...

最新文章

  1. Hbase 和 MySQL 的区别是什么?一文深度对比!
  2. Selenium如何通过location和size定位元素坐标?
  3. java 日期计算类_java日期计算工具类【包含常用的日期计算方法】
  4. SpringBoot入门实战项目各阶段目录
  5. TableCellRenderer和TableCellEditor(一)
  6. android horizontalscrollview 动画,Android HorizontalScrollView左右滑动效果
  7. php设计模式课程---9、桥接模式是什么
  8. 如何调试SharePoint中XsltListViewWebPart的XSL
  9. 解决ajax跨域的方法原理详解之Cors方法
  10. 为什么网站总显示服务器不能创建对象,IE浏览器出现“Automation 服务器不能创建对象”解决教程...
  11. 表单的js验证框架,只提供提示信息及正则表达式即可自动验证及提示
  12. Oracle VM VirtualBox不能正常运行(电脑强行关机后,Linux不能正常运行)
  13. 怎么用Java解二元方程_正则表达式解二元方程式代码
  14. 3D游戏编程 作业六 打飞碟改进
  15. 全局地址池 与接口地址池
  16. 【Javaweb】基础开发流程与介绍
  17. 医院常见报表统计思路整理
  18. 数学建模笔记——评价类模型之熵权法
  19. 骑士编年史服务器没响应,骑士编年史非root刷初始方法
  20. Camera Calibration Toolbox for Matlab使用教程

热门文章

  1. three20 如何将three20中的demo添加到自己的应用程序中。
  2. 诗一首,程序员不仅仅只会写程序
  3. 定义接口.定义接口成员
  4. Guava RateLimiter 实现 API 限流,这才是正确的姿势!
  5. 阿里P8架构师:淘宝技术架构从1.0到4.0的架构变迁!12页PPT详解
  6. 10小时,就能吃透Kafka源码?
  7. 刷抖音看美腿中毒后,我决定做一款抖音App
  8. 程序员哀叹:专科都是几十万的年薪,互联网的泡沫要破了
  9. 一名7年总监的6点离职忠告
  10. 十亿级同步,百亿级调用,千亿级访问量的开放技术平台如何炼成?