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

最新文章

  1. 添加群组表AppGroup和群组详细表AppGroupDetails
  2. jQuery MiniUI开发系列之:安装部署
  3. 《Zend studio 12 + UPUPW+PHP5.4开发平台配置过程》
  4. 测试管理_测试人员招聘[持续更新ing]
  5. java类的访问权限
  6. 关于SQL语言的优化(Oracle)
  7. HDU - 5187 - zhx's contest (高速幂+高速乘)
  8. C# 通过hessian调Java注意事项
  9. android 自定义ViewGroup和对view进行切图动画实现滑动菜单SlidingMenu[转]
  10. MES制造执行系统启动篇
  11. Deep Learning速成教程
  12. 《Ext JS 4.2 实战》可以买了
  13. [ Java面试题 ]算法篇
  14. 关于idea easyui 引入css js
  15. [MySQL Code]Innodb 锁分配和锁冲突判断
  16. 总结:Java 集合进阶精讲1
  17. ffmpeg 视频实现各种特效
  18. opencvbase 实现opencv打开摄像头和初步处理等效果操作(附源码)
  19. MyCAT 源码解析 —— 分片结果合并(使用unsaferow)
  20. 树莓派3代B型 Raspberry Pi Model 3 B 安装 centos7系统

热门文章

  1. HDU 6312 - Game - [博弈][杭电2018多校赛2]
  2. POJ 2318 - TOYS - [计算几何基础题]
  3. MyBatis学习(一)一个简单的例子
  4. PXE配置手记(Linux)
  5. Python面试网络编程和并发
  6. mysql数据库的相关练习题及答案
  7. 牛客练习赛18E pocky游戏 状压dp
  8. 【python-opencv】几何变换
  9. 爱上 SQLAlchemy 的 10 个理由(转)
  10. 前端 HTML body标签相关内容 常用标签 换行标签 br