windows文件共享我就不截图了,估计大家都会,我就直接在centos6.7上操作了
一、挂载win共享文件夹
mount -t cifs -o username=administrator,password=123.qwe //192.168.1.205/web /web
#如果报错就是没有安装cifs-utils
#yum -y install cifs-utils
df -h
//192.168.1.205/web   60G  8.6G   52G  15% /web
二、安装rsync
yum install rsync xinetd
编辑配置文件,设置开机启动rsync
vi /etc/xinetd.d/rsync
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}
三、查看系统是否支持inotify并安装
ll /proc/sys/fs/inotify/
-rw-r--r-- 1 root root 0 3月  23 00:47 max_queued_events
-rw-r--r-- 1 root root 0 3月  23 00:47 max_user_instances
-rw-r--r-- 1 root root 0 3月  23 00:47 max_user_watches
tar zxvf inotify-tools-3.13.tar.gz
cd inotify-tools-3.13
./configure --prefix=/usr/local/inotify
make && make install
四、创建脚本,实时触发rsync进行同步

vi rsync.sh
src=/data
target="/web1 /web /web2"
for i in $target;
do
rsync -avH --delete /data/ $i
done
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,delete,create,attrib $src |  while read file
do
for i in $target;
do
rsync -avH --delete /data/ $i
done
done

保存退出啊

五、测试
sh +x rsync.sh
sending incremental file list
./

sent 202 bytes  received 26 bytes  456.00 bytes/sec
total size is 336  speedup is 1.47
sending incremental file list
./
rsync: failed to set times on "/web/.": Permission denied (13)
rsync.sh
1/
10/
2/
3/
4/
5/
6/
7/
8/
9/
lost+found/

sent 614 bytes  received 78 bytes  1384.00 bytes/sec
total size is 336  speedup is 0.49
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
sending incremental file list
./

sent 202 bytes  received 26 bytes  456.00 bytes/sec
total size is 336  speedup is 1.47

查看/web
ll /web
总用量 1
drwxr-xr-x 0 root root   0 3月  22 16:00 1
drwxr-xr-x 0 root root   0 3月  22 16:00 10
drwxr-xr-x 0 root root   0 3月  22 16:00 2
drwxr-xr-x 0 root root   0 3月  22 16:00 3
drwxr-xr-x 0 root root   0 3月  22 16:00 4
drwxr-xr-x 0 root root   0 3月  22 16:00 5
drwxr-xr-x 0 root root   0 3月  22 16:00 6
drwxr-xr-x 0 root root   0 3月  22 16:00 7
drwxr-xr-x 0 root root   0 3月  22 16:00 8
drwxr-xr-x 0 root root   0 3月  22 16:00 9
drwxr-xr-x 0 root root   0 3月  22 14:08 lost+found
-rwxr-xr-x 0 root root 336 3月  22 20:31 rsync.sh

六、添加开机自动挂载

vi /etc/rc.local

mount -t cifs -o username=administrator,password=123.qwe //192.168.1.205/web /web

sh +x /data/rsync.sh >/var/log/rsync.log 2>&1

rsync+inotify实现文件实时同步:

http://www.cnblogs.com/zclzhao/p/4955592.html

