一、服务器端配置
1、rsyncd.conf文件说明
uid = rsync     #用户,用来控制用户访问模块目录的读写权限
gid = rsync     #组,用来控制组访问模块目录的读写权限
use chroot = no     #安全相关
max connections = 50     #最大连接数
timeout = 180     #超时时间(单位为秒)
motd file = /etc/rsyncd/rsyncd.motd     #定义登录服务器时的banner信息
pid file = /var/run/rsyncd.pid     #进程对应的进程号文件
lock file = /var/run/rsync.lock     #锁文件
log file = /var/log/rsyncd.log     #错误日志目录
ignore errors     #忽略错误
read only = false     #可写
list = false     #不能查看服务器上有哪些模块
hosts allow = 172.16.1.0/24 10.10.80.0/24     #允许访问的网段
hosts deny = 0.0.0.0/0     #拒绝其它访问
auth users = rsync     #远程访问用户名
secrets file = /etc/rsync.password     #远程用户访问认证密码文件
[backup]     #目录模块名
path = /backup/     #目录路径
[test]
path = /test/
说明:
ignore errors选项最好加上,否则再很多crontab的时候往往发生错误你也未可知,因为你不可能天天去看每#时每刻去看log,不加上这个出现错误的几率相对会很高,因为任何大点的项目和系统,磁盘IO都是一个瓶颈

2、创建rsyncd.conf文件
[root@backup ~]#vim /etc/rsyncd.conf

uid = rsync
gid = rsync
use chroot = no
max connections =
timeout =
#motd file = /etc/rsyncd.motd
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 10.47.39.0/
hosts deny = 0.0.0.0/
auth users = rsync
secrets file = /etc/rsync.password [backup]
path = /backup/

[root@backup ~]#vim /etc/rsyncd.motd
Welcome login rsync serser!!!!!!
[root@backup ~]# useradd rsync -s /sbin/nologin -M
[root@backup ~]# vim /etc/rsync.password
rsync:123456
[root@backup ~]# chmod 600 /etc/rsync.password
[root@backup ~]# ll /etc/rsync.password
-rw------- 1 root root 13 3月 8 21:51 /etc/rsync.password
[root@backup ~]# rsync --daemon #启动rsync服务
[root@backup ~]# ps -ef|grep rsync|grep -v grep
root 31288 1 0 11:09 ? 00:00:00 rsync --daemon
[root@backup ~]# mkdir /backup
[root@backup ~]# chown -R rsync.rsync /backup
[root@backup ~]# ls -lid /backup
140545 drwx------ 2 rsync rsync 4096 2月 17 2017 /backup

二、客户端配置
[root@backup ~]# vim /etc/rsync.password
123456
[root@backup ~]# chmod 600 /etc/rsync.password
[root@backup ~]# ll /etc/rsync.password
-rw------- 1 root root 13 3月 8 21:51 /etc/rsync.password
[root@backup ~]# rsync -avz /root/install.log rsync@10.47.39.8::backup --password-file=/etc/rsync.password

三、rsync常用错误
问题一:
@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 ‘backup'
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服务器不存在指定模块。提供正确的模块名或在服务器端修改成你要的模块以解决问题。

问题四:
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

问题五:
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 ,这里登陆名不可缺少

问题六:
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

问题七:
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 来查看可用空间和已用空间

问题八:网络问题
1、权限问题
类似如下的提示:rsync: opendir "/kexue" (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测试。
可能因为客户端或者服务端的防火墙开启 导致无法通信,可以设置规则放行 rsync(873端口) 或者直接关闭防火墙。
还有一种在同步过程中可能会提示没有权限 (将同步目录加上SvcwRsync全部权限即可,更简单的方法就是将SvcwRsync设为管理员即可)

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]
说明:导致此问题多半是服务端服务没有被正常启动,到服务器上去查查服务是否有启动,然后查看下 /var/run/rsync.pid 文件是否存在,最干脆的方法是杀死已经启动了服务,然后再次启动服务或者让脚本加入系统启动服务级别然后shutdown -r now服务器

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配置文件中。
Rsync configure:
配置一:
ignore errors
说明:这个选项最好加上,否则再很多crontab的时候往往发生错误你也未可知,因为你不可能天天去看每时每刻去看log,不加上这个出现错误的几率相对会很高,因为任何大点的项目和系统,磁盘IO都是一个瓶颈

