rsync
===
rsync 是一款远程同步软件 远程同步功能的软件,它在同步文件的同时,能够保持原来文件的权限、时间、软硬连接等附加信息 。
它采用C/S的方式进行同步,有人测试首次同步的时候速度较慢,后面同步的时候只同步更改的文件。(这让我想到git,固然他们的目的不同)
- 问题1:在什么状况下用它?
- 问题2:如何使用,例如同步一个目录到远程?
先找一些资料
http://www.iteye.com/topic/604436
http://blog.csdn.net/caianye/article/details/6670750
http://www.cnblogs.com/itech/archive/2009/08/10/1542945.htmlhtml
http://everythinglinux.org/rsync/linux
原理
http://zh.wikipedia.org/wiki/Rsync
http://coolshell.cn/articles/7425.html
回答1: 我翻译了的小段关于rsync的优势和特色。git
Rsync 是一个易用易安装的小工具。Rsync 不只是一个脚本化的FTP会话或者其余形式的文件传输的脚本,它会仅拷贝被改变文件的差量部分,通过压缩,并经过ssh协议安全的传输。这又一点拗口,但它意味着:shell
差量 - 仅仅实际被改变的文件片断将被传输,而非整个文件。这使得更新更快速,这对慢速的调制解调器来讲很是好。 FTP将会传输整个文件,哪怕只有1字节的改变。
安全
压缩 - 小块的差量片断在传输过程通过压缩,进一步节省传输的时间和网络的负载。
服务器
安全的shell - 安全意识强的你确定会喜欢这一点,并为此而使用它。rsync的流能够经过ssh协议加密会话替代rsh,固然这是可选的(若是你不想用ssh,你能够在/etc/inet.d 设置,并重启inet的守护进程,这样就关闭了它的安全性)
网络
回答2:ssh
配置服务器端:tcp
hvn1:~ # cat /etc/rsyncd.conf strict modes=yes port = 873 gid = users log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid [test] uid=root gid=root path= /root/test read only = no write only = no hosts allow = * auth users = root secrets file = /etc/rsyncd.secrets
hvn1:~ # cat /etc/rsyncd.secrets
# user:passwd
root:hello123
hvn1:~ # ll /etc/rsyncd.secrets
-rw------- 1 root root 28 Sep 23 13:40 /etc/rsyncd.secrets
hvn1:~ # ps -ef | grep rsync root 27870 1 0 13:41 ? 00:00:00 /usr/bin/rsync --daemon root 27985 26855 0 13:58 pts/6 00:00:00 grep rsync hvn1:~ # netstat -na | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN tcp 0 0 :::873 :::* LISTEN
配置客户端:
[root@bogon test1]# service xinetd status xinetd (pid 2176) is running...
下载同步:工具
rsync -av --progress --delete root@10.0.23.61::test /root/work/test1/ff/
上传同步:
rsync -av --progress /root/work/test1/ff/ root@10.0.23.61::test