A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

rsync + inotify

rsync + inotify is a more commonly used real-time synchronization solution, but it is not applicable in all the scenes,

rsync + inotify more suitable for the following 10 small-scale web cluster in real-time synchronization, but in the use of rsync + inotify solution and the use of rsync daily,
rsync + inotify rsync server needs to deploy multiple and only one client, rsync client as a daily content of the server so that it will push the data to each Each rsync on the server.
Which used to monitor the file system changes the tool is inotify-tools, rsync client installed inotify-tools after the need to specify the file path to be monitored, the path under the monitored file changes can be used according to the relevant information Triggers rsync to make file push. Linux support inotify kernel minimum 2.6.13, you can use uname-r can view, now CentOS 5 are supported above are more than 2.6.18 so the kernel is generally supported.
Installation is also very simple, after the configuration of the epel source can be installed through yum: yum-y install inotify-tools, after the installation of two binary files are inotifywait and inotifywatch, which is used to monitor the file changes is inotifywait, and inotifywait the parameters used by the option is also very simple:

-m is to keep monitoring changes.
-r Use the recursive form to monitor the directory.
-q Reduce redundant information and only print out the required information.
-e Specifies the list of events to be monitored.
–timefmt is the output format for the specified time.
–format Specifies the details of the file changes.

So you can use the script to hang in the background real-time monitoring specified directory file used to trigger rsync to do file push:

/usr/local/scripts/ &


inotifywait -mrq –timefmt ‘%Y-%m-%d %H:%M:%S’ –format ‘%T %Xe %w%f’ -e modify,delete,create,attrib ${src_dir} | while read line
file=$(echo $line | awk ‘{print $4}’)
dir=$(dirname $file)
if [ -f $file ];then
rsync -vzrLtopg –progress –delete –port=${port} ${file} –password-file=${password_file} ${rsyncd_user}@${rsyncd_host}::${DEST_name}
cd $dir && rsync -vzrLtopg –progress –delete –port=${port} ./ –password-file=${password_file} ${rsyncd_user}@${rsyncd_host}::${DEST_name}

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




Blue Captcha Image


Protected by WP Anti Spam