Rsync error:
错误一:
@ERROR: auth failed on module xxxxx
rsync: connection unexpectedly closed (90 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
说明:这是因为密码设置错了,无法登入成功,检查一下rsync.pwd,看客服是否匹配。还有服务器端没启动rsync 服务也会出现这种情况。

错误二:
password file must not be other-accessible
continuing without password file
Password:
说明:这是因为rsyncd.pwd rsyncd.sec的权限不对,应该设置为600。如:chmod 600 rsyncd.pwd

错误三:
@ERROR: chroot failed
rsync: connection unexpectedly closed (75 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
说明:这是因为你在 rsync.conf 中设置的 path 路径不存在,要新建目录才能开启同步

错误四:
rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
说明:防火墙问题导致,这个最好先彻底关闭防火墙,排错的基本法就是这样,无论是S还是C,还有ignore errors选项问题也会导致

错误五:
@ERROR: access denied to www from unknown (192.168.1.123)
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(359)
说明:此问题很明显,是配置选项host allow的问题,初学者喜欢一个允许段做成一个配置,然后模块又是同一个,致使导致

错误六:
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(244) [generator=2.6.9]
rsync error: received SIGUSR1 (code 19) at main.c(1182) [receiver=2.6.9]
说明:导致此问题多半是服务端服务没有被正常启动,到服务器上去查查服务是否有启动,然后查看下 /var/run/rsync.pid 文件是否存在,最干脆的方法是杀死已经启动了服务,然后再次启动服务或者让脚本加入系统启动服务级别然后shutdown -r now服务器

错误七:
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(604) [sender=2.6.9]
说明:原数据目录里没有数据存在

问题八:
@ERROR: Unknown module ‘backup'
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服务器不存在指定模块。访问的服务器地址不在hosts allow里或模块名不正确

Linux上rsync配置的更多相关文章

  1. linux上安装配置samba服务器

    linux上安装配置samba服务器 在linux上安装配置samba服务器 在这给大家介绍一个不错的家伙,samba服务.如果您正在犯愁,如何在Windows和Linux之间实现资源共享,就请看看这 ...

  2. Linux上安装配置Keepalived

    Linux上安装配置Keepalived 1.下载 自行去Keepalived官网进行下载,也可以通过如下链接进行下载2.0.18版本(目前的稳定版) 链接:https://pan.baidu.com ...

  3. Linux的rsync 配置,用于服务器之间远程传大量的数据

    [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize) 是一个远程资料同步工具,可通过LAN/WAN快速同步多台主机, ...

  4. linux上网络配置不生效的怪异现象处理

    1.在Linux上.在ifcfg-eth0上设置IP地址等信息 具体配置信息例如以下已 [root@rac01 Desktop]#more/etc/sysconfig/network-scripts/ ...

  5. linux 上安装配置l2tp的客户端

    有些时候我们外网linux服务器需要访问内网的服务器,这时候就需要在外网服务器上配置l2tp的客户端,连接到VPN访问内网服务器. 安装: yum -y install xl2tpd ppp 安装成功 ...

  6. Redis在linux上的配置

    一.安装gcc  1.Redis在linux上的安装首先必须先安装gcc,这个是用来编译redis的源文件的.首先需要先切换的到root用户 2.然后开始安装gcc: yum install gcc- ...

  7. 在 Linux 上安装配置 BitTorrent Sync [转]

    背景介绍:目前我们线上的前端服务器数量比较多,超过200多台,每次发布新应用的时候,都是将软件包放在一台专门的Push服务器上,再由所有的前端服务器通过rsync自动同步.但随着前端服务器的数量越来越 ...

  8. Ubuntu Linux上安装配置Mysql

    一.安装: 三种安装方式: 1. 从网上安装 sudo apt-get install mysql-server.装完已经自动配置好环境变量,可以直接使用mysql的命令. 注:建议将/etc/apt ...

  9. linux上安装配置vsftpd(转)

    转自:http://www.webarch.org/category/linux生产环境是Centos5.6,由于需要提供ftp服务,就找了一款比较小巧的ftp服务器端软件,vsftpd(vsftpd ...

随机推荐

  1. NSIS+Duilib 制作Windows安装包

    转载:https://www.cnblogs.com/zzllily/articles/5443850.html 转载:https://blog.csdn.net/bruce135lee/articl ...

  2. topcoder srm 714 div1

    problem1 link 倒着想.每次添加一个右括号再添加一个左括号,直到还原.那么每次的右括号的选择范围为当前左括号后面的右括号减去后面已经使用的右括号. problem2 link 令$h(x) ...

  3. 5.sql2008分组与嵌套

    1.Group by基本介绍;2.Having的使用;3.分组综合应用;4.子查询基本介绍;5.In/Exists/Any/Some/All;6.子查询综合应用; 1.Group by基本介绍:依据B ...

  4. 深入了解JVW

    Java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时 ...

  5. ZOJ 3609 Modular Inverse(扩展欧几里得)题解

    题意:求乘法逆元最小正正数解 思路:a*x≡1(mod m),则称x 是 a 关于 m 的乘法逆元,可以通过解a*x + m*y = 1解得x.那么通过EXGcd得到特解x1,最小正解x1 = x1 ...

  6. 最最简单的c语言函数汇编分析

    0x01 环境 xp+vc6.0 0x02 代码 int plus(int x, int y) { return 0; } 以下是vc6.0的反汇编窗口 1: int plus(int x, int ...

  7. Linux/shell: remove adjacent similar patterns

    cat > temp004AA1abcAA2AA3abcAA4abcAA5AA6 awk 'BEGIN {pre=0; str="";} { if(NR==1){     i ...

  8. sed命令使用详解

        内容来自马哥视频,感谢马哥精彩讲解 sed:编辑器 sed: Stream EDitor, 行编辑器,逐行进行处理 grep:实现文本过滤 awk:文本报告生成器 sed默认不编辑源文件,而是 ...

  9. 【NOI 2009】诗人小G

    Problem Description 小 \(G\) 是一个出色的诗人,经常作诗自娱自乐.但是,他一直被一件事情所困扰,那就是诗的排版问题. 一首诗包含了若干个句子,对于一些连续的短句,可以将它们用 ...

  10. 【译】第23节---Fluent API - 实体映射

    原文:http://www.entityframeworktutorial.net/code-first/configure-entity-mappings-using-fluent-api.aspx ...