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.
用php实现一个双向队列
作者:蘑菇 日期:2010-07-23 00:54
- <?php
- class deque
- {
- public $queue = array();
- public $length = 0;
- public function frontAdd($node){
- array_unshift($this->queue,$node);
- $this->countqueue();
- }
- public function frontRemove(){
- $node = array_shift($this->queue);
- $this->countqueue();
- return $node;
- }
- public function rearAdd($node){
- array_push($this->queue,$node);
- $this->countqueue();
- }
- public function rearRemove(){
- $node = array_pop($this->queue);
- $this->countqueue();
- return $node;
- }
- public function countqueue(){
- $this->length = count($this->queue);
- }
- }
- ?>
这道题从难度上讲其实不是很难,它主要考察了phper以下几个方面的技能:
1. 当然是双向队列的定义,这个就不多做解释了。
2. 考察对函数是否熟悉。
3. 考察OOP编程。
4. 考察程序员的代码规范和编程习惯。
Joomla 用户密码的生成原理
作者:蘑菇 日期:2010-07-22 01:09
当然,Joomla对密码的加密方式有很多种,有ssha、md5、base64等等,但是因为我们很少触及这些设置,所以大多数还是在使用默认的md5加密方式。
有些人会问:为什么同样的密码每次加密后的结果都不一样呢?原因就是因为Joomla在加密的时候添加了一个随机key。由于这个key是随机的,所以每次加密后的结果也会不一样。
举例说明:
我的Joomla的明文密码是 123456,加密后的结果是
6fa7069f6c2b4a7abc376669113acab8:cW2r7QqdGQrp2Rw9sbxCxN85nSek6tlV
我们看到,加密后的字符串不是普通的md5格式,它被“:”分成了两段,这也是致使有些人怀疑它不是md5的原因。其实后面的这段是key,在每次添加新用户或修改密码时,这一串是随机生成的,而前边的密码才是md5加密后的密码,加密方法为:
md5(明文密码.key)
如上面的密码应该为
6fa7069f6c2b4a7abc376669113acab8 == md5('123456cW2r7QqdGQrp2Rw9sbxCxN85nSek6tlV')
在验证用户密码时也通过这个key做一下md5验证就可以了。
生成这个key和加密密码的函数分别为 getSalt() 和 getCryptedPassword()
它们在 libraries/joomla/user/helper.php 文件中被定义,在 libraries/joomla/user/user.php 的bind()方法中被调用。
从Mysql EXPLAIN探寻数据库查询优化
作者:蘑菇 日期:2010-07-20 16:37
- EXPLAIN tbl_name|SELECT select_options
EXPLAIN tbl_name和DESCRIBE tbl_name的作用是一样的,用于显示表结构等信息。
当我们在select语句前加上EXPLAIN后,Mysql将告诉我们它是如何处理select语句的,提供表之间的联结方式、使用索引等有关信息。
二. 测试环境简单介绍
为了节省创建表的时间,我用了joomla的文章表做测试,因为要演示优化过程,所以我事先删除了表里除主键之外的所有索

