A description of the application scenario
There are several game suits running PHP code on the back end of LB, the same as PHP code for each server's environment deployment. It is now sometimes necessary to change the game profile, such as changing the service state of each area. Logging on to each server to change the corresponding files is cumbersome and requires the configuration files on the other server to change automatically when the configuration file on the first server is changed. So consider using rsync + inotify to synchronize the code.
Two rsync and inotify configurations
Installing Rsync services using Yum-y install Rsync
Rsync has two modes of operation, command-line mode and C/s mode
Use man rsync to view the detailed use of the rsync command
Use man rsyncd.conf to view detailed configuration files for rsync c/s mode runtime
Start rsync c/S mode
/usr/bin/rsync--daemon
/etc/rsyncd.conf This file does not exist by default and requires a manual creation.
uid = root gid = root use chroot = no max connections = 50 #strict modes = yes pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [login_nginx] path = /etc/ Nginx/ comment = login nginx ignore errors read only = no write only = no hosts allow = 192.168.1.0/ 24 hosts deny = * list = false [game_center] path = /var/www/html comment = game_center code ignore errors read only = no write only = no Hosts allow =&nbsP;192.168.1.0/24 hosts deny = * list = false
Here the UID and GID are particularly important, indicating that the RSYNCD daemon should have permission to the specified directory when the file is transferred. If the permissions are not correct, the transfer will fail.
Use Chroot if set to True, then rsync chroot to the specified directory before transferring the file.
List This parameter sets whether the module can be listed when the client requests to list the available modules
Max connections sets the maximum number of concurrent connections, which by default is 0, which means no limit.
Game_center is the name of this module
Path setting synchronization Directory
Ignore errors ignoring some I/O errors
Read only setting whether to allow ReadOnly
Write only sets whether to allow write-only
Hosts allow to set the IP range allowed to be accessed, either as a single IP or as an IP segment
Hosts deny sets IP ranges that are denied access
This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1583159
Automatic real-time synchronization of multiple game suit codes using rsync + inotify