inotify

Is there a way to watch a mysql database for changes using perl?

我们两清 提交于 2019-11-30 04:03:43
问题 I'm looking for a solution similar to the inotify method of watching files for changes. I'm aware that I could watch the binlog file of the mysql database and run queries to pick out the new results but that seems very inefficient and inelegant; as does simply doing masses of queries in a loop waiting for new results. 回答1: If you add a TRIGGER to the table(s) you're interested in, you can use that to alert the watching application. You could do that in a number of ways: Create an audit table

源码包的安装、rsync同步、inotify监测

China☆狼群 提交于 2019-11-30 00:50:51
一、源码包的安装   1.源码包的作用:yum 使用的是rpm包,rpm包安装的不能指定安装位置           源码包可以按需选择/定制,及时修复bug ,适用于各种平台   2、大致过程:源码包——>make gcc将源码包变成可执行的程序---->运行安装   3.这就要求make,gcc软件支持,yum 下安装make 和gcc   4、下载源码包 wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz   5 、解压源码包:[root@localhost ~]# tar -xf inotify-tools-3.14.tar.gz -C /opt/   解压完可以在解压目录下查看: [root@localhost ~]# ls /opt inotify-tools-3.14 rh [root@localhost ~]# ls /opt/inotify-tools-3.14 aclocal.m4 ChangeLog config.h.in configure COPYING INSTALL libinotifytools Makefile.am man NEWS src AUTHORS config.guess config.sub configure.ac

监控文件事件

