Linux Rsync

一、Rsync介绍

1、什么是Rsync

Rsync 即Remote Rynchronization,是一款开源的、快速的、多功能的、可实现全量或增量的本地或者远程数据镜像同步复制、备份的优秀工具。

类似于scp命令,但是优于scp,可以做增量的备份。Rsync还可以在本地主机的不同分区或目录之间全量及增量的复制数据,这类似与cp命令,同样优于cp命令(增量)。

Rsync 是一个远程数据同步工具,可通过 LAN/WAN 快速同步多台主机间的文件。

Rsync 使用所谓的“Rsync 演算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。

运行 Rsync server 的机器也叫 backup server,一个 Rsync server 可同时备份多个 client 的数据;也可以多个Rsync server 备份一个 client 的数据。
Rsync 可以搭配 rsh 或 ssh 甚至使用 daemon 模式。Rsync server 会打开一个873的服务通道(port),等待对方(客户端) Rsync 连接。连接时,Rsync server 会检查口令是否相符,若通过口令查核,则可以开始进行文件传输。第一次连通完成时,会把整份文件传输一次,下一次就只传送二个文件之间不同的部份。

2、Rsync特性

支持拷贝特殊文件如链接、设备等
支持排除特定文件或目录同步的功能,相当于打包命令tar的排除功能。
支持保持源文件或目录的权限、时间、软硬链接、属主属组等所有属性的不改变。
支持实现增量同步,既只同步发生变化的数据,因为数据传输效率很高。
支持使用rcp、rsh、ssh等方式配合传输文件,也可以直接通过socket(进程方式)传输。
支持匿名的或认证(无需系统用户)的进程模式传输,可实现方便安全的进行数据备份及镜像。

二、Rsync配置

1、Rsync安装

一般的linux系统上都默认安装得了rsync 。如若没有安装请自行安装。

2、Rsync主要配置文件

rsyncd.conf(主配置文件)、rsyncd.secrets(密码文件)

rsyncd.conf 服务器的主要配置文件:

transfer logging = true
log format = %h %o %f %l %b
log file = /wy/logs/rsyncd.log
pid file = /var/run/rsyncd.pid
[data]
        path = /wy/data/doc
        comment = wydoc
        ignore errors = yes
        read only = no
        uid = root
        gid = root
        list = no
        hosts allow = 115.182.93.132  10.200.93.132
        hosts deny = *
        max connections = 10
        auth users = wy
        secrets file = /etc/rsyncd.secrets
        exclude =  dir1/  dir2/

auth users是必须在服务器上存在的真实的系统用户,如果你想用多个用户以,号隔开,比如auth users = nobody,root

#在rsync 服务器中,全局定义有几个比较关健的,根据我们前面所给的配置文件 rsyncd.conf 文件;
  pid file = /var/run/rsyncd.pid   注:告诉进程写到 /var/run/rsyncd.pid 文件中;
  port = 873  注:指定运行端口,默认是873,您可以自己指定;
  address = 192.168.1.171  注:指定服务器IP地址
  uid = nobody
  gid = nobdoy
  注:服务器端传输文件时,要发哪个用户和用户组来执行,默认是nobody。 如果用nobody 用户和用户组,可能遇到权限问题,有些文件从服务器上拉不下来。所以我就偷懒,为了方便,用了root 。不过您可以在定义要同步的目录时定义的模块中指定用户来解决权限的问题。
  
    use chroot = yes
  注:用chroot,在传输文件之前,服务器守护程序在将chroot 到文件系统中的目录中,这样做的好处是可能保护系统被安装漏洞侵袭的可能。缺点是需要超级用户权限。另外对符号链接文件,将会排除在外。也就是说,你在 rsync服务器上,如果有符号链接,你在备份服务器上运行客户端的同步数据时,只会把符号链接名同步下来,并不会同步符号链接的内容;这个需要自己来尝试

  read only = yes
  注:read only 是只读选择,也就是说,不让客户端上传文件到服务器上。还有一个 write only选项,自己尝试是做什么用的吧;

  #limit access to private LANs
  hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
  注:在您可以指定单个IP,也可以指定整个网段,能提高安全性。格式是ip 与ip 之间、ip和网段之间、网段和网段之间要用空格隔开;

  max connections = 5
  注:客户端最多连接数

  motd file = /etc/rsyncd/rsyncd.motd
  注:motd file 是定义服务器信息的,要自己写 rsyncd.motd 文件内容。当用户登录时会看到这个信息。

  log file = /var/log/rsync.log
  注:rsync 服务器的日志; 

  transfer logging = yes
  注:这是传输文件的日志

  log format = %t %a %m %f %b
  syslog facility = local3
  timeout = 300

