First, the introduction of rsync
Rsync Synchronize is a remote Data synchronization tool that allows you to quickly synchronize files between multiple hosts by Lan/wan, or you can use rsync to synchronize different directories on your local hard disk.
Rsync is a tool to replace RCP, and Rsync uses the so-called "rsync algorithm" to synchronize files between local and remote two hosts, which transfer only a different portion of two files, rather than sending it all at a time, so it's very fast. You can refer to the How to rsync works A practical Overview to learn more about Rsync's operating mechanism.
Rsync supports most Unix-like systems, both Linux, Solaris, and BSD are well tested. In addition, it also has a corresponding version under the Windows platform, the more well-known are cwrsync and Sync2nas.
The initial authors of Rsync are Andrew Tridgell and Paul Mackerras, which are currently maintained by http://rsync.samba.org.
The basic features of rsync are as follows:
1. Can be mirrored to save the entire directory tree and file system;
2. It is easy to maintain the original file permissions, time, soft and hard links;
3. Installation without special permission;
4. Optimized flow, high efficiency of file transfer;
5. You can use RCP, ssh and other means to transfer files, of course, can also be connected through the direct socket;
6. Support for anonymous transmission to facilitate site mirroring.
There are two ways to use rsync for remote synchronization: remote Shell mode (which is recommended for SSH, user authentication is responsible for SSH), and C/s mode (that is, the customer connects to the remote rsync server and the user authenticates by the rsync server).
Whether the local synchronization directory or the remote synchronization data, the first run will be a copy of all the files once, and later run will only copy the changed files (for new files) or the changes in the file (for the original file).
Rsync does not have the speed advantage at first copy and is not as fast as tar, so you can consider using tar for the first copy when the data is large, and then use rsync for data synchronization.
Second, the system environment
System Platform: CentOS Release 6.3 (Final)
rsync version:rsync-3.0.9-2.el6.rfx.x86_64.rpm
rsync Server: Ts-dev (172.16.1.135)
rsync clients: Ts-client (172.16.1.136)
Third, server-side installation rsync services
3.1. Check to see if rsync is installed
# Rpm-qa|grep Rsync
If it is already installed, uninstall using the RPM-E command.
3.2. Download RPM Package
# wget http://pkgs.repoforge.org/rsync/rsync-3.0.9-2.el6.rfx.x86_64.rpm
3.3. Install rsync
# RPM-IVH rsync-3.0.9-2.el6.rfx.x86_64.rpm
Iv. Configuring Rsync Services
4.1. Configuring the Rsync server steps
First, select the server startup method
For a heavier-load rsync server, you should use an independent operation
For a lighter-load rsync server, you can use the xinetd run mode
Create configuration file rsyncd.conf
Authentication password files are also created for rsync servers that are not anonymously accessed
4.2. Run rsync service with XINETD
CentOS runs the rsync service in xinetd mode by default. XINETD configuration file for rsync
In/etc/xinetd.d/rsync. To configure the Rsync service running with xinetd, you need to perform the following commands:
# chkconfig rsync on # service xinetd restart
The administrator can modify the/etc/xinetd.d/rsync configuration file to suit your needs. For example, you can modify the configuration line
Server_args =--daemon
Add the service options for rsync later.