##rsync 服务建立
在centos中,rsync是xinet管理的,要建立相关的配置文件
<pre> yum install rsync vim /etc/xinetd.d/rsync # default: off # description: The rsync server is a good addition to an ftp server, as it \ # allows crc checksumming etc. service rsync { disable = no flags = IPv6 socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID } </pre>
##rsync配置
<pre> vim /etc/rsyncd.conf uid = root gid = root port = 873 hosts allow = 0.0.0.0/0 use chroot = max connections = timeout= pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log motd file = /etc/rsyncd.motd [test] path = /root/work/ auth users = rsync secrets file = /etc/rsync.passwd </pre>
这里有一点要注意,注释一定要另起一行,写在行末会发生诡异的错误
/etc/init.d/xinetd restart 启动服务
##远程同步
一般使用 rsync -hvarAEXHi --progress --stats --numeric-ids [USER@]HOST::SRC... [DEST] 命令
参数的作用在 man rsync 中都有详细的介绍,i参数不是一下子就能看明白的,这里详细说一下 参数i 有11个字母长的输出,使用YXcstpoguax说明,Y是更新方式,X是文件类型,其他的代表改过的属性 Y常出现的有:
> 表示文件是传到本地的 * 表示其他的字母包含一个信息(例如,‘deleting’)
X主要有:
f 表示文件 d 表示目录 L 表示链接
其他的字母:
+ 表示新创建的item . 表示同样的item ? 表示未知的item
例子如下:
<pre> >f+++++++++ src/etc/ssl/certs/ca-certificates.crt </pre>
表示 src/etc/ssl/certs/ca-certificates.crt这个文件,从远端传到本地。
<pre> *deleting test.dir/test.txt </pre>
表示test.dir/test.txt这个文件被删除
更多详细的资料参考 man rsync 这里非常的全面。