rsync同出出现 IOrsync error code 5encountered 怎么办

rsync日常维护
rsync是unix/linux下同步文件的一个高效算法,它能同步更新两处计算机的文件与目录,并适当利用查找文件中的不同块以减少数据传输。rsync中一项与其他大部分类似程序或协定中所未见的
rsync是unix/linux下同步文件的一个高效算法,它能同步更新两处计算机的文件与目录,并适当利用查找文件中的不同块以减少数据传输。rsync中一项与其他大部分类似程序或协定中所未见的重要特性是镜像是只对有变更的部分进行传送。rsync可拷贝/显示目录属性,以及拷贝文件,并可选择性的压缩以及递归拷贝,同步速度快。
& & & & 192.168.0.30
& & & & 提供服务,并部署rman增量备份
& & & & 使用inotify和rsync实时同步rman备份到备机,为rsync客户端
& & & & 192.168.0.29
& & & & 部署数据库,配置与主机相同,但不提供数据库服务,仅在主机宕机时进行rman异机恢复
& & & & 部署rsync服务,为rsync服务端
以下是使用rsync的维护记录。
第一次同步异常
查看某一系统主机和备机,发现的备份未进行同步,查看日志rsync连接异常,并手动进行测试。
rsync服务端输出日志如下
[root@anybak rmanbak]# tail -f /var/log/rsyncd.log
09:18:05 [9301] params.c:Parameter() - Ignoring badly formed line in configuration : ignore errors
09:18:05 [9301] name lookup failed for 192.168.0.30: Temporary failure in name resolution
09:18:05 [9301] connect from UNKNOWN (192.168.0.30)
09:18:05 [9301] rsync to anbak from oracle@unknown (192.168.0.30)
09:18:05 [9301] rmanbak/
09:18:28 [9301] inflate (token) returned -5
09:18:28 [9301] rsync error: error in rsync protocol data stream (code 12) at token.c(478) [receiver=2.6.8]
09:18:28 [9301] rsync: connection unexpectedly closed (2097 bytes received so far) [generator]
09:18:28 [9301] rsync error: error in rsync protocol data stream (code 12) at io.c(463) [generator=2.6.8]
1.ignore errors
查看/etc/rsyncd.conf,配置了ignore errors,注释掉即可;ignore errors 可以忽略掉一些无关的IO错误。
2.name lookup failed for 192.168.0.30: Temporary failure in name resolution
rsync 启用了DNS反向解析,查询不到时,可能需要花很长时间。
在/etc/hosts文件中,添加192.168.0.30
配置重新启动rynsc服务和客户端脚本,即可正常同步。
第二次同步异常
查看某一系统主机和备机,发现的备份未进行同步。
rsync客户端日志
inflate (token) returned -5
rsync: connection unexpectedly closed (229751 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(463) [sender=2.6.8]
rsync服务端日志
[root@anybak ~]# tail -f /var/log/rsyncd.log
16:57:27 [8694] connect from
(192.168.0.30)
16:57:27 [8694] rsync to anybak from oracle@ (192.168.0.30)
16:57:27 [8694] rmanbak/
16:57:50 [8694] inflate (token) returned -5
16:57:50 [8694] rsync error: error in rsync protocol data stream (code 12) at token.c(478) [receiver=2.6.8]
16:57:50 [8694] rsync: connection unexpectedly closed (2096 bytes received so far) [generator]
16:57:50 [8694] rsync error: error in rsync protocol data stream (code 12) at io.c(463) [generator=2.6.8]
还是出现了上次出现过的异常。在网上搜索后,发现可能是,因传输的文件太多太大,此时需要升级rsync版本。
查看当前rsync版本
[root@any rmanbak]# rpm -qa | grep rsync
rsync-2.6.8-3.1
[root@any rmanbak]# mount 192.168.1.100:/media/centos/5.7_64/1 /media/
[root@any rmanbak]# rpm -ihv /media//rsync-3.0.6-4.el5.x86_64.rpm
warning: /media/CentOS/rsync-3.0.6-4.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:rsync ########################################### [100%]
升级版本之后,仍有错误信息。
rsync客户端日志
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection reset by peer (104)
inflate (token) returned -5
rsync error: error in rsync protocol data stream (code 12) at token.c(604) [receiver=3.0.6]
rsync: connection unexpectedly closed (229747 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
rsync服务端日志
17:29:21 [9026] connect from
(192.168.0.30)
17:29:21 [9026] rsync to anybak from oracle@ (192.168.0.30)
17:29:21 [9026] receiving file list
17:29:21 [9026] rmanbak/
17:29:44 [9026] inflate (token) returned -5
17:29:44 [9026] rsync error: error in rsync protocol data stream (code 12) at token.c(604) [receiver=3.0.6]
17:29:44 [9026] rsync: connection unexpectedly closed (2017 bytes received so far) [generator]
17:29:44 [9026] rsync error: error in rsync protocol data stream (code 12) at io.c(600) [generator=3.0.6]
升级之后,可能还是传输的文件太大所导致的。
根据网上搜索到的文档,在rsync命令中加入参数 --no-iconv,重启后,客户端日志信息如下:
sending incremental file list
rmanbak/_inc0_tfnlf4ok_1_1.bkp
22% 47.78MB/s 0:01:13
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Connection reset by peer (104)
inflate (token) returned -5
rsync error: error in rsync protocol data stream (code 12) at token.c(604) [receiver=3.0.6]
rsync: connection unexpectedly closed (229747 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
根据以上提示,文件_inc0_tfnlf4ok_1_1.bkp太大,导致传输异常。
查看该文件大小
[root@any rmanbak]# ll -h _inc0_tfnlf4ok_1_1.bkp
-rw-r----- 1 oracle oinstall 4.4G Sep 17 22:21 _inc0_tfnlf4ok_1_1.bkp
这里需要调整rman备份片的大小,限制在500M,实际最大能够正常传输多大的文件尚未明确。
在rman中设置备份集中备份片的大小
[root@any rmanbak]# su - oracle
[root@any rmanbak]# rman target/
RMAN& CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 500M;
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 500 M;
new RMAN configuration parameters are successfully stored
不过以上设置对手动分配过channel的备份脚本无效,此时可以在分配通道的脚本中手动指定每个备份片的大小
sql 'alter system archive log current';
alloe channel cha_inc0 type disk maxpiecesize=500M;
incremental level 0
format '/apps/rmanbak/data/%T_inc0_%U.bkp'
tag 'weekly inc0 backup'
database plus arc
release channel cha_inc0;
将未同步的文件使用scp命令手动同步到备机,再进行小文件(大不予500M)的同步测试。
另外,因主机和备机停机过( 17:08),而rsync的实时同步备份只有监测的路径下文件结构发生变更时才会触发远程同步,这样累计起来需要同步的文件太多( 正好周一,rman每周一晚十点都会进行数据库全备,因此产生的备份文件很多),也可能导致rsync同步失败。
[root@any ~]# uptime
20:37:04 up 1 day, 3:31, 1 user, load average: 0.07, 0.02, 0.11
[root@any ~]# last | more
root pts/1
Tue Sep 25 20:36 still logged in
root pts/1
Tue Sep 25 12:46 - 20:28 (07:42)
root pts/2
Tue Sep 25 09:06 - 20:28 (11:22)
root pts/1
Tue Sep 25 08:55 - 10:04 (01:09)
oracle pts/1 :0.0 Tue Sep 25 08:32 - 08:33 (00:00)
oracle :0 Tue Sep 25 08:31 - 08:33 (00:01)
oracle :0 Tue Sep 25 08:31 - 08:31 (00:00)
reboot system boot 2.6.18-194.el5 Mon Sep 24 17:08 (1+03:28)
[root@anybak ~]# date
Tue Sep 25 20:30:25 CST 2012
[root@anybak ~]# uptime
20:30:27 up 1 day, 3:32, 1 user, load average: 0.00, 0.00, 0.00
[root@anybak ~]# last | more
root pts/1
Tue Sep 25 20:30 still logged in
root pts/2 192.128.1.100 Tue Sep 25 16:58 - 19:58 (03:00)
root pts/1 192.138.1.100 Tue Sep 25 12:37 - 20:21 (07:43)
reboot system boot 2.6.18-194.el5 Mon Sep 24 16:59 (1+03:31)
#abstract:
#rsync auto sync script
first_release
#variables
current_date=$(date +%Y%m%d_%H%M%S)
rman_path=/apps/rmanbak
log_file=/var/log/rsync.log
rsync_server=192.168.0.29
rsync_user=oracle
rsync_pwd=/etc/rsync_client.pwd
rsync_module=anybak
#rsync_client password check
if [ ! -e ${rsync_pwd} ]; then
echo &rsync client password file does not exist!&
#inotify function
inotify_fun(){
/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y-%H:%M' --format '%T%w%f' \
-e modify,delete,create,move ${rman_path} | while read file
/usr/bin/rsync -vrtzopg --progress --delete --password-file=${rsync_pwd} ${rman_path} ${rsync_user}@${rsync_server}::${rsync_module}
inotify_fun && ${log_file} 2&&1 &
转自:/blog/2012/10/rsync-maintenance-info.html
转载请保留固定链接:
------分隔线----------------------------
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
在一般的 linux 或者 unix 系统中, 都可以通过编辑 bashrc 和 profil...
因为休眠功能在部分计算机无法正常工作,所以Ubuntu默认是不开...
看到too many open files可能想到fs.file-max参数,其实还受下面参数影...
为什么Nginx的性能要比Apache高很多? 这得益于Nginx使用了最新的...
老实说,人们最不曾思考的问题之一是他们的个人电脑中使用了...
近两年来,Linux的容器技术占据了世界企业IT市场的主导地位,并...CentOS下rsync linux(server)与win(client)同步
研究了好久记录一下。。。基本介绍:Rsync使用所谓的&Rsync算法&来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。rsync的优点①可以镜像保存整个目录树和文件系统;②可以很容易做到保持原来文件的权限、时间、软硬链接等;③无须特殊权限即可安装;④优化的流程,文件传输效率高;⑤可以使用rsh、ssh等方式来传输文件,当然也可以通过直接的socket连接;⑥支持匿名传输服务器端的配置具体的就不多说了,重要的地方说一下。首先检查rsync是否安装:rpm &q rsyncrsync-2.6.8-3.1说明rsync已安装,如果提示出现 package rsync is not installed 则说明这个软件报没有安装大家可以使用yum进行安装另外,关闭防火墙和SElinux,因为是内网中传输,所以这些没必要service iptables stop && chkconfig iptables offsetenforce 0下面分享下我自己定义的配置文件/etc/rsyncd.conf。文件我先贴出来,方便线上环境的朋友直接复制,后面再写上详细注释。uid = nobodygid = nobodyuser chroot = nomax connections = 200timeout = 600pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.log[backup]path=/backup/&&&&&&&&&&& #服务器要备份的目录 权限777ignore errorsread only = nolist = nohosts allow = 192.168.21.0/255.255.255.0auth users = test&&&&&&&&&&&&&&&&&&& # rootsecrets file = /etc/rsyncd.password&& #服务器存在用户的账号密码 比如 root:123456注释:uid = nobody进行备份的用户,nobody 为任何用户gid = nobody进行备份的组,nobody为任意组use chroot = no如果&use chroot&指定为true,那么rsync在传输文件以前首先chroot到path参数所指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要以root权限并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true.但是这个一般不需要,我选择no或falselist = no不允许列清单max connections = 200最大连接数timeout = 600覆盖客户指定的IP超时时间,也就是说rsync服务器不会永远等待一个崩溃的客户端pidfile = /var/run/rsyncd.pidpid文件的存放位置lock file = /var/run/rsync.lock锁文件的存放位置log file = /var/log/rsyncd.log日志文件的存放位置[backup]这里是认证模块名,即跟samba语法一样是对外公布的名字path = /backup/这里是参与同步的目录ignore errors可以忽略一些无关的IO错误read only = no允许可读可写list = no不允许列清单hosts allow = 192.168.21.0/255.255.255.0这里跟samba的语法是一样的,只允许192.168.21.0/24的网段进行同步,拒绝其它一切auth users = test认证的用户名secrets file = /etc/rsyncd.password密码文件存放地址注意:对于这个地方的配置文件,虽然解释的很清楚,可是一些朋友始终还会在这里出错这里我提亮点易错点:1、[backup] 认证模块名和 path = /backup/ 参与同步的目录这里的path 大家要记好了,这里不要随便的一设置就直接完事,要知道这里是认证模块的,以后从客户机备份的数据会存储在这里。2、auth users = redhat 认证的用户名这个名字是服务器端实实在在存在用户,大家不要直接跟步骤走却忽略了这点。如果服务器端少了这个的话我估计你的数据同步就实现不了,大家要谨记。3、path = /backup/ 参与同步的目录这个需要稍后自己要在根目录下自己建cd /mkdir backupchmod &R 777 /backupecho &test:test& & /etc/rsyncd.password(这里我设置的是用户名和密码一致)为了安全起见,我设置他的权限为600chmod 600 /etc/rsync.password客户端配置:1、配置windows的rsync客户端&(1)安装client端的rsync包(2)打开cmd,执行同步计划:cd D:\Program Files\cwRsync\binrsync -vzrtopg --progress --delete root@192.168.0.132::backup /test这样就可以把& 服务器backup指定的目录 同步到 本地d盘的test目录了win8系统:/test 是本地目录&& 我的win8系统 rwrsync装到D盘了& /test指的就是D:\test这个研究了 好久 郁闷着呢。rsync -av /test root@192.168.0.132::backup 可以把本地d盘test目录上传到服务器 backup指定的目录(此时须输入root用户的密码,就可进行同步了。)xp系统:/test 本地目录& d:\test& 要写成 /cygdrive/d/test& 其他盘换第二个目录的d就可以了& 指定本地密码文件 和 本地备份目录时 要注意。。。测试都配置完毕之后就是测试了。在机器上,输入命令rsync -vzrtop --delete /cygdrive/d/test root@192.168.1.200::backup --password-file=/etc/rsyncd.password查看同步效果。注意:我这里是直接以root进行操作。rsync以delete操作时要注意,它会完全同步这边的目录与服务器的目录中的文件,这样会产生一个后果,它会删掉服务器中多余的文件。如果是线上机器,请慎之又慎,切记!我们都是通过错误日志查看在rsyncd.log里面或.err文件里面,大家可以用记事本打开查看。注意windows下面我们需要给SvcwRsync用户,管理同步目录的所有权限,基本上这样就可以了在本地和服务器测试时总是提示 rsync: failed to connect to 最后发现是本地路由没有设置873端口的转发 进入路由设置一下873 转发到服务器就可以了。。问题一: @ERROR: chroot failed rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3] 原因: 服务器端的目录不存在或无权限,创建目录并修正权限可解决问题。 问题二: @ERROR: auth failed on module backup rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3] 原因: 服务器端该模块(backup)需要验证用户名密码,但客户端没有提供正确的用户名密码,认证失败。 提供正确的用户名密码解决此问题。 问题三: @ERROR: Unknown module &tee_nonexists& rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3] 原因: 服务器不存在指定模块。提供正确的模块名或在服务器端修改成你要的模块以解决问题。 问题1: 在client上遇到问题: rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/ rsync: could not open password file &/etc/rsync.pas&: No such file or directory (2) Password: @ERROR: auth failed on module backup rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7] 遇到这个问题:client端没有设置/etc/rsync.pas这个文件,而在使用rsync命令的时候,加了这个参数-- password-file=/etc/rsync.pas 问题2: rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/ @ERROR: auth failed on module backup rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7] 遇到这个问题:client端已经设置/etc/rsync.pas这个文件,里面也设置了密码111111,和服务器一致,但是 服务器段设置有错误,服务器端应该设置/etc/rsync.pas ,里面内容root:111111 ,这里登陆名不可缺少 问题3: rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/ @ERROR: chdir failed rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7] 遇到这个问题,是因为服务器端的/home/backup 其中backup这个目录并没有设置,所以提示:chdir failed 问题4: rsync: write failed on &/home/backup2010/wensong&: No space left on device (28) rsync error: error in file IO (code 11) at receiver.c(302) [receiver=3.0.7] rsync: connection unexpectedly closed (2721 bytes received so far) [generator] rsync error: error in rsync protocol data stream (code 12) at io.c(601) [generator=3.0.7] 磁盘空间不够,所以无法操作。 可以通过df /home/backup2010 来查看可用空间和已用空间 问题5:网络收集问题 1、权限问题 类似如下的提示:rsync: opendir &/test& (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 或者更改指定默认的配置文件路径,在/etc/xinetd.d/rsync配置文件中。
&&最后修改于
请各位遵纪守法并注意语言文明用户名:jafyoo
文章数:164
评论数:60
访问量:825971
注册日期:
阅读量:1297
阅读量:3317
阅读量:440897
阅读量:1127286
51CTO推荐博文
rsync出错:
IO input / output error (5)
failed verification & update discarded (will try again).
将目的文件删除,重新备份本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)版权所有(C) mcsrainbow,保留所有原创日志的权利。转载请注明出处: 。这篇文章发表于
11:00,属于
分类。 你可以通过
来跟踪这篇文章。
你还可以对它进行 。
标签云(Tags)
WP Cumulus Flash tag cloud by
新浪微博(Sina Weibo)
友情链接(Blogroll)
文章归档(Archives)
功能(Meta)
网站安全监测(Webscan)
美国时间(US Time)
Google +1 (Plusone Button)
广告(Google Adsense)
Fusion theme by
| powered by}

我要回帖

更多关于 error encountered 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信