模块定义
  模块定义什么呢?主要是定义服务器哪个目录要被同步。每个模块都要以[name]形式。这个名字就是在rsync 客户端看到的名字,其实有点象Samba服务器提供的共享名。而服务器真正同步的数据是通过path 指定的。我们可以根据自己的需要,来指定多个模块。每个模块要指定认证用户,密码文件、但排除并不是必须的
  下面是前面配置文件模块的例子:

  [home]  #模块它为我们提供了一个链接的名字,在本模块中链接到了/home目录;要用[name] 形式
  path = /usr/local/tomcat/webapp/home/statics    #指定文件目录所在位置,这是必须指定的
  auth users = root   #认证用户是root  ,是必须在服务器上存在的用户
  list=yes   #list 意思是把rsync 服务器上提供同步数据的目录在服务器上模块是否显示列出来。默认是yes 。如果你不想列出来,就no ;如果是no是比较安全的,至少别人不知道你的服务器上提供了哪些目录。你自己知道就行了;
  ignore errors  #忽略IO错误
  secrets file = /etc/rsyncd.secrets   #密码存在哪个文件
  comment = linuxsir home  data  #注释可以自己定义
  exclude = dir1/ dir2/
  注:exclude是排除的意思,也就是说,要把/usr/local/tomcat/webapp/home/statics目录下的easylife和samba排除在外; dir1/和dir2/目录之间有空格分开

rsyncd.secrets

#目录、用户权限创建配置
[[email protected]_A ~]# useradd rsync -s /sbin/nologin -M
[[email protected]_A ~]# grep rsync /etc/passwd
rsync:x:502:502::/home/rsync:/sbin/nologin#修改属主
[[email protected]_A ~]# chown rsync.rsync /skyex/
[[email protected]_A ~]# ls -ld /skyex/
drwxr-xr-x 2 rsync rsync 167936 May 30 22:10 /skyex/
#配置密码文件(格式---> 用户:密码)
[[email protected]_A ~]# echo "rsync_backup:skyex" >> /etc/rsync.password
[[email protected]_A ~]# cat /etc/rsync.password
rsync_backup:skyex
#修改权限更改密码文件权限600
[[email protected]_A ~]# chmod 600 /etc/rsync.password
[[email protected]_A ~]# ls -ld /etc/rsync.password
-rw------- 1 root root 19 May 27 22:14 /etc/rsync.password

3、启动Rsync服务

#启动rsync
[[email protected]_A ~]# rsync --daemon
#查看rsync进程
[[email protected]_A ~]# ps -ef|grep rsync
root 2779 1 0 22:41 ? 00:00:00 rsync --daemon
root 2785 2678 0 22:41 pts/0 00:00:00 grep rsync
#根据端口查看进程
[[email protected]_A ~]# lsof -i tcp:873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 2779 root 4u IPv4 8610 0t0 TCP *:rsync (LISTEN)
[[email protected]_A ~]# netstat -lntup |grep 873
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2779/rsync

    Rsync 客户端配置

#配置密码文件
[[email protected]_B ~]# echo "skyex">>/etc/rsync.secrets
[[email protected]_B ~]# cat /etc/rsync.secrets
skyex
#更改密码文件权限为600
[[email protected]_B ~]# chmod 600 /etc/rsync.secrets
[[email protected]_B ~]# ls -ld /etc/rsync.secrets
-rw------- 1 root root 6 May 27 22:17 /etc/rsync.secrets

三、Rsync的工作方式

1、主机本地间的数据传输(类似cp命令的功能)
    2、借助rcp、ssh等通道来传输数据(类似scp命令的功能)
    3、以守护进程(socket)的方式传输数据

本地数据传输模式(local-only mode)

1 Local: rsync [OPTION...] SRC... [DEST]

