排错前提
- 先查看SELinux这个是否关闭
#查看SELinux状态
/usr/sbin/sestatus
SELinux status: disabled
#SELinux status: enable为开启
#临时关闭 SELinux
setenforce 0
#永久关闭 SElinux
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing #将 SELINUX=enforcing改为SELINUX=disabled,保存后退出
- 查看防火墙是否关闭
#查看防火墙状态
firewall-cmd --list-all
FirewallD is not running
#关闭防火墙
systemctl stop firewalld
ERRPR:chdir failed
问题原因:
服务器端备份存储目录不存在或建立的备份存储目录和配置文件定义不一致
错误演示过程
rsync -avz /etc/passwd rsync_user@10.0.0.41::backup
Password:
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1656)
[sender=3.1.2]
解决方法
#在服务器端创建相关目录,并赋予权限rsync管理权限
mkdir -p /backup
chown -R rsync.rsync /backup
EEROR: some files/attrs were not transferred (see previous errors) (code23) at main.c(1179) [sender=3.1.2]
问题原因
1、服务端配置文件中指定的用户和模块指定的目录的属主属组不同
2、服务端模块指定的目录属组属组没有权限
错误显示过程
rsync -avz /etc/passwd rsync_user@10.0.0.41::backup
Password:
sending incremental file list
passwd
rsync: mkstemp ".passwd.W6cTyw" (in backup) failed: Permission denied (13)
sent 608 bytes received 122 bytes 208.57 bytes/sec
total size is 1,238 speedup is 1.70
rsync error: some files/attrs were not transferred (see previous errors) (code23) at main.c(1179) [sender=3.1.2]
解决方法
#服务端rsync对目录操作权限不足
chown -R rsync.rsync /backup
ERROR: cannot stat destination"." (in backup): Permission denied (13)
问题原因
服务端rsync对目录操作权限不足
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup
Password:
sending incremental file list
rsync: ERROR: cannot stat destination "." (in backup): Permission denied (13)
rsync error: errors selecting input/output files, dirs (code 3) atmain.c(635)[Receiver=3.1.2]
解决办法
#修改服务器端共享目录的权限
chmod 755 /backup
ERROR: auth failed on module backup
问题原因
服务端/etc/rsync.password 配置文件是否有问题
1、 客户端密码文件的权限不是600
2、 服务端密码文件不是600
3、 服务端密码文件不存在(名字写错了/没有创建/配置文件参数写错了)
4、 服务端密码文件里保存的用户名和密码不正确
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup
Password:
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1656)[sender=3.1.2]
解决办法
服务器/etc/rsync.password和/etc/rsyncd.conf两个文件用户名或密码是否一致
客户端密码文件的权限是不是600
服务端密码文件是不是600
服务端密码文件不存在(名字写错了/没有创建/配置文件参数写错了)
服务端密码文件里保存的用户名和密码不正确
ERROR: Unknown module ‘aaa’
问题原因
客户端输入的模块错误或者服务器端没有该模块
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::aaa
@ERROR: Unknown module 'aaa'
rsync error: error starting client-server protocol (code 5) at main.c(1656)[sender=3.1.2]
解决方法
#换一个模块使用
#编写一个局部模块
vim /etc/rsyncd.conf
uid = rsync
......
[aaa]
comment = welcome to softeem backup!
path = /backup
ERROR: password file must not be other-accessible
问题原因
客户端使用免交互,创建了/etc/rsync.password文件,但权限不是600
错误显示过程
rsync -avz /etc/passwd rsync_user@10.0.0.41::backup/ --password-file=/etc/rsync.password
ERROR: password file must not be other-accessible
rsync error: syntax or usage error (code 1) at authenticate.c(196)[sender=3.1.2]
解决方法
#rsync客户端的秘钥文件也必须是600权限
chmod 600 /etc/rsync.password
ERROR: auth failed on module backup
问题原因
- /etc/rsync.password内用户名和密码有错误
- secrets file = /etc/rsync.password指定的密码文件和实际密码文件名称不一致
- /etc/rsync.password文件权限不是600
- rsync_backup:123456 密码配置文件后面注意不要有空格
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup/ --password-file=/etc/rsync.password
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1656)[sender=3.1.2]
解决方法
#按问题原因逐步排查
ERROR: syntax or usage error (code 1) at authenticate.c(187)
问题原因
加入了–password-file=/etc/rsync.password参数,但是没有创建/etc/rsync.password文件
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup/ --passwordfile=/etc/rsync.password
rsync: could not open password file /etc/rsync.password: No such file or directory (2)
rsync error: syntax or usage error (code 1) at authenticate.c(187)[sender=3.1.2]
解决方法
#:创建/etc/rsync.password文件,并更改权限
echo "1" > /etc/rsync.password
chmod 600 /etc/rsync.password
ERROR: error in socket IO (code 10) at clientserver.c(126) [sender=3.1.2]
问题原因
rsync服务未启动
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup/
rsync: failed to connect to 10.0.0.41 (10.0.0.41): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(126) [sender=3.1.2]
解决方法
#启动服务
systemctl start rsyncd
#开机自启
systemctl enable rsyncd
ERROR: error starting client-server protocol (code 5) at main.c(1656)
问题原因
rsync服务无效用户信息
rsync服务对应rsync虚拟用户不存在了
错误显示过程
[root@web01 ~]# rsync -avz /etc/passwd rsync_user@10.0.0.41::backup/
Password:
@ERROR: invalid uid rsyn
#@ERROR: invalid gid rsyn
rsync error: error starting client-server protocol (code 5) at main.c(1656) [sender=3.1.2]
解决方法
#创建需要的用户
vim /etc/rsyncd.conf
uid = rsync
gid = rsync
.............