使用rsync+inotify同步两台服务器文件
目标功能:将B服务器文件同步到A服务器
A服务器rsyncd.conf配置 权限600

A服务器rsyncd.pas文件配置 权限600

同步文件路径 /data/wwwroot/shen/ 权限755
打开873端口:iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT
保存设置:service iptables save
重启:service iptables restart
启动服务 rsync --daemon --config=/etc/rsyncd.conf
删除文件即可重启rsync rm -rf /var/run/rsyncd.pid
B服务器
rsyncd.pas 权限600

将B服务器中/data/wwwroot/shen/内的所有文件同步到A服务器中
rsync -avH --progress --delete --password-file=/etc/rsyncd.pas /data/wwwroot/shen/ root@112.74.203.95::web
常见错误:http://www.jb51.net/article/31920.htm
查看是否支持inotify ls -lsart /proc/sys/fs/inotify
下载 yum install inotify-tools --enablerepo=epel
检测是否成功安装 inotifywait -h
编写shell脚本
#etc/rc.d/inotify.sh
inotifywait -mrq --format '%Xe %w%f' -e modify,create,delete,attrib /data/wwwroot/shen/ | while read file
do
rsync -avH --progress --delete --password-file=/etc/rsyncd.pas /data/wwwroot/shen root@112.74.203.95::web
done
chmod +x /etc/rc.d/inotify.sh
执行脚本:/etc/rc.d/inotify.sh
使用rsync+inotify同步两台服务器文件的更多相关文章
- CentOS7通过rsync+crontab实现两台服务器文件同步
centos7系统中已经默认安装rsync 1:主服务器配置 (1)修改rsyncd.conf 配置文件 [root@localhost app]# vi /etc/rsyncd.conf motd ...
- linux下两台服务器文件实时同步方案设计和实现
inux下两台服务器文件实时同步方案设计和实现 假设有如下需求: 假设两个服务器: 192.168.0.1 源服务器 有目录 /opt/test/ 192.168.0.2 目标服务器 有目录 /o ...
- Centos 6.5 rsync+inotify 两台服务器文件实时同步
rsync和inotify是什么我这里就不在介绍了,有专门的文章介绍这两个工具. 1.两台服务器IP地址分别为: 源服务器:192.168.1.2 目标服务器:192.168.1.3 @todo:从源 ...
- linux下两台服务器文件实时同步方案实现-乾颐堂
假设有如下需求: 假设两个服务器: 192.168.0.1 源服务器 有目录 /opt/test/ 192.168.0.2 目标服务器 有目录 /opt/bak/test/ 实现的目的就是保持这两 ...
- rsync+inotify实现多台服务器之间数据实时同步
配置环境 1.操作系统:CentOS6.5-X86_64 2.rsync客户端(rsync+inotify):192.168.200.82 3.rsync服务端:192.168.200.80,192. ...
- Windows Server 2012 两台服务器文件同步
下载cwRsyncServer软件安装(这是Windows下的文件同步软件) 一.(1)在文件客户端服务器安装该软件,找到安装位置下的rsyncd.conf,修改配置文件(注意在Windows下输入位 ...
- linux实现多台服务器文件同步
inotify-tools+rsync实时同步文件安装和配置 Linux+Nginx+PHP+MySQL+MemCached+eaccelerator安装优化记录(见 http://www.linux ...
- Centos7 rsync+inotify两台服务器同步文件(单向)
注:本篇介绍的是单向同步,即A文件同步到B,但B的文件不同步到A,双向同步的在下一篇文章中. rsync与inotify不再赘述,直接进入实战. 0.背景 两台服务器IP地址分别为: 源服务器:192 ...
- rsync配置两台服务器之间的文件备份(同步)
rsync配置两台服务器之间的文件备份(同步) 前情提要 环境: 192.168.1.2 主服务器 centos 7.7 192.168.1.3 备份服务器 centos 7.7 rsync 安装(两 ...
随机推荐
- Titanium.App.Properties 对象
Titanium.App.Properties是用来管理键值对数据的一个很方便的对象.在保存数据的时候,在Ti.App.Properties.setString相对应的Key的值中设置你要保存的值即可 ...
- hexo+next博客添加搜索
1.为什么添加algolia搜索 第一当然是可以方便的查找所需文章,第二点就是之前常用的swiftype插件不再免费.我的个人博客是这个月初搭建完成的,这时候swiftype已经不再免费,而且只开放企 ...
- js动态获取子复选项并设计全选及提交
在做项目的时候,会遇到根据父选项,动态的获取子选项,并列出多个复选框,提交时,把选中的合并成一个字符提交后台 本章将讲述如何通过js控制实现该操作: 1:设计父类别为radio,为每一个radio都加 ...
- T-SQL 去除特定字段的前导0
在工作过程中遇到一个需求,要从特定字段中删除前导零,这是一个简单的VARCHAR(10)字段. 例如,如果字段包含"00001A",则SELECT语句需要将数据返回为"1 ...
- MMORPG大型游戏设计与开发(服务器 AI 事件)
AI中的事件与场景中的事件大致相同,都是由特定的条件触发的.只不过AI的事件与其他事件不同的是,对于AI的事件往往是根据不同的AI类型,和动态的触发条件下才产生的.其实不管AI多么智能,它对应的触发条 ...
- canvas贝塞尔曲线 - 1
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvEAAAIcCAIAAADwgGbqAAAgAElEQVR4nOy9a4wb55nn20kOZhq7o8
- liunx关闭防火墙
Redirecting to /bin/systemctl stop iptables.service systemctl stop iptables.service ?????? centos从7开 ...
- [笔记]ng2的webpack配置
欢迎吐槽 前言 angular.cn教程中用的是systemjs加载器,那用webpack应该怎么配置呢?本文 demo: https://github.com/LeventZheng/angular ...
- [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- 【WPF】GridLengthAnimation
参考 : http://zhidao.baidu.com public class GridLengthAnimation : AnimationTimeline { public static re ...