通过远程shell进行数据传输(remote shell mode)

1 Access via remote shell:
2 Pull: rsync [OPTION...] [[email protected]]HOST:SRC... [DEST]
3 Push: rsync [OPTION...] SRC... [[email protected]]HOST:DEST

通过守护进程的方式进行数据传输

1 Access via rsync daemon:
2 Pull: rsync [OPTION...] [[email protected]]HOST::SRC... [DEST]
3 rsync [OPTION...] rsync://[[email protected]]HOST[:PORT]/SRC... [DEST]
4 Push: rsync [OPTION...] SRC... [[email protected]]HOST::DEST
5 rsync [OPTION...] SRC... rsync://[[email protected]]HOST[:PORT]/DEST

Rsync命令同步参数选项
  rsync [OPTION...] SRC ... DEST
  常用参数选项说明:
  -v, --verbose 详细模式输出,传输时的进度等信息
  -z, --compress 传输时进行压缩以提高传输效率,--compress-level=NUM可按级别压缩
  -r, --recursive 对子目录以递归模式,即目录下的所有目录都同样传输,注意是小写r
  -t, --times 保持文件时间信息
  -o, --owner 保持文件属主信息
  -p, --perms 保持文件权限
  -g, --group 保持文件属组信息
  -P, --progress 显示同步的过程及传输时的进度等信息
  -a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rtopgDl 
  -D, --devices 保持设备文件信息
  -l, --links 保留软链接
  -e, --rsh=COMMAND 使用的信道协议, 指定替代rsh的shell程序。例如:ssh 
  --exclude=PATTERN 指定排除不需要传输的文件模式

rsync -avz /opt/ /mnt #加/,只同步目录内的内容
   rsync -avz /opt /mnt #不加/,会将目录和目录内的内容一起同步

四、具体应用

通过Rsync在本地传输数据实践

#通过rsync命令,推送56_rsync_a.log到10.0.0.57的家目录
[[email protected]_A ~]# ll
total 76
-rw-r--r-- 1 root root 0 May 30 20:34 56_rsync_a.log
-rw------- 1 root root 967 May 21 02:09 anaconda-ks.cfg
-rw-r--r-- 1 root root 41751 May 21 02:08 install.log
-rw-r--r-- 1 root root 4688 May 21 02:06 install.log.syslog
-rw-r--r-- 1 root root 2832 May 13 11:08 system_init.sh
[[email protected]_A ~]# rsync -avzP 56_rsync_a.log [email protected]:~
sending incremental file list
56_rsync_a.log
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/1)
14 sent 75 bytes received 31 bytes 212.00 bytes/sec
total size is 0 speedup is 0.00
17 [[email protected]_B ~]# ll
total 68
-rw-r--r-- 1 root root 0 May 30 20:34 56_rsync_a.log
-rw------- 1 root root 967 May 21 02:09 anaconda-ks.cfg
-rw-r--r-- 1 root root 41751 May 21 02:08 install.log
-rw-r--r-- 1 root root 4688 May 21 02:06 install.log.syslog
#通过rsync命令,拉取10.0.0.57主机/tmp目录数据到本地/tmp目录下
[[email protected]_B tmp]# ll
total 4
-rw-r--r-- 1 root root 0 May 30 21:38 57.tmp.log
drwx------ 2 root root 4096 May 30 21:04 ssh-XpIRDi2492
30 [[email protected]_A ~]# ll /tmp/
total 8
drwx------ 2 root root 4096 May 30 20:09 ssh-aiWOPN2537
-rw-r--r-- 1 root root 2832 May 13 11:08 system_init.sh
[[email protected]_A ~]# rsync -avz [email protected]:/tmp /tmp
receiving incremental file list
tmp/
tmp/57.tmp.log
tmp/.ICE-unix/
tmp/ssh-XpIRDi2492/
tmp/ssh-XpIRDi2492/agent.2492
42 sent 45 bytes received 210 bytes 510.00 bytes/sec
total size is 0 speedup is 0.00
[[email protected]_A ~]# ll /tmp/
total 12
drwx------ 2 root root 4096 May 30 20:09 ssh-aiWOPN2537
-rw-r--r-- 1 root root 2832 May 13 11:08 system_init.sh
drwxrwxrwt 4 root root 4096 May 30 2013 tmp
[[email protected]_A ~]# tree /tmp/
/tmp/
|-- ssh-aiWOPN2537
| `-- agent.2537
|-- system_init.sh
`-- tmp
|-- 57.tmp.log
`-- ssh-XpIRDi2492
`-- agent.2492
59 3 directories, 4 files

