---restore content starts---
Company Web Site A server is not up, it is intended to use load balancing, is now 3 machines to run the site, before the batch update has not written a log, now complement, but also borrowed a lot of blog
There's no need to compile and install the Yum directly.
Yum Install rsync
Setting up a configuration file
#touch/etc/rsyncd.conf
Set up account profile
#touch/etc/rsyncd.pwd
Configuration files can only be viewed by themselves
#chmod 600/etc/rsyncd.conf
Account profile can only be viewed by itself
#chmod 600/etc/rsyncd.pwd
# vi/etc/rsyncd.conf
Uid=rootgid=rootmax connections=4use chroot=yeslog file=/var/log/rsyncd.logpid file=/var/run/rsyncd.pidlock file=/ Var/run/rsyncd.lock#auth users=rootsecrets File=/etc/rsyncd.pwd[web]path =/home/wwwroot/web1/comment = Welcome to 0.1ignore Errorsread only = Nolist = Yesauth users = www
Vi/etc/rsyncd.pwd
The contents of the file are as follows:
Www:xxxxxxxxxxxxxxxxxxxxxx
Start Rsync Server (the configuration file/etc/rsyncd.conf will be loaded automatically)
#rsync--daemon
If Iptables is turned on, open the input (inbound) rule for TCP 873 first
Set Password file
#echo "xxxxxxxxxxxxxxx" > /script/rsync_remote.pwd
Password files can only be viewed by themselves
#chmod 600/script/rsync_remote.pwd
Installation inotifywait is not detailed
Here is the script I used to update the execution
/script/inotify_rsync.sh Note: host1 Host2 is 2 servers that need to be synchronized. If there are more servers that need synchronization, you can add------------------------------------------------------------------------#!/bin/bashif ["$"] below ! = ""]; then echo "run/etc/init.d/inotify start" Exit 1fihost1=192.168.0.22host2=192.168.0.23src=/home/www Root/web1/src2= "' Echo $src | Sed-e ' s/\//+++/g ' "des=webuser=wwwrsync_exclude_file=/script/rsync_skip.setuppassword_file=/script/rsync_ Remote.pwddo_rsync () {files=$1 user=$2 host=$3 des_url=$4 rsync_exclude_file=$5 Password_file=$6/usr/bin/rsync--DELETE-ZRTOPG--exclude-from=${rsync_exclude_file}--progress--password-file= ${password_file} ${files} [email protected] $host:: $des _url} #echo "SRC2: $src 2"/usr/local/inotify/bin/ Inotifywait--excludei ' (. svn|. swp|. swo| Runtime) '-mrq--timefmt '%d/%m/%y%h:%m '--format '%w::%f '-e close_write,delete,create,attrib $src | While read filessdo files= ' echo ' $filess | Awk-f:: ' {print '} ' file=' Echo ' $filess | Awk-f:: ' {print $} ' des_dir= ' echo ' $files | Sed-e ' s/\//+++/g '-e "s/${src2}/\//g"-e ' s/+++/\//g "des_url=" ${des}${des_dir} "Do_rsync" $files "" $user "$host 1" "$des _url" "$rsync _exclude_file" "$password _file" Do_rsync "$files" "$user" "$host 2" "$des _url" "$rsync _ Exclude_file "" $password _file "echo" ' Date ' Dir:${files}, File:${file} was rsync to ${host1},${host2}/${des_url} " >>/home/ Rsync.logdone----------------------------------------------------------------------------------------------/ etc/init.d/inotify#! /bin/sh### BEGIN INIT info# provides:inotify# required-start: $remote _fs $network # required-stop: $remote _fs $network # default-start:2 3 4 AA default-stop:0 1 6# short-description:starts inotify# Description: Starts the PHP FastCGI Process Manager daemon### END INIT infocase "$" in start) echo-n "starting INotify "/script/inotify_rsync.sh&Amp If ["$?"! = 0]; Then echo "Failed" Exit 1 fi sleep 2 If ["' PS aux | grep inotifywait | Wc-l ' "-GT 1]; Then echo "Done" else echo "failed" Exit 1 fi;; Stop) echo-n "Gracefully shutting down inotify" Killall inotifywait killall inotify_rsync.sh sleep 2 If ["' PS aux | grep inotifywait | Wc-l ' "-GT 1]; Then echo "Failed" Exit 1 else Echo " Done "Exit 1 fi;; Restart) $ stop $ start; *) echo "Usage: $ Start|stop|restart}" exit 1;; Esac
---restore content ends---
Inotify+rsync implementing batch update of Linux files