For the site can be migrated at any time or load balance, must ensure the consistency of the Web root directory, so the real-time synchronization
Here is a Web synchronization before I simulated the migration:
for data synchronization prior to migration, mainly using Rsync+lsync
client:192.168.1.135 (website backup data)
server:192.168.1.136 (site source data)
Client Installation rsync:
Yum install-y rsync xinetd
Add a profile for rsync
Vi/etc/rsyncd.conf
[Email protected] root]# cat/etc/rsyncd.conf
UID = nobody// user who started the service
GID = nobody// start a service group
Use chroot = yes// limit cage environment
Max connections = max// maximum number of connections
Timeout = +// time-out
Strict modes = yes
PID file =/var/run/rsync/rsyncd.pid
#lock file =/var/run/rsync/rsyncd.lock
Log file =/var/log/rsync/rsyncd.log
[Data]// module
#path =/usr/local/nginx-1.6.3/html/home/paixian/root
Path =/usr/local/nginx/html/home/paixian/root// module path
Ignore errors = yes// ignore error
Read Only = no// read-only
Write only = no// write-only
Hosts allow = *// Access Restrictions
#hosts deny =
List = False
UID = root
GID = root
Auth users = min// authenticated user
Secrets file =/ETC/RSYNCD.PASSWD// Authentication password files
Configuring Authentication Files
vi/etc/rsyncd.passwd
[Email protected] root]# CAT/ETC/RSYNCD.PASSWD
Min:min// User: Password
Add permissions
chmod 600/etc/rsyncd.passwd// Authorization
Start the service
Service xinetd Restart
Detect if the service is started
Ss-tulnp|grep 873
Server Installation rsync
Yum install-y rsync xinetd
Add Authentication File
vi/etc/rsyncd.passwd
[Email protected] bin]# CAT/ETC/RSYNCD.PASSWD
Min
Authorized Certification Documents
chmod 600/etc/rsyncd.passwd
testing the client's rsync
rsync--list-only--password-file=/etc/rsyncd.passwd [email protected]::d ATA
[[email protected] bin]# rsync--list-only--password-file=/etc/[email protected]::d ATA
drwxrwxrwx 4096 2015/10/15 18:22:35.
-rwxr-xr-x 404 2015/09/17 17:17:30 admin.php
-rwxr-xr-x 246 2015/09/17 22:14:00 config.php
-rwxr-xr-x 299 2015/09/17 17:15:37 index.php
-rwxr-xr-x 2015/09/17 17:17:30 phpinfo.php
-rwxr-xr-x 1414 2015/09/17 17:15:36product_list.phtml
-rwxr-xr-x 1998 2015/09/17 17:17:30 test.php
-rw-r--r--2015/10/15 12:29:55 test1.php
-rw-r--r--4 2015/10/15 18:22:17 test2.php
drwxrwxrwx 4096 2015/09/17 17:17:53. Cache
drwxrwxrwx 4096 2015/09/17 17:17:31 admin
drwxrwxrwx 4096 2015/09/17 17:15:36 data
drwxrwxrwx 4096 2015/09/17 17:17:30 Demo
drwxrwxrwx 4096 2015/09/17 17:15:36 Demo2
drwxrwxrwx 4096 2015/09/17 17:13:48phpdemo_boxcontroler
drwxrwxrwx 4096 2015/10/15 15:26:03 root
drwxrwxrwx 4096 2015/09/17 17:13:49 statics
drwxrwxrwx 4096 2015/09/17 17:17:30 test
drwxrwxrwx 4096 2015/09/17 17:15:44 web
Installing LSYNCD
Cd/usr/local
Unzip Lsyncd-master.zip// decompression
CD Lsyncd-master
cmake-dcmake_install_prefix=/usr/local/lsyncd-2.1.5// Compile the specified path
Make && make install
Add a configuration file
cd/usr/local/lsyncd-2.1.5
mkdir etc var// Create configuration files and log files
VI etc/lsyncd.conf// add config file
[Email protected] root]# cat/usr/local/lsyncd-2.1.5/etc/lsyncd.conf
Settings {
LogFile = "/usr/local/lsyncd-2.1.5/var/lsyncd.log",
Statusfile = "/usr/local/lsyncd-2.1.5/var/lsyncd.status",
Inotifymode = "Closewrite",
Maxprocesses = 7,
--Nodaemon =true,
}
Sync {
Default.rsync,
Source = "/usr/local/nginx-1.6.3/html/home/root",// Origin path
target = "[email protected]::d ata",// destination path
Delete= "Running",
Exclude = {". *", ". tmp"},// exclude which files
Delay = 0,// delay number of seconds, send together
init = False,
Rsync ={
binary = "/usr/bin/rsync",
Archive = True,
Compress = True,
Verbose = True,
Password_file = "/ETC/RSYNCD.PASSWD",
_extra ={"--bwlimit=200"}
}
}
Start LRSYNCD
CD bin/
./lsyncd-log exec/usr/local/lsyncd-2.1.5/etc/lsyncd.conf
Self-testing
Real-time synchronization of MySQL:
http://10554846.blog.51cto.com/10544846/1693049
http://10554846.blog.51cto.com/10544846/1697185
This article is from the "innovation sharing gallop inside and out" blog, please be sure to keep this source http://10554846.blog.51cto.com/10544846/1703317
RSYNC+LSYNCD for real-time synchronization