借助rcp、ssh等通道来传输数据实践

#通过ssh通道推送数据
[[email protected]_A ~]# rsync -avzP -e "ssh -p22" 56_rsync_a.log [email protected]:/tmp
sending incremental file list
56_rsync_a.log
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/1)
 7 sent 75 bytes received 31 bytes 212.00 bytes/sec
total size is 0 speedup is 0.00
10 [[email protected]_B ~]# ll /tmp/
total 4
-rw-r--r-- 1 root root 0 May 30 20:34 56_rsync_a.log
-rw-r--r-- 1 root root 0 May 30 21:38 57.tmp.log
drwx------ 2 root root 4096 May 30 21:04 ssh-XpIRDi2492
#通过ssh通道拉取数据
[[email protected]_A ~]# rsync -avz -e "ssh -p22" [email protected]:/tmp .
receiving incremental file list
tmp/
tmp/56_rsync_a.log
tmp/57.tmp.log
tmp/.ICE-unix/
tmp/ssh-XpIRDi2492/
tmp/ssh-XpIRDi2492/agent.2492
26 sent 64 bytes received 274 bytes 676.00 bytes/sec
total size is 0 speedup is 0.00
[[email protected]_A ~]# ll
total 80
-rw-r--r-- 1 root root 0 May 30 20:34 56_rsync_a.log
-rw------- 1 root root 967 May 21 02:09 anaconda-ks.cfg
-rw-r--r-- 1 root root 41751 May 21 02:08 install.log
-rw-r--r-- 1 root root 4688 May 21 02:06 install.log.syslog
-rw-r--r-- 1 root root 2832 May 13 11:08 system_init.sh
drwxrwxrwt 4 root root 4096 May 30 2013 tmp
[[email protected]_A ~]# tree tmp/
tmp/
|-- 56_rsync_a.log
|-- 57.tmp.log
`-- ssh-XpIRDi2492
`-- agent.2492
43 1 directory, 3 files

通过ssh key+rsync实现批量免密码加密分发数据

#批量将任意文件服务分发至/tmp目录下
#!/bin/sh
. /etc/init.d/functions
if [ $# -ne 1 ];then
echo "Usage:$0 argv"
 exit
fi
for ip in `cat iplist`
do
rsync -avzP $1 -e "ssh -p 52113" [email protected]$ip:~ >&/dev/null
ssh -p52113 -t [email protected]$ip sudo rsync ~/$1 /etc >&/dev/null
if [ $? -eq 0 ];then
action "fenfa $1 successful." /bin/true
else
action "fenfa $1 failure." /bin/false
 fi
done

 以守护进程(socket)的方式传输数据

 Rsync推送数据

#推送/var/www/html到服务器端
[[email protected]_B script]# cd /var/www/
[[email protected]_B www]# tar zcvf html_$(date +%F).tar.gz ./html/
./html/
./html/d
./html/a
./html/c
./html/e
./html/b
./html/f
[[email protected]_B www]# ll
total 8
drwxr-xr-x 2 root root 4096 May 30 23:44 html
-rw-r--r-- 1 root root 190 May 30 23:59 html_2013-05-30.tar.gz
[[email protected]_B www]#
#推送数据压缩包至rsync服务器skyex模块内
[[email protected]_B www]# rsync -avzP html_2013-05-30.tar.gz [email protected]::skyex
Password:
sending incremental file list
html_2013-05-30.tar.gz
190 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/1)
24 sent 277 bytes received 27 bytes 46.77 bytes/sec
total size is 190 speedup is 0.62
#免密码输入,推送数据
[[email protected]_B www]# rsync -avzP html_2013-05-30.tar.gz [email protected]::skyex --password-file=/etc/rsync.password
sending incremental file list
31 sent 43 bytes received 8 bytes 102.00 bytes/sec
total size is 190 speedup is 3.73
[[email protected]_B www]#
#通过rsync协议进行推送
[[email protected]_B www]# rsync -avzP html_2013-05-30.tar.gz rsync://[email protected]/skyex --password-file=/etc/rsync.password
sending incremental file list
39 sent 43 bytes received 8 bytes 102.00 bytes/sec
total size is 190 speedup is 3.73
[[email protected]_B www]#