centos6.7rsync端与window2012服务器实时文件同步的更多相关文章

  1. Linux 之 rsync实现服务器的文件同步

    rsync实现服务器的文件同步 参考文献链接: 一.rsync实现负载均衡集群文件同步,搭建线上测试部署环境 二.rsync. 三.rsync常见错误. 四.rsync 安装使用详解. 环境部署: 服 ...

  2. rsync+sersync+inotify实现服务器间文件同步之一

    rsync+sersync+inotify实现服务器间文件同步之一:rsync安装配置 2013年12月14日 ⁄ Linux管理, 服务器集群技术 ⁄ 共 4925字 ⁄ rsync+sersync ...

  3. centos6.5 rsync+inotify实现服务器之间文件实时同步

    1. rsync的优点与不足 与传统的cp.tar备份方式相比,rsync具有安全性高.备份迅速.支持增量备份等优点,通过rsync可以解决对实时性要求不高的数据备份需求,例如定期的备份文件服务器数据 ...

  4. cwRsync window下的跨服务器的文件同步

    cwRsync 是window下的文件同步软件,可以跨服务器运行,第一次运行的时候是全部备份同步,之后的同步采用的是增量同步 这个软件分为服务端和客户端. 服务器是需要同步的文件源, 客户端相当于是备 ...

  5. 云server之间实时文件同步和文件备份的最简单高效的免费方案

     分布于不同云计算中心的多台云server,通常须要进行文件同步.以满足业务的须要. 传统的文件同步方案,部署繁琐.同步实时性差.无法令人惬意. 端端Clouduolc,一款纯p2p方式的文件实时 ...

  6. C#实现服务器间文件同步

    using System.IO; /// <summary> /// 远程登陆服务器 /// </summary> /// <param name="remot ...

  7. 使用inotify+rsync实现服务器间文件同步

      1. rsync 1.1 什么是rsync   rsync是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.它使用所谓的“Rsync演算法”来使本地和远程两个主机之间的文件达到 ...

  8. Lsyncd - 实时文件同步工具(精译)

    原文: http://axkibe.github.io/lsyncd/ 描述 Lsyncd监视本地目录树事件监视器接口(inotify或fsevents).它聚集并组合事件几秒钟,然后生成一个(或多个 ...

  9. 本地和服务器(ubuntu)文件同步

    秘钥登录远端服务器 rsync -avze 'ssh -i ./id_rsa' root@remoteIp:/xx/remotefile.txt ./localpath (./id_rsa为本地秘钥路 ...

随机推荐

  1. POJ 2195 - Going Home - [最小费用最大流][MCMF模板]

    题目链接:http://poj.org/problem?id=2195 Time Limit: 1000MS Memory Limit: 65536K Description On a grid ma ...

  2. 加入到java后台开发

    下载java环境安装包 http://www.oracle.com/technetwork/java/javase/overview/index.html 下载eclipse j2ee版本 http: ...

  3. Postman 工具模拟Ajax请求

    1.请求方式 post 2.headers设置:X-Requested-With:XMLHttpRequest    代码判断是以此为依据的 (Content-Type:application/x-w ...

  4. requests的post请求:百度翻译

    import json import requests class Trans(object): def __init__(self, juzi): self.juzi = juzi self.bas ...

  5. 前端 HTML的规范

    1.编写HTML规范 1)所有标记元素都要正确的嵌套,不能交叉嵌套.正确写法举例:<h1><font></font></h1> (2)HTML标签通常是 ...

  6. android activity and fragment活动周期

    1.状态 /* 每个活动一共有四种状态 *:1.运行状态,就是栈顶的那个 * 2.暂停状态:就是不处于栈顶,但是依然可见,比如对话框下面的界面 * 3.停止状态:不处于栈顶,并且不可见 * 4.销毁状 ...

  7. python中各种数据类型

    数字类型 整型int 作用:年纪,等级,身份证号,qq号等与整型数字有关 定义: age=10 #本质age=int(10) 浮点型float 作用:薪资,身高,体重等与浮点数相关 salary=3. ...

  8. PAT 1023 Have Fun with Numbers[大数乘法][一般]

    1023 Have Fun with Numbers (20)(20 分) Notice that the number 123456789 is a 9-digit number consistin ...

  9. 使用Python2.7 GET Onenet平台的数据

    效果 代码 # -*- coding: utf-8 -*- """ ------------------------------------------------- F ...

  10. Redis日常使用随笔

    Redis常用配置:1.采用master与slave互为主从的方式,两条重要命令:redis 127.0.0.1:6379> SLAVEOF NO ONEredis 127.0.0.1:6379 ...