Rsync服务器的安装与配置详解(3)

hosts allow = 172.16.1.0/24
hosts deny = 0.0.0.0/32
auth users = tang
secrets file = /etc/tang
#rsync_config________________________end
[root@linuxidc chen]# mkdir /luo
[root@linuxidc chen]# chown rsync.rsync /luo
[root@linuxidc chen]# ls -ld /luo/
drwxr-xr-x 2 rsync rsync 4096 12月  2 19:18 /luo/
[root@linuxidc chen]# cat /etc/tang 
tang:tangguo
[root@linuxidc luo]# ls /etc/tang  -ld
-rw------- 1 root root 13 12月  2 19:34 /etc/tang
权限一定要是600

客户端配置:
[root@linuxidc ming]# cat /etc/tang 
tangguo
[root@linuxidc ming]# ls /etc/tang -ld
-rw------- 1 root root 8 12月  2 19:35 /etc/tang
客户端权限也一定要是600
[root@linuxidc ming]# rsync -avz /ming/ tang@172.16.1.41::luo/  --password-file=/etc/tang 
sending incremental file list
./
ming1
ming10
ming2
ming3
ming4
ming5
ming6
ming7
ming8
ming9
 
sent 463 bytes  received 201 bytes  1328.00 bytes/sec
total size is 0  speedup is 0.00

五、Rsync案例排错
5.1 案例1

[root@linuxidc ming]# rsync -avz /ming/ tang@172.16.1.41::luo/  --password-file=/etc/tang 
@ERROR: auth failed on module luo
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
[root@linuxidc luo]# tail -3 /var/log/rsyncd.log 
2016/12/02 19:46:18 [3601] secrets file must not be other-accessible (see strict modes option)
2016/12/02 19:46:18 [3601] continuing without secrets file
2016/12/02 19:46:18 [3601] auth failed on module luo from unknown (172.16.1.31): missing secret for user "tang"
 
报错的原因是服务器端的/etc/tang的权限问题没有设置为600,我们查看一下。
[root@linuxidc luo]# ls -ld /etc/tang 
-rwxr-xr-x 1 root root 13 12月  2 19:34 /etc/tang
权限改为600就可以了

5.2 案例2
[root@linuxidc ~]# rsync -avz /ming/ tang@172.16.1.41::luo/  --password-file=/etc/tang 
@ERROR: auth failed on module luo
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
查看日志
[root@linuxidc luo]# tail -3 /var/log/rsyncd.log 
2016/12/02 19:52:12 [3614] name lookup failed for 172.16.1.31: Name or service not known
2016/12/02 19:52:12 [3614] connect from UNKNOWN (172.16.1.31)
2016/12/02 19:52:12 [3614] auth failed on module luo from unknown (172.16.1.31): password mismatch
password mismatch,密码错误,客户端和服务器端的密码不一致导致的问题。
【注意】有的客户端和服务器端密码看起来一样,实际里面有空格,也能报错,注意一下

5.3 案例3
[root@linuxidc ~]# rsync -avz /backup/ rsync://rsync_backup@172.16.1.41/backup/ --password-file=/etc/rsync.password 
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
原因:服务端的backup目录不存在

5.4  案例4
[root@linuxidc ~]# rsync -avz /backup/ rsync://rsync_backup@172.16.1.41/backup/ --password-file=/etc/rsync.password 
sending incremental file list
./
rsync: failed to set times on "." (in backup): Operation not permitted (1)
1
 
sent 4325 bytes  received 1911 bytes  12472.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
原因:服务端backup的属组和属主问题

RSync实现文件备份同步详解   

利用inotifywait监控主机文件和目录

利用inotify+rsync实现Linux文件批量更新

inotify-tools+rsync实时同步文件安装和配置

rsync同步完整配置

CentOS 6.5下Rsync远程同步

Linux文件夹对比并提取的差分文件技巧-rsync的妙用

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d9917fb37187951c162790d0573accf3.html