别等时光非礼了梦想. 提交于 2019-11-29 20:04:53
1.作用:   对 文件或目录 进行监控,探测是否发生特定事件。 2.相关api int inotify_init();   创建监控实例,返回句柄。 int inotify_add_watch(int fd, const char *pathname, uint32_t mask);   添加监控事件,返回监控描述符。   注意:inotify_add_watch对文件有一次性读操作,所以需要有读权限。 int inotify_rm_watch(int fd, uint32_t wd);    删除监控项 3.inotify_event struct inotify_event { int wd; // 监控描述符 uint32_t mask; //事件 uint32_t cookie; // 相关事件,只用于重命名 uint32_t len; //name域长度 char name[]; //可选的以null结尾的字符串 }      使用read可以获得一个或多个event。   如果read的buf不足一个event,则失败,返回EINVAL.   read buf的最小长度 sizeof(struct inotify_event) + MAX_NAME_LEN + 1   inotify是一个环形队列,所以可以描述事件发生顺序。  

Linux命令:inotifywait

六眼飞鱼酱① 提交于 2019-11-29 18:26:04
inotifywait命令 Inotify 一种强大的、细粒度的、异步文件系统监控机制,它满足各种各样的文件监控需要,可以监控文件系统的访问属性、读写属性、权限属性、删除创建、移动等操作,也就是可以监控文件发生的一切变化。。 inotify-tools 是一个C库和一组命令行的工作提供Linux下inotify的简单接口。inotify-tools安装后会得到 inotifywait 和 inotifywatch 这两条命令: inotifywait命令 可以用来收集有关文件访问信息,Linux发行版一般没有包括这个命令,需要安装inotify-tools,这个命令还需要将inotify支持编译入Linux内核,好在大多数Linux发行版都在内核中启用了inotify。 inotifywatch命令 用于收集关于被监视的文件系统的统计数据,包括每个 inotify 事件发生多少次。 开始之前需要检测系统内核是否支持inotify: 使用 uname -r 命令检查Linux内核,如果低于2.6.13,就需要重新编译内核加入inotify的支持。 使用 ll /proc/sys/fs/inotify 命令,是否有以下三条信息输出,如果没有表示不支持。 ll /proc/sys/fs/inotify total 0 -rw-r--r-- 1 root root 0 Jan 4 15

inotifywait - exclude regex pattern formatting

∥☆過路亽.° 提交于 2019-11-29 12:34:59
问题 I am trying to use inotifywait to watch all .js files under my ~/js directory; how do I format my regex inside the following command? $ inotifywait -m -r --exclude [REGEX HERE] ~/js The regex - according to the man page, should be of POSIX extended regular expression - needs to match "all files except those that ends in .js ", so these files can in turn be excluded by the --exclude option. I've tried the (?!) lookaround thing, but it doesn't seem to work in this case. Any ideas or workarounds

Rsync实现负载均衡的数据同步

北城以北 提交于 2019-11-29 09:59:16
使用三台服务器: 系统:CentOS 6.8 192.168.8.169 开发服务器 192.168.8.167 线上服务器1 192.168.8.168 线上服务器2 实现思路: 在开发服务器上制定一个规则, 即只要rsync.txt存在, 线上服务器就开始进行文件同步,同步完删除该文件。 实现步骤: (1)安装Rsync。 1、Rsync简介: Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。 Rsync使用所谓的“Rsync算法”来使本地和远 程两个主机之间的文件达到同步, 这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 2、Rsync安装: wget https://download.samba.org/pub/rsync/rsync-3.1.3.tar.gz tar -zxvf rsync-3.1.3.tar.gz cd rsync-3.1.3 ./configure --prefix=/usr/local/rsync make make install 第二步: 安装inotify和inotify-tools Centos 6和CentOS 7,已经默认安装了inotify, 如果要查看是否安装,可以使用如下命令 : ll /proc/sys/fs/inotify

How do I program for Linux's new `fanotify` file system monitoring feature?

非 Y 不嫁゛ 提交于 2019-11-28 19:32:56
fanotify , built on top of fsnotify , is supposed to replace inotify which replaced dnotify . Are there some good programming examples or existing utilities that use fanotify to watch for changes in a filesystem? How much detail does fanotify provide? MvG This LWN article is often quoted as a source of documentation for fanotify. But the description there appears to be out of date. fanotify no longer works using a socket connection. Instead, there are two new libc functions wrapping syscalls, declared in sys/fanotify.h . One is called fanotify_init , the other is fanotify_mark . At the time of

inotify file in C

南笙酒味 提交于 2019-11-28 07:24:01
问题 I am trying to run an example of inotify in C..but it's not working. I want to monitor modifications to a file (the file is tmp.cfg), but it doesn't work..I don't know if i'm running it correctly, because I understand how to monitor directories, but not a single file Here´s the example: #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/inotify.h> #include <unistd.h> #define EVENT_SIZE ( sizeof (struct inotify_event) ) #define BUF_LEN ( 1024 * (

Centos7 rsync+inotify实现实时同步更新

走远了吗. 提交于 2019-11-28 06:13:44
inotify slave部署 把master上指定文件下载到本地的主机指定目录 yum install rsync –y [root@localhost ~]# useradd rsync -s /sbin/nologin -M [root@localhost ~]# mkdir -p /home/yxh/back [root@localhost ~]# chown rsync.rsync /home/yxh/back/ echo rsync_backup:yxh >>/etc/rsync.password rsync_backup 为用户名 yxh 为密码 [root@localhost ~]# chmod 600 /etc/rsync.password [root@localhost ~]# rsync --daemon [root@localhost ~]# ss -tunlp | grep rsync tcp LISTEN 0 5 *:873 *:* users:(("rsync",pid=12133,fd=4)) tcp LISTEN 0 5 :::873 :::* users:(("rsync",pid=12133,fd=5)) 重启rsync [root@localhost back]# ps -ef | grep rsync root 13472 1 0 20

Best way to monitor file system changes in linux

那年仲夏 提交于 2019-11-28 05:55:05
I'm looking at building a file system sync utility that monitors file system activity, but it appears that some of the file system monitoring features in the linux kernel are obsolete or not fully featured. What my research as found dnotify came first with notification has the features of notifying for delete,modify,access,attribs,create,move can determine file descriptor, however is now out dated by inotify and fanotify inotify came out second with notification has the features of notifying access, modify, attrib, close, move, delete, create, etc however it does not give you a file descriptor