What is INotify?
INotify is a powerful, fine-grained, asynchronous file system time monitoring mechanism, which can replace Crond with rsync trigger file synchronization, thus monitoring the file system to add, delete, modify, move and other fine-grained events, from Linux 2.6.13, has added support for inotify, so we only need to install a third party software Inotify-tools to manage this service.
Before using the Rsync+crond to trigger the bottleneck of synchronization is that rsync in the synchronization of data, the need to scan all files before the comparison, and then differential transmission, if the number of files is large and changes quickly, scanning all files will be very time-consuming, and there will be leakage synchronization problems, Cause inefficiency.
And Rsync+inotify will make up for the first scan after the synchronization of the efficiency problem, the use of system-level monitoring of various changes, when the file changes, will trigger rsync synchronization, solve the efficiency and real-time problems.
Linux operating system: centOS6.3 64bit
Rsync: System with Self
Inotify-tools:inotify-tools-master
WWW1 (rsync server): 192.168.7.73
WWW2 (rsync client): 192.168.7.74
Topology map:
(server) Represents server-side configuration only
(client) represents only clients configuration
(Server,client) indicates that both the client and the server need to be configured
Environment construction: (server,client)
1. Close Iptables and SELinux
# Service Iptables Stop
# Setenforce 0
# Vi/etc/sysconfig/selinux
---------------
Selinux=disabled
---------------
Determine if the Linux system kernel is up to 2.6.13 or more:
# uname-a
-------------
Linux www1.example.com 2.6.32-279.el6.x86_64 #1 SMP Fri June 12:19:21 UTC-x86_64 x86_64 x86_64 gnu/linux
-------------
To see if the INotify directory exists:
# ls-lsart/proc/sys/fs/inotify/
------------------
Total dosage 0
0 dr-xr-xr-x 0 root root 0 June 4 14:04.
0 dr-xr-xr-x 0 root root 0 June 4 17:35.
0-rw-r--r--1 Root 0 June 4 17:35 max_user_watches
0-rw-r--r--1 Root 0 June 4 17:35 max_user_instances
0-rw-r--r--1 Root 0 June 4 17:35 max_queued_events
------------------
If the above content is returned, the system supports inotify.