码迷,mamicode.com
首页 > 其他好文 > 详细

rsync远程同步服务

时间:2014-09-09 13:47:08      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:rsync服务

 rsync常用选项
-a:归档模式,相当于-rlptgoD
-v:显示同步过程详细信息
-z:传输过程中启用压缩
-H:保留硬连接文件
-A:保留文件的ACL属性信息
--delete:删除目标有而源没有的文件
--checksum:根据校验和来决定是否要同步
1.发布 rsync  --daemon 共享
1)建立同步账号文件(匿名则不需要)
[root@svr6 ~]# vim  /etc/rsyncd_users.db
ruser:123456                                   //每行一条用户记录
othername:123456
……
[root@svr6 ~]# chmod  600  /etc/rsyncd_users.db   //权限必须严格,否则同步会失败

2)建立 /etc/rsyncd.conf 共享设置

[root@svr6 ~]# vim  /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = yes
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
[tools]
    path = /usr/src
    comment = Rsync Share Test
    read only = yes
    dont compress = *.gz *.bz2 *.tgz *.zip       //适用各种压缩文件
    auth users = ruser                          //允许谁访问
   secrets file = /etc/rsyncd_users.db         //指定账号文件的路径

 2. rsync + rsync 服务器的 上传、下载

[root@svr5 ~]# rsync   //浏览共享
Password:        //验证口令
drwxr-xr-x        4096 2009/10/01 22:58:39 debug
drwxr-xr-x        4096 2009/10/01 22:58:39 kernels
.. ..
[root@svr5 ~]# mkdir  /root/mysrc
[root@svr5 ~]# rsync  -avz  --delete   
 
 /root/mysrc                                 //下行同步,删除多余文件

 3.rsync 实时同步(inotify监控及触发)

1). 安装 inotify-tools 软件包

[root@svr5 ~]# tar zxf inotify-tools-3.13.tar.gz
[root@svr5 ~]# cd inotify-tools-3.13
[root@svr5 inotify-tools-3.13]# ./configure
.. ..
[root@svr5 ~]# make  &&  make  install
2). inotifywait 工具的触发验证
以监控 /root 目录为例,当 /root 目录下的文档有变动时,会立即给出相应提示
[root@svr5 ~]# inotifywait  -mrq -e modify,move,create,delete,attrib  /root
/root/ CREATE,ISDIR tdir1
/root/ CREATE file1.txt
/root/ MODIFY file1.txt
/root/ DELETE file1.txt

rsync远程同步服务

标签:rsync服务

原文地址:http://baixueping.blog.51cto.com/9126294/1549909

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!