inotify

rsync+inotify实时同步

匿名 (未验证) 提交于 2019-12-02 23:49:02
1、安装inotify软件 获取软件包 [root@app1-server ~]# wget http://downloads.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz 解压安装 [root@app1-server ~]# tar xf inotify-tools-3.13.tar.gz -C /usr/src/ [root@app1-server ~]# cd /usr/src/inotify-tools-3.13/ [root@app1-server inotify-tools-3.13]# make [root@app1-server inotify-tools-3.13]# make install 安装完成后,就会产生下面两个命令 【等待】【看守】 2、查看命令如何使用,然后编写脚本来实现目录的监控 注意:该脚本应该在app1-server上运行 [root@app1-server inotify-tools-3.13]# inotifywait --help -m  保持监控状态 -q   只打印事件 -e   指定事件 事件 modify   修改 attrib   属性信息 编写脚本实时监控【/tmp/app/java_project】目录

CentOS7添加自定义脚本服务

匿名 (未验证) 提交于 2019-12-02 22:56:40
一、CentOS7添加自定义脚本服务说明 在CentOS7下,已经不再使用chkconfig命令管理系统开机自启动服务和条件自定义脚本服务了,而是使用管理unit的方式来控制开机自启动服务和添加自定义脚本服务。在/usr/lib/systemd/system目录下包含了各种unit文件,有service后缀的服务unit,有target后缀的开机级别unit等。这里介绍自定义脚本服务,如果想把自定义的脚本变成服务进程,都需要写对应的service配置文件,这样才能被unit所管理(注意:自定义开机自启动服务的.service配置文件必须放在/usr/lib/systemd/system这个目录下面)。服务类别又分为服务又分为系统服务(system)和用户服务(user)。 系统服务:开机不登陆就能运行的程序(常用于开机自启)。 用户服务:需要登陆以后才能运行的程序。 二、编写.service配置文件说明 1、[unit]区块:设置管理启动顺序与依赖关系 Description=服务描述 Documentation=路径或url 给出文档位置 定义在某些服务之后启动。例如sshd服务启动必须在network.target sshd-keygen.service服务开启之后才能启动,可以使用如下命令查看sshd服务的配置 Before=服务.target 定义在某些服务之前启动

How do I find out what inotify watches have been registered?

女生的网名这么多〃 提交于 2019-12-02 17:16:45
I have my inotify watch limit set to 1024 (I think the default is 128?). Despite that, yeoman, Guard and Dropbox constantly fail, and tell me to up my inotify limit. Before doing so, I'd like to know what's consuming all my watches (I have very few files in my Dropbox). Is there some area of /proc or /sys, or some tool I can run, to find out what watches are currently registered? inotify filesystem options sysctl fs.inotify opened files lsof | grep inotify | wc -l Increase the values like this sysctl -n -w fs.inotify.max_user_watches=16384 sysctl -n -w fs.inotify.max_user_instances=512 zeekvfu

二进制sersync部署安装

陌路散爱 提交于 2019-12-02 16:19:07
一、为什么要用rsync+sersync架构? 1、sersync是基于inotify开发的,类似于inotify-tools的工具 2、sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或者某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的文件或者目录 二、rsync+inotify-tools与rsync+sersync架构的区别? 1、rsync+inotify-tools a、inotify只能记录下被监听的目录发生了变化(增,删,改)并没有把具体是哪个文件或者哪个目录发生了变化记录下来; b、rsync在同步的时候,并不知道具体是哪个文件或目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此效率很低 2、rsync+sersync a、sersync可以记录被监听目录中发生变化的(增,删,改)具体某个文件或目录的名字; b、rsync在同步时,只同步发生变化的文件或目录(每次发生变化的数据相对整个同步目录数据来说很小,rsync在遍历查找对比文件时,速度很快),因此效率很高。 总结: 当同步的目录数据量不大时,建议使用rsync+inotify 当同步的目录数据量很大时(几百G甚至1T以上)文件很多时,建议使用rsync+sersync

redhat 7.6 安装 inotify-tools

