inotify

实时同步sersync实战

∥☆過路亽.° 提交于 2019-11-26 10:17:45
目录 实时同步sersync实战 什么是实时同步 sersync和rsync+inotify对比 sersync项目实战 安装rsync的服务端(backup) NFS服务端部署sersync 实时同步sersync实战 什么是实时同步 实时同步是一种只要当前目录发生变化则会触发一个事件,事件触发后会将变化的目录同步至远程服务器。 sersync和rsync+inotify对比 提到数据同步就必然会谈到 rsync ,一般简单的服务器数据传输会使用 ftp/sftp 等方式,但是这样的方式效率不高,不支持差异化增量同步也不支持实时传输。针对数据实时同步需求大多数人会选择 rsync+inotify-tools 的解决方案,但是这样的方案也存在一些缺陷(文章中会具体指出), sersync 是国人基于前两者开发的工具,不仅保留了优点同时还强化了实时监控,文件过滤,简化配置等功能,帮助用户提高运行效率,节省时间和网络资源。 项目地址 sersync项目实战 1)环境准备 角色 外网IP(NAT) 内网IP(LAN) 安装工具 web01 eth0:10.0.0.7 eth1:172.16.1.7 部署代码(提交作业) nfs-server eth0:10.0.0.31 eth1:172.16.1.31 rsync+inotify+sersync backup eth0:10.0.0

rsync

一曲冷凌霜 提交于 2019-11-26 09:22:55
rsync rsync简介 rsync特性 rsync的ssh认证协议 rsync命令 rsync+inotify rsync简介 rsync是linux系统下的数据镜像备份工具。使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH、rsync主机同步 rsync特性 rsync支持很多特性: 可以镜像保存整个目录树和文件系统 可以很容易做到保持原来文件的权限、时间、软硬链接等等 无须特殊权限即可安装 快速:第一次同步时rsync会复制全部内容,但在下一次只传输修改过的文件。rsync- - 在传输数据的过程中可以实行压缩及解压缩操作,因此可以使用更少的带宽 安全:可以使用scp、ssh等方式来传输文件,当然也可以通过直接的socket连接 支持匿名传输,以方便进行网站镜象 rsync的ssh认证协议 rsync命令来同步系统文件之前要先登录remote主机认证,认证过程中用到的协议有2种: ssh协议 rsync协议 rsync server端不用启动rsync的daemon进程,只要获取remote host的用户名和密码就可以直接rsync同步文件 rsync server端因为不用启动daemon进程,所以也不用配置文件/etc/rsyncd.conf ssh认证协议跟scp的原理是一样的,如果在同步过程中不想输入密码就用ssh

Is there a command like “watch” or “inotifywait” on the Mac?

淺唱寂寞╮ 提交于 2019-11-26 09:10:02
I want to watch a folder on my Mac (Snow Leopard) and then execute a script (giving it the filename of what was just moved into a folder (as a parameter... x.sh "filename")). I have a script all written up in bash (x.sh) that will move some files and other stuff on input $1 I just need OSX to give me the file name when new files/folders are moved/created into a dir. Any such command? cwd fswatch fswatch is a small program using the Mac OS X FSEvents API to monitor a directory. When an event about any change to that directory is received, the specified shell command is executed by /bin/bash If

Is there anything like inotify on Windows?

删除回忆录丶 提交于 2019-11-26 02:18:45
问题 With the Linux OS, there is the ionotify subsystem which notifies an application of changes to the filesystem. However, I am mainly a Windows user, so I was wondering if there is a similar way to monitor filesystem changes? 回答1: See the FindFirstChangeNotification API, or the .NET counterpart FileSystemWatcher 回答2: If you're using .net , use FileSystemWatcher . More info here: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx If you're using C , use

Is there a command like “watch” or “inotifywait” on the Mac?

你说的曾经没有我的故事 提交于 2019-11-26 01:09:52
问题 I want to watch a folder on my Mac (Snow Leopard) and then execute a script (giving it the filename of what was just moved into a folder (as a parameter... x.sh \"filename\")). I have a script all written up in bash (x.sh) that will move some files and other stuff on input $1 I just need OSX to give me the file name when new files/folders are moved/created into a dir. Any such command? 回答1: fswatch fswatch is a small program using the Mac OS X FSEvents API to monitor a directory. When an

部署nfs高可用rsync+inotify

余生颓废 提交于 2019-11-25 23:38:48
项目环境: 三台主机(centos7): nfs-server主:172.16.1.20 nfs-server从:172.16.1.30 client(客户机):172.16.1.40 项目操作: 1, 首先搭建nfs服务器 主从nfs-server都需搭建,相同的操作。 [root@nfs-master ~]# yum -y install nfs-utils #安装nfs服务 [root@nfs-master ~]# yum -y install rpcbind #安装远程传输控制协议 [root@nfs-master ~]# vim /etc/exports #编写nfs文件 /nfs-share 172.16.1.*(rw,sync,no_root_squash) 参数解释: 172.16.1.*:表示允许该网段,也可以自定义ip地址 rw:可读可写 sync:同步数据到磁盘 no_root_squash:加上这个选项后,root用户就会对共享的目录拥有至高的权限控制,就像是对本机的目录操作一样。 [root@nfs-master ~]# mkdir /nfs-share #创建共享目录 [root@nfs-master ~]# systemctl start rpcbind #先启动该服务 [root@nfs-master ~]# systemctl start nfs

How to retrieve a module's path?

非 Y 不嫁゛ 提交于 2019-11-25 23:18:42
问题 I want to detect whether module has changed. Now, using inotify is simple, you just need to know the directory you want to get notifications from. How do I retrieve a module\'s path in python? 回答1: import a_module print(a_module.__file__) Will actually give you the path to the .pyc file that was loaded, at least on Mac OS X. So I guess you can do: import os path = os.path.abspath(a_module.__file__) You can also try: path = os.path.dirname(a_module.__file__) To get the module's directory. 回答2:

rsync+inotify实时同步环境部署

て烟熏妆下的殇ゞ 提交于 2019-11-25 20:24:47
rsync+inotify实时同步环境部署 随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足。 首先,rsync在同步数据时,需要扫描所有文件后进行比对,进行差量传输。如果文件数量达到了百万甚至千万量级,扫描所有文件将是非常耗时的,并且正在发生变化的往往是其中很少的一部分,这是非常低效的方式。 其次,rsync不能实时的去监测、同步数据,虽然它可以通过linux守护进程的方式进行触发同步,但是两次触发动作一定会有时间差,这样就导致了服务端和客户端数据可能出现不一致,无法在应用故障时完全的恢复数据。 基于以上两种情况,可以使用rsync+inotify的组合来解决,可以实现数据的实时同步。 inotify是一种强大的、细粒度的、异步的文件系统事件控制机制。linux内核从2.6.13起,加入了inotify支持,通过inotify可以监控文件系统中添加、删除、修改、移动等各种事件,利用这个内核接口,第三方软件就可以监控文件系统下文件的各种变化情况,而inotify-tools正是实施监控的软件。 在使用rsync首次全量同步后,结合inotify对源目录进行实时监控,只有有文件变动或新文件产生,就会立刻同步到目标目录下,非常高效使用! 需求说明: 分别将 192.168.1.1的/Data/fangfull