客户端拉取

/usr/bin/rsync -avzP --password-file=/etc/rsyncd/rsyncd.secrets [email protected]::data /var/www/statics/

 五、总结

 Rsync 工作模式

  1.拷贝本地文件;当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式。

2.使用一个远程shell程序(如rsh、ssh)来实现将本地机器的内容拷贝到远程机器。当DST路径地址包含单个冒号":"分隔符时启动该模式。

3.使用一个远程shell程序(如rsh、ssh)来实现将远程机器的内容拷贝到本地机器。当SRC地址路径包含单个冒号":"分隔符时启动该模式。

4. 从远程rsync服务器中拷贝文件到本地机。当SRC路径信息包含"::"分隔符时启动该模式。

5. 从本地机器拷贝文件到远程rsync服务器中。当DST路径信息包含"::"分隔符时启动该模式。

6. 列远程机的文件列表。这类似于rsync传输,不过只要在命令中省略掉本地机信息即可。

通过与crontab结合使用,让这个脚本定时运行。

Rsync 服务端部署流程

  1、配置rsync配置文件

  2、创建同步的本地目录/skyex,并根据需要授权rsync服务的用户可读写/ skyex。目录和/etc/rsync.passwore为配置文件中path = / skyex参数的配置

  3、账号及密码文件配置

  4、启动rsync服务

Rsync客户端配置流程

  1、echo “123”>/etc/rsync.password

  2、chmod 600 /etc/rsync.password

  提示:客户端的和服务端的/etc/rsync.password没有任何关系。只要/etc/rsync.password和客户端rsync命令中的参数--password-file=/etc/rsync.password中的路径对应即可。

Rsync服务端的排错思路

  1、查看rsync服务配置文件路径是否正确,默认路径为/etc/rsyncd.conf

  2、查看配置文件里host allow,host deny,允许的ip网段是否允许客户端访问的ip网段。

  3、查看配置文件中path参数里的路径是否存在,权限是否正确(正常应为配置文件中的UID参数对应的属主和组)

  4、查看rsync服务是否启动。查看命令为:ps -ef|grep rsync,端口是否存在netstat -lnt|grep 873

  5、查看iptables防火墙和selinux是否开启允许rsync服务通过,也可以考虑关闭。

  6、查看服务端rsync配置的密码文件是否为600权限,密码文件格式是否正确,正确格式为:用户名:密码,文件路径和配置文件里的secrect file路径一致。

Rsync客户端的排错思路

  1、查看客户端rsync配置的密码文件是否为600的权限,密码文件格式是否正确  注意:仅需要有密码。并且和服务端的密码一致。

  2、用telnet链接rsync服务器IP地址873端口,查看服务是否启动(可测试服务端防火墙是否阻挡)。telnet 10.0.0.141 873

  3、客户端执行命令时rsync -avzrtopgP [email protected]::skyex/test /test --password-file=/etc/rsync.password

参考:http://www.cnblogs.com/lycn/articles/3259331.html

由于本人经验有限,文章中难免会有错误,请浏览文章的您指正或有不同的观点共同探讨!

时间: 12-10

Linux Rsync的相关文章

linux rsync介绍(八)

[教程主题]:rsync [1] rsync介绍 Rsync(Remote Synchronize) 是一个远程资料同步工具,可通过LAN/WAN快速同步多台主机,Rsync使用所为的“Rsync演算法”来使本地主机和远程主机之间达到同步,这个演算法并不是每次都整份传送,它只传送两台计算机之间所备份的资料不同的部分,因此速度相当快. Rsync的优点如下: 1.可以镜像保存整个目录树和文件系统. 2.可以很容易的做到保持原来文件的许可权.时间.软链接等. 3.无须特使许可权即可安装. 4.拥有优

Linux rsync实现断点续传