蹲街弑〆低调 提交于 2019-12-02 09:19:17
1.解压inotify-tools tar -zxvpf inotify-tools-3.14.tar.gz 2.cd 到解压的目录 3../configure 编译,然后失败,提示checking no的关联包 . 4.需要安装gcc, yum install gcc -y 5.再次执行步骤3正常安装,接下来执行 make ;makeinstall 两条命令完成安装 来源: https://www.cnblogs.com/MOMING95/p/11740746.html

Retrieve the full path name from inotify_event

杀马特。学长 韩版系。学妹 提交于 2019-12-01 17:26:55
The inotify_event struct looks like this : struct inotify_event { int wd; /* Watch descriptor */ uint32_t mask; /* Mask of events */ uint32_t cookie; /* Unique cookie associating related events (for rename(2)) */ uint32_t len; /* Size of name field */ char name[]; /* Optional null-terminated name */ }; The name part stores only the file name(not the path to the file). How do we get the fully qualified path from the inotify_event struct or do I have to wrap my own struct around it ? Edit: I wait for the events for around 2s and then process it on one go.I maintain a queue of events. My question

Retrieve the full path name from inotify_event

∥☆過路亽.° 提交于 2019-12-01 15:27:56
问题 The inotify_event struct looks like this : struct inotify_event { int wd; /* Watch descriptor */ uint32_t mask; /* Mask of events */ uint32_t cookie; /* Unique cookie associating related events (for rename(2)) */ uint32_t len; /* Size of name field */ char name[]; /* Optional null-terminated name */ }; The name part stores only the file name(not the path to the file). How do we get the fully qualified path from the inotify_event struct or do I have to wrap my own struct around it ? Edit: I

Suppress or prevent duplicate inotifywait events?

末鹿安然 提交于 2019-12-01 14:44:23
Currently inotifywait is watching git server folders. End it emits only when specific file modified. The problem is, when changes are pushed to git server, inotifywait triggers few times. I don’t know why. So how can I do the next: prevent inotifywait from making duplicates? I was thinking about the algorithm: when triggered first time->sleep script so it won’t scan next changes for 5 seconds->resume script. But it sounds idiotic... Can you help me achieving this? Thanks!! As I mentioned in your other question , you can setup first a post-receive hook which would checkout the repo for you

第12章intofy工具实时同步方案

醉酒当歌 提交于 2019-12-01 12:41:28
第12章intofy工具实时同步方案 12.1实时同步的原理与企业应用场景 12.2inotify介绍及数据同步原理 12.2.1 inotfy简介 Inotfy是一种强大的,细粒度的,异步的文件系统时间监控机制,linux内核从2.6.13起加入Inotify支持,通过Inotify可以监控文件系统中的添加,删除,修改,移动等各种事件,利用这个内核接口,第三方软件就可以监控文件系统下文件的各种变化情况,而Inotify-tools正是 这样的监控软件。 12.2.2 Inotify的工作机制 12.2.2 系统架构拓扑 准备条件 只有rsync配置成功后。才可以配置inoify服务,而且此服务只能配置在客户端上。 1) Uname -r查看内核是否满足要求 32 2) ls -l /proc/sys/fs/inotify/ 查看是否支持inotify服务 3) 最重要的一点。只有配置了rsync成功之后,可以推拉,才能在客户端配置inotify服务。 下载inotify源码包(最好将它放入一个文件夹中) 检查是否有安装inotify 如果没有就安装 rpm -qa inotify-tools    没有就先安装epol源 wget -O/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo   

Suppress or prevent duplicate inotifywait events?

纵饮孤独 提交于 2019-12-01 12:37:37
问题 Currently inotifywait is watching git server folders. End it emits only when specific file modified. The problem is, when changes are pushed to git server, inotifywait triggers few times. I don’t know why. So how can I do the next: prevent inotifywait from making duplicates? I was thinking about the algorithm: when triggered first time->sleep script so it won’t scan next changes for 5 seconds->resume script. But it sounds idiotic... Can you help me achieving this? Thanks!! 回答1: As I mentioned