rsync 常见错误及解决方法(中文版)
作者:蘑菇 日期:2010-07-28 01:12
编译错误
options.c:24:18: popt.h: No such file or directory
make: *** [options.o] Error 1
解决方法
丢失popt.h,添加编译选项 --with-included-popt
-------------------------------------------------------------------------------------------------------------
连接错误
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at main.c(1383) [receiver=2.6.9]
解决方法
检查日志文件/var/log/rsyncd.log,以获取更多帮助信息
-------------------------------------------------------------------------------------------------------------
配置文件错误
secrets file must not be other-accessible (see strict modes option)
continuing without secrets file
解决方法
初始化设置strict modes = false 或修改密码文件权限 chmod 600 /path/to/secrets
-------------------------------------------------------------------------------------------------------------
配置文件错误
Ignoring badly formed line in configuration file: xxx
解决方法
检查 /etc/rsyncd.conf 文件中xxx所在行,它应该包含变量、等号(=)、和值。
-------------------------------------------------------------------------------------------------------------
配置文件错误
rsync: chroot /path/to/files failed: Operation not permitted (1)
解决方法
如果你没有超级用户权限,请将设置选项 use chroot = false 。
如果为true,那么在rsync在传输文件以前首先chroot到path参数指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要root权限,并且不能备份指向外部的符号连接指向的目录文件。
-------------------------------------------------------------------------------------------------------------
客户端错误
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(604) [receiver=2.6.9]
或
rsync: getaddrinfo: mydomain.com xxx: no address associated with hostname.
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
或
rsync: failed to connect to mydomain.com: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
解决方法
rsync服务器没有在指定的端口上运行。检查rsync服务器端口是否指定,并检查其是否运行 ps -aux。
-------------------------------------------------------------------------------------------------------------
客户端错误
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at /home/lapo/packaging/tmp/rsync-2.6.6/main.c(1171)
解决方法
rsync调用时用户名必须在站点名前面,例如: rsync -auvzbP /cygwin/local/path/ user@remotehost.com::desired_module --port=8730
-------------------------------------------------------------------------------------------------------------
客户端错误
14 [main] (2164) C:\Program Files\cwRsync\bin\ssh.exe: *** fatal error - C:\Program Files\cwRsync\bin\ssh.exe: *** system shared memory version mismatch detected - 0x2D1E009C/0x75BE009C.
解决方法
请确保你正在rsync同一目录下运行SSH。此问题可能是由于你使用了不兼容的Cygwin DLL版本,在windows下查找cygwin1.dll并删除所有的旧版本,最新的版本应该在x:\cygwin\bin(x为你安装cygwin的分区),如果找不到建议重启再试。
-------------------------------------------------------------------------------------------------------------
客户端错误
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at main.c(1383) [receiver=2.6.9]
解决方法
配置文件中(通常是/etc/rsyncd.conf)“auth users”选项和“secrets file” 文件中定义给module的用户列表不匹配。
-------------------------------------------------------------------------------------------------------------
客户端错误
/bin/sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9]
解决方法
检查rsync是否在你当前登录的ssh会话的环境变量中。
你可以通过命令ssh -2 -v mylogin@mydomain.com 登录到服务器,然后使用 env|grep -i path 来检查。
你可以将/etc/rsyncd/wrapper.sh添加到/.ssh/authorized_keys文件的第一行,并将它设置为可执行权限。
-------------------------------------------------------------------------------------------------------------
更从配置说明与参数介绍请参阅:Ubuntu rsync同步文件实例
rsync 常见错误及解决办法
作者:蘑菇 日期:2010-07-28 00:43
Make error
options.c:24:18: popt.h: No such file or directory
make: *** [options.o] Error 1
Solution
Missing popt.h Change configure to include --with-included-popt
-------------------------------------------------------------------------------------------------------------
Connect Error
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at main.c(1383) [receiver=2.6.9]
Solution
Check /var/log/rsyncd.log file for further details
-------------------------------------------------------------------------------------------------------------
rsyncd.log Error
secrets file must not be other-accessible (see strict modes option)
continuing without secrets file
Solution
EITHER set option strict modes = false in initial section of configuration file OR chmod 600 /path/to/secrets
-------------------------------------------------------------------------------------------------------------
rsyncd.log Error
Ignoring badly formed line in configuration file: xxx
Solution
Check syntax of line given (xxx) in /etc/rsyncd.conf. It should consist of an option, an equals sign (=) and a value.
-------------------------------------------------------------------------------------------------------------
rsyncd.log Error
rsync: chroot /path/to/files failed: Operation not permitted (1)
Solution
Set Module Option use chroot = false if you do not have super user access. When “use chroot” is false, symlinks may only be relative paths pointing to other files within the root path, for security reasons and leading slashes are removed from most absolute paths
-------------------------------------------------------------------------------------------------------------
rsync Client error
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(604) [receiver=2.6.9]
OR
rsync: getaddrinfo: mydomain.com xxx: no address associated with hostname.
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
OR
rsync: failed to connect to mydomain.com: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
Solution
No rsync server runnning on specified port of server. Check that correct port was specified. Also, check that the rsync server is running by typing ps -auxww.
-------------------------------------------------------------------------------------------------------------
rsync Client error
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at /home/lapo/packaging/tmp/rsync-2.6.6/main.c(1171)
Solution
rsync needs to be called with the username before the site name. For example rsync -auvzbP /cygwin/local/path/ user@remotehost.com::desired_module --port=8730
-------------------------------------------------------------------------------------------------------------
rsync Client error
14 [main] (2164) C:\Program Files\cwRsync\bin\ssh.exe: *** fatal error - C:\Program Files\cwRsync\bin\ssh.exe: *** system shared memory version mismatch detected - 0x2D1E009C/0x75BE009C.
Solution
Make sure that you are running SSH from the same directory as rsync. This problem is probably due to using incompatible versions of the cygwin DLL. Search for cygwin1.dll using the Windows Start->Find/Search facility and delete all but the most recent version. The most recent version *should* reside in x:\cygwin\bin, where ‘x’ is the drive on which you have installed the cygwin distribution. Rebooting is also suggested if you are unable to find another cygwin DLL.
-------------------------------------------------------------------------------------------------------------
rsync Client error
@ERROR: auth failed on module rsyncd_module
rsync error: error starting client-server protocol (code 5) at main.c(1383) [receiver=2.6.9]
Solution
Mismatch between “auth users” line for module rsyncd_module in configuration file (Normally /etc/rsyncd.conf) and users listed in “secrets file” specified in module’s definition.
-------------------------------------------------------------------------------------------------------------
rsync Client error
/bin/sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9]
Solution
Check that rsync is in the path of your SSH session as the environment may well be different for SSH to that for a normal login. To verify this, try executing the command ssh -2 -v mylogin@mydomain.com “env|grep -i path”. You can modify /.ssh/authorized_keys to include the line command=”/etc/rsyncd/wrapper.sh” as the first line. You will need to create the wrapper and make it executable.
Ubuntu rsync同步文件实例
作者:蘑菇 日期:2010-05-29 11:58
服务器端:Ubuntu 9.10 - 192.168.1.3
客户端:Ubuntu 10.04 - 192.168.1.73
我们先来设置一下服务器端的配置
1.ubuntu系统安装完之后,rsync服务默认不是启动的,我们要修改下面的文件。
$sudo vi /etc/default/rsync
RSYNC_ENABLE=true
2.修改配置文件
$sudo cp /usr/share/doc/rsync/examples/rsyncd.conf /etc
我们先来查看一下这个文件
$sudo cat /etc/rsyncd.conf
# sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd #登录欢迎信息
#log file=/var/log/rsyncd #日志文件
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
pid file=/var/run/rsyncd.pid
#指定rsync发送日志消息给syslog时的消息级别,常见的消息级别是:uth, authpriv, cron, daemon, ftp, kern, lpr, mail, news, security, sys-log, user, uucp, local0, local1, local2, local3,local4, local5, local6和local7。默认值是daemon。
#syslog facility=daemon
#自定义tcp选项,默认是关闭的
#socket options=
#以下是模块信息,我们可以创建多个模块
# MODULE OPTIONS
[ftp]
comment = public archive #模块描述
path = /var/www/pub #需要同步的路径
use chroot = yes #默认是yes|true,如果为true,那么在rsync在传输文件以前首先chroot到path参数指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要root权限,并且不能备份指向外部的符号连接指向的目录文件。
# max connections=10 #最大连接数
lock file = /var/lock/rsyncd #指定支持max connections参数的锁文件。
# the default for read only is yes...
read only = yes #只读选项
list = yes #客户请求时可用模块时是否列出该模块
uid = nobody #设定该模块传输文件时守护进程应该具有的uid
gid = nogroup #设定该模块传输文件时守护进程应具有的gid,此项与uid配合可以确定文件的访问权限
# exclude = #用来指定多个由空格隔开的多个模式列表,并将其添加到exclude列表中。这等同于在客户端命令中使用--exclude来指定模式,不过配置文件中指定的exlude模式不会传递给客户端,而仅仅应用于服务器。一个模块只能指定一个exlude选项,但是可以在模式前面使用"-"和"+"来指定是exclude还是include
# exclude from = #可以指定一个包含exclude模式定义的文件名
# include = #与exclude相似
# include from = #可以指定一个包含include模式定义的文件名
# auth users = #该选项指定由空格或逗号分隔的用户名列表,只有这些用户才允许连接该模块。这里的用户和系统用户没有任何关系。如果"auth users"被设置,那么客户端发出对该模块的连接请求以后会被rsync请求challenged进行验证身份这里使用的 challenge/response认证协议。用户的名和密码以明文方式存放在"secrets file"选项指定的文件中。默认情况下无需密码就可以连接模块(也就是匿名方式)
# secrets file = /etc/rsyncd.secrets #该文件每行包含一个username:password对,以明文方式存储,只有在auth users被定义时,此选项才生效。同时我们需要将此文件权限设置为0600
strict modes = yes #该选项指定是否监测密码文件的权限,如果该选项值为true那么密码文件只能被rsync服务器运行身份的用户访问,其他任何用户不可以访问该文件。默认值为true
# hosts allow = #允许的主机
# hosts deny = #拒绝访问的主机
ignore errors = no #设定rsync服务器在运行delete操作时是否忽略I/O错误
ignore nonreadable = yes #设定rysnc服务器忽略那些没有访问文件权限的用户
transfer logging = no #使rsync服务器使用ftp格式的文件来记录下载和上载操作在自己单独的日志中
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes. #设定日志格式
timeout = 600 #超时设置(秒)
refuse options = checksum dry-run #定义一些不允许客户对该模块使用的命令选项列表
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz #告诉rysnc那些文件在传输前不用压缩,默认已设定压缩包不再进行压缩
日志格式选项列表:
%h:远程主机名
%a:远程IP地址
%l:文件长度字符数
%p:该次rsync会话的进程id
%o:操作类型:"send"或"recv"、”del.”
%f:文件名
%P:模块路径
%m:模块名
%t:当前时间
%u:认证的用户名(匿名时是null)
%b:实际传输的字节数
%c:当发送文件时,该字段记录该文件的校验码
下面我们来定义自己的conf文件
# [GLOBAL OPTIONS]
#motd file=/etc/motd
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
pid file=/var/run/rsyncd.pid
syslog facility=daemon
#socket options=
# [MODULE OPTIONS]
[serverdb]
comment = Server Databases
path = /home/flow/Documents/db_backup
use chroot = no
# max connections=10
lock file = /var/lock/rsyncd
# the default for read only is yes...
read only = true
list = true
uid = nobody
gid = nogroup
exclude = db_backup.sh
# exclude from =
# include =
# include from =
auth users = liubing
secrets file = /etc/rsyncd.secrets
strict modes = true
hosts allow = 192.168.1.73
# hosts deny =
ignore errors = true
ignore nonreadable = true
transfer logging = true
log format = %t[%p]: host %h (%a) %o %f (%l bytes). Total %b bytes.
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
创建一个密码文件
$sudo vi /etc/rsyncd.secrets
liubing:123456
$sudo chmod 0600 /etc/rsyncd.secrets
启动rsync
sudo /etc/init.d/rsync start
我们再来看一下客户端的操作,一般客户端不需要进行特殊的配置,直接同步即可
$rsync -vzrtopg --progress liubing@192.168.1.3::serverdb .
password
成功!
我们把这个同步工作交给crontab去执行。首先我们要创建一个密码文件
$sudo vi /etc/rsync.pwd输入123456,保存
!注意:下面这两步操作是必须的
sudo chmod 0600 /etc/rsync.pwd
sudo chown liubing:liubing /etc/rsync.pwd
然后我们打开crontab,加入以下任务
$crontab -e
* */1 * * * rsync -a --password-file=/etc/rsync.pwd liubing@192.168.1.3::serverdb /home/liubing/Documents/db_backup
更多内容:rsync 常见错误及解决方法
- 1