Linux 主机之间即时传送文件,scp命令大家都很熟悉但当要传送的文件较大,过程中如果网络中断了,就比较悲剧了.这时候可以考虑使用rsync命令替代scp,实现断点续传文件. 试验:rsync使用 环境:2台RHEL 5.7 需求:主机A传送文件夹TestDB到主机B rsync -rP --rsh=ssh /home/oracle/TestDB/ [email protected]:/home/oracle/TestDB 实验rsync断点续传的过程记录: [[email protected

[rsync] linux rsync 安装

linux rsync 安装 作者:flymaster qq:908601287 blog:http://www.cnblogs.com/flymaster500/ rsync作用比较:远程拷贝:scp本地拷贝:cp删除功能:rm rsync可以是一个网络服务(port socket)rsync命令是客服端命令:第一种工作模式:localrsync -avz /etc/hosts /tmp/ ===cprsync -avz --delete /null/ /tmp/ ===rm第二种工作模式:r

Linux rsync数据同步命令解析

rsync命令 rsync有六种不同的工作模式: 1)拷贝本地文件.当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式. rsync -a /data /backup 2)使用一个远程shell程序(如rsh.ssh)来实现将本地机器的内容拷贝到远程机器.当DST路径地址包含单个冒号":"分隔符时启动该模式. rsync -avz *.c foo:src 3)使用一个远程shell程序(如rsh.ssh)来实现将远程机器的内容拷贝到本地机器.

linux rsync实时同步

rsync同步 同步与复制的差异:复制:完全拷贝源到目标同步:增量拷贝,只传输变化过的数据 同步操作:remote sync 远程同步支持本地复制,或与其他ssh,rsync主机同步.官方网站:http://rsync.samba.org/ 命令用法rsync [选项] 源目录 目标目录常用选项:-a:归档模式,相当于-rlptgiD-v:显示同步过程详细信息 -z:传输过程中启用压缩 -r:递归,包括目录/子目录及所有文件-l:保留符号链接文件-p,-t:保留文件的权限,时间标记-o,-g:保

linux rsync配置及用法

rsync介绍 rsync 是一款开源的.快速的.多功能的.可实现全量及增量的本地或远程数据同步备份的优秀工具.并且可以不进行改变原有数据的属性信息.实现数据的备份迁移特性.Rsync软件适用于unlx.linux.windows等多种操作系统平台.可以实现本地或者异地备份 rsync包含的功能 1.rsync包含cp功能 命令 参数 源文件 目标文件 [[email protected] caojiaoyue]# ls /tmp/[[email protected] caojiaoyue]#

linux rsync 远程同步

rsync(Remote Sync) 是一个Unix/linux系统下的文件同步和传输工具.Rsync通过"rsync算法"提供了一个客户机和远程文件服务器的文件同步的快速方法.   工作机制:  在远程同步任务中,负责发起rsync同步操作的客户机称为发起端,而负责响应来自客机的rsync同步操作的服务器称为备份源.在下行同步(下载)中,备份源负责提供文档的原始位置,发起端应对该位置具有读取权限:在上行同步(上传)中,备份源负责提供文档的目标位置,发起端应对该位置具有写入权限. rs

linux rsync服务

1.rsync介绍rsync是一个开源的,快速的,多功能的,可实现全量及增量的本地或远程数据同步备份的优秀工具,rsync软件适用于nunix/linux/windows多操作系统上运行.官方网站:http://www.samba.org/ftp/rsync/rsync.htmlrsync 英文全称为remote rynchronization.rsyn的特性:1)支持拷贝特殊文件如连接文件,设备等.2)可以有排除指定文件或目录同步到功能,相当于打包命令tar的排除功能.3)可以做到保持原文件或

Linux rsync 命令详解

服务器之间常常要保持些文件或目录的一致,比如一些大的软件下载网站,它们通常使用多台服务器来提供下载服务.当一台服务器上的文件更新后,其它的服务器 也需要更新,而且 在更新的时候应该是只对新增或是修改过的文件进行更新,否则会造成网络带宽和时间的浪费.rsync就是能有效的保持文件及目录的一致的优秀软件. rsync,remote synchronize 顾名思意就知道它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限.时间.软硬链接等附加信息,而且可以通过ssh方式来传输文