Recently the company server expires, preparing to migrate the server, then the question is, too much data, the relocation process server continues to run the old data, how to break? ?
Eyes put in front of me on the two roads,
1, the easiest way to migrate data midnight, which shows that I want the jet lag
2, try to engage him! I can have a good night sleep on a wave, after all, still young Si ω Si, pay attention to maintenance
Man of few words said, is to select the first two kinds, do not ask why, head of iron!
Focus here, Rsync + crontab is most equipped
The company is using server centos pagoda environment, checked, even to pagoda charge! ! !
\
8 .. 4 month I like rich people do? ?
Direct Access information manually do!
Here is the process
a, b two servers, a server for the old, b for the new server, rsync can also play a key role in server load balancing, is bound to be used later, follow-filled pit it again
First, on a server to configure
● Rsync will bring general linux
Remember a server open port 873
If not, even on SSH, execute the following code
yum -y install rsync
● After installation, with pagoda enter /etc/rsyncd.conf
[aa] path=/www/wwwroot/aa/ use chroot=no max connections=10 read only=yes write only=no list=no uid=root gid=root auth users=root secrets file=/etc/rsync_server.pas strict modes=yes hosts allow=* #hosts deny=1.1.1.1 ignore errors=yes timeout=120 #秒
Parameters:
[AA]: module name, their own definition, you can add other modules below. Module name in order to be consistent with the implementation of the client.
path: file server to be backed up folder path.
hosts allow: connection allows the client IP.
secrets file: server password files, content format, user name: password.
auth users: privileged user name, in line with the user name and password file.
To manually in the / etc directory to create a password file rsync_server.pas look at adding user name and password, content format: username: password. Such as root: 123456
Remember that you've created the file permissions set to 600, the same user name owner to keep the password file
Next start rsync service
# 启动rsync /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
By the way stop ysync
# Stop rsync PS -ef | grep rsync the kill -9 process ID RM -rf /var/rsync/rsync.pid
Next b server configuration
Also, rsync, if not installed, install it on a service call to install
Bahrain, created in the / etc password file rsync_client.pas, note the contents of only password, and the password file server with a password the same. As 123456
Change the password file permissions to 600. This is very important, otherwise it will not be synchronized
Add regular tasks crontab server in b
Directly edit / etc / crontab file, add the following regular code, save
00 02 * * * root rsync -aqzrtopg --delete rsync://[email protected]/aa /home/aa_backup --password-file=/etc/rsync_client.pas
Parameter Description
Is assumed to be a server IP 192.168.1.1
AA for the file server /etc/rsyncd.conf [AA] module
/ home / aa_backup b is the server folder path
/etc/rsync_client.pas current password file server
Bin, sleep at ease, time 2:00 (nighttime backup operation is appropriate and will not affect the normal operation of the server during the day) would code is synchronized to the server b