centos6.7rsync端与window2012服务器实时文件同步
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服务器实时文件同步的更多相关文章
- Linux 之 rsync实现服务器的文件同步
rsync实现服务器的文件同步 参考文献链接: 一.rsync实现负载均衡集群文件同步,搭建线上测试部署环境 二.rsync. 三.rsync常见错误. 四.rsync 安装使用详解. 环境部署: 服 ...
- rsync+sersync+inotify实现服务器间文件同步之一
rsync+sersync+inotify实现服务器间文件同步之一:rsync安装配置 2013年12月14日 ⁄ Linux管理, 服务器集群技术 ⁄ 共 4925字 ⁄ rsync+sersync ...
- centos6.5 rsync+inotify实现服务器之间文件实时同步
1. rsync的优点与不足 与传统的cp.tar备份方式相比,rsync具有安全性高.备份迅速.支持增量备份等优点,通过rsync可以解决对实时性要求不高的数据备份需求,例如定期的备份文件服务器数据 ...
- cwRsync window下的跨服务器的文件同步
cwRsync 是window下的文件同步软件,可以跨服务器运行,第一次运行的时候是全部备份同步,之后的同步采用的是增量同步 这个软件分为服务端和客户端. 服务器是需要同步的文件源, 客户端相当于是备 ...
- 云server之间实时文件同步和文件备份的最简单高效的免费方案
分布于不同云计算中心的多台云server,通常须要进行文件同步.以满足业务的须要. 传统的文件同步方案,部署繁琐.同步实时性差.无法令人惬意. 端端Clouduolc,一款纯p2p方式的文件实时 ...
- C#实现服务器间文件同步
using System.IO; /// <summary> /// 远程登陆服务器 /// </summary> /// <param name="remot ...
- 使用inotify+rsync实现服务器间文件同步
1. rsync 1.1 什么是rsync rsync是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.它使用所谓的“Rsync演算法”来使本地和远程两个主机之间的文件达到 ...
- Lsyncd - 实时文件同步工具(精译)
原文: http://axkibe.github.io/lsyncd/ 描述 Lsyncd监视本地目录树事件监视器接口(inotify或fsevents).它聚集并组合事件几秒钟,然后生成一个(或多个 ...
- 本地和服务器(ubuntu)文件同步
秘钥登录远端服务器 rsync -avze 'ssh -i ./id_rsa' root@remoteIp:/xx/remotefile.txt ./localpath (./id_rsa为本地秘钥路 ...
随机推荐
- FMOD变声如何捕获并存储处理音效之后的数据
类似AVAudioEngine的功能,一个Engine可以将N个connect连接(串联和并联)在一起,这样来实现多个输入源,多层处理效果的混合输出.实现这个所需功能也是通过这样的方案来实现的.也就是 ...
- 图论最短路——spfa
今天开始图论的最短路的最后复习,今天自己手打spfa虽然看了一眼书,但是也算是自己打出来的,毕竟很久没打了,而且还是一遍a代码下来15min左右就搞完了,成就感++.所以呢来篇博客记录一下. 香甜的黄 ...
- Making the Grade---poj3666(dp)
题目链接:http://poj.org/problem?id=3666 题意:有一个n个数的序列a,现在要把这些序列变成单调增的或者单调减的序列 b , 其价值为|A1 - B1| + |A2 - B ...
- CF45G Prime Problem 构造+数论
正解:构造+数论 解题报告: 传送门! maya这题好神仙啊我jio得,,,反正我当初听的时候是没有太懂的,,, 首先这题你要知道一些必要的数学姿势 比如哥德巴赫猜想巴拉巴拉的 然后直接讲题趴QAQ ...
- Python命令行解析库argparse(转)
原文:http://www.cnblogs.com/linxiyue/p/3908623.html 2.7之后python不再对optparse模块进行扩展,python标准库推荐使用argparse ...
- AppFog使用
cd ‘你的应用目录’ af login(之后输入你的邮箱和密码) af update ‘你的应用名’ 相关文档:https://docs.appfog.com/getting-started/af- ...
- js-jquery-Validate校验【一】
一.导入 js 库 <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.j ...
- 【剑指offer】跳台阶
一.题目: 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果). 二.思路: 同斐波那契数列. 三.代码:
- linux命令:locate
1.命令简介 locate(locate) 命令用来查找文件或目录. locate命令要比find -name快得多,原因在于它不搜索具体目录,而是搜索一个数据库/var/lib/ml ...
- 小P的故事——神奇的换零钱&&人活着系列之平方数
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2777&cid=1219 这题不会,看了别人的代码 #include <iostre ...