rsync使用小结

作者 : admin 于 2010-04-17 22:28:51
2010
04-17

多台服务器使用,难免用到同步,工作中大量接触的是rsync,简单测试了一下其命令和应用。

rsync官方主页: http://samba.anu.edu.au/rsync/ 下载地址为:http://samba.anu.edu.au/ftp/rsync/rsync-3.0.7.tar.gz

安装:

  1. ./configure --prefix=/opt/rsync-3.0.7
  2. make
  3. make install

默认好像没有生成配置文件,创建

  1. vi /etc/rsync.conf
  2. //填入以下内容
  3. uid=nobody
  4. gid=nobody
  5. max connections=3
  6. use chroot=no
  7. log file=/var/log/rsyncd.log
  8. pid file=/var/run/rsyncd.pid
  9. lock file=/var/run/rsyncd.lock

测试的两台主机:192.168.0.20 192.168.0.30

在192.168.0.30的/etc/rsync.conf下增加以下代码

  1. [test]       //定义一个域
  2. path=/root/test
  3. comment=test folder
  4. uid=root
  5. ignore errors
  6. read only=no
  7. list=no

然后测试两个命令
1、把192.168.0.20上的 /root/source 目录同步到 192.168.0.30 的 /root/test上
/opt/rsync-3.0.7/bin/rsync -vazu –progress /root/source 192.168.0.30::test
2、从192.168.0.30 的 /root/test 同步到 192.168.0.20上的/root/test
/opt/rsync-3.0.7/bin/rsync -vzrtopg –progress 192.168.0.30::test /root/test

配置权限:
在192.168.0.30上vi /etc/rsycnpass 然后 echo test:123456 >> /etc/rsycnpass
配置文件修改为

  1. secrets file = /etc/rsyncpass
  2. [test]       //定义一个域
  3. path=/root/test
  4. comment=test folder
  5. uid=root
  6. ignore errors
  7. read only=no
  8. list=no
  9. auth users=test

则上边命令1修改为 /opt/rsync-3.0.7/bin/rsync -vazu –progress /root/source test@192.168.0.30::test
命令2改为 /opt/rsync-3.0.7/bin/rsync -vzrtopg –progress test@192.168.0.30::test /root/test

发表评论




XHTML:你可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(若看不到验证码,请重新加载页面。)