rsync as a service as the monitoring inotify
I had to re-order is configured rsync configuration inotify
Media download path
https://download.csdn.net/download/qq_35653822/11192154
1 install rsync
At 225 and 220 are mounted as the monitoring rsync
- Decompression
tar -zxvf rsync-3.0.9.tar.gz
- Configuration
mkdir rsync
cd rsynv-3.0.9
./configure --prefix=/opt/rsync
- Compile
make && make install
- Profiles
rsync.conf configured as follows
uid = root
gid = root
port = 873
max connections = 200
timeout = 300
use chroot = no
pid file = /opt/rsync/rsyncd.pid
lock file = /opt/rsync/rsyncd.lock
log file = /opt/rsync/rsyncd.log
host allow = *
[html]
path=/opt/nginx/html
comment = rsync files
ignore errors
read only = false
list = no
auth users = rsync
secrets file = /etc/rsyncd.pass # Note that the password file location
rsync.pass configured as follows
rsync:123456
- Empowerment
chmod 600 rsyncd.pass
- Start rsync
./rsync --deamon /etc/rsyn.conf
2 Installing inotify
Inotify server is installed on the 225 as a server
- Decompression
tar -zxvf inotify-tools-3.14.tar.gz
- Configuration
cd inotify-tools-3.14
./configure --prefix=/opt/inotify
- Compile
make && make install
4) Upload files upload.sh
5) empowerment
chmod +x upload.sh
6) establish the other server password file
vim rsyncd220.pass
Content for each other rsync password
123456
chmood 600 rsyncd220.pass
7) running in the background script
nohup bash upload.sh &
upload.sh follows (# is the explanation)
#!/bin/sh
#SRC=/share/share1/data/middleware/tomcat/maupload/upload
SRC = / opt / nginx / html / # synchronization paths
HTML :: [email protected] #html configured for rsync.conf the node name 172.22.22.220 you want to sync on servers where to write Which ip
Provided that rsync to another server installed and there are other rsync.conf this node html
# Incremental synchronization (sync)
dir_sync(){
echo "Start Sync"
rsync -avz --progress --password-file=/etc/rsyncd203.pass $SRC $DST
echo "synchronization is complete!"
}
# Main function
main(){
When the first synchronous start time #
dir_sync
echo "Blocking state, waiting for a trigger event ..."
#cycle
/opt/inotify/bin/inotifywait -mrq -e modify,create ${SRC} | while read D E F
do
echo "directory change" $ D, $ E, $ F
# Perform synchronization
dir_sync
echo "Blocking state, waiting for a trigger event ..."
done
}
#Entrance
echo "Start Sync"
main
6.2.2.3 verification
- Performed at the server has the inotify
rsync -avz --password-file=/etc/rsyncd220.pass /opt/nginx/conf/nginx.conf rsync@172.22.22.220::html
2. Synchronize directory upload static resource server has inotify, if there have the same static resources under another server directory synchronization is successful synchronization