Introduction to Rsync file sync Server & installation and configuration

Source: Internet
Author: User
Tags rsync
(1) Software Overview Rsync is a remote data synchronization tool that allows you to quickly synchronize files between multiple hosts through LANWAN. Rsync is a tool used to replace rcp, which is currently maintained by rsync.samba.org. Rsync uses the so-called "Rsync algorithm" to synchronize files between local and remote hosts. This algorithm only transfers two

(1) Software Overview

RsyNcIs a remote data synchronization tool that can quickly synchronize files between multiple hosts through the LAN/WAN. RSyncOriginally used to replaceRCpA tool, which is currently composedRsync.samba.orgMaintenance. Rsync uses the so-called "Rsync algorithm" to synchronize files between local and remote hosts. This algorithm only transfers two filesDifferent PartsInstead of transmitting the entire copy each time, the speed is quite fast. The machine running Rsync server is also calledBackup serverOne Rsync server can back up data of multiple clients at the same time, or multiple Rsync servers can back up data of one client.

Rsync can be used togetherRsh, ssh, or even daemon mode. Rsync server opens873And wait for the peer Rsync connection. During connection, the Rsync server checks whether the Password Matches. If the password is checked, file transmission can be started. When the first connection is complete, the entire file will be transferred once, and only different parts of the two files will be transferred at the next time.
Rsync supports most Unix-like systems, including Linux, Solaris, and BSD. In addition, it also has corresponding versions on the windows platform, which are well-knownCwRsync and Sync2NAS.
The basic features of Rsync are as follows:
1.Images can be used to save the entire directory tree and File System;
2. It is easy to maintain the original filePermissions, time, and soft and hard linksAnd so on;
3.No special permissions requiredYou can install it;
4. optimized processes and filesHigh Transmission Efficiency;
5. AvailableRcp, SshAnd other methods to transfer files, of course, you can alsoConnect through a direct socket;
6.Supports anonymous transmission.


(2) Core algorithms

Assume that similar files A and B are synchronized between two computers named α and beta. Alpha has access to file A and beta has access to file B. In addition, it is assumed that the network bandwidth between host α and β is very small. Then, The rsync algorithm is completed in the following five steps:
1. Beta splits file B into a group of non-overlappingData blocks with a fixed size of S bytes. The last part may be smaller than S.
2. Beta performs two types of verification on each split data block:32-bit rolling weak Verification, The other is128-bit MD4 strong verification.
3. Beta sends the verification results to α.
4. α searches all data blocks of file A with the size of S (the offset can be optional, not necessarily A multiple of S ), to find data blocks with the same weak verification code and strong verification code as one of file B. This work can be leveragedRolling VerificationFeatures are quickly completed.
5. Alpha sends A string of instructions to generate A backup of file A on Beta. Each instruction here is either a proof that file B has a data block and does not need to be re-transmitted, or a data block, this data block certainly does not match any data block of file B.

(3) Server Configuration
Rsync is installed by default in RHEL5, 2.6.8-3.1, and the latest version is available from the http://rsync.samba.org/rsync.

1. configuration file rsynCd. Conf

1. Create a configuration directory and file

# CreateRsyncd directoryWe storeRsyncd. conf and rsyncd. secrets files
Mkdir/Etc/rsyncd
# Create rsyncd. conf, which is the configuration file of the rsync server
Touch/Etc/rsyncd. conf

# Create rsyncd. secrets. This isUser Password File

Touch/etc/rsyncd. secrets

# For Password Security, we set the permission to 600
Chmod600/etc/rsyncd. secrets

#Server welcome information
Touch/etc/rsyncd/Rsyncd. motd

2. Edit rsyncd. conf

# This line is requirEdBy the/etc/init. d/rsyncd script

PId File=/Var/run/rsyncd. pid

Lock file =/var/run/rsyncd. lock

Port = 873

ADdRess = 192.168.55.229

Uid = root

Gid = root

Use chroot = yes

Read only = yes # Pay attention to this user ID and group ID. For convenience, you can set it to root so that rsync can read almost # any files and directories, but it also brings security risks. We recommend that you only read the directories and files you want to back up.

 

# Limit access to private LANs

Hosts allow = 192.168.55.0/255.255.255.0 10.0.55.0/255.255.255.0

Hosts deny = *

 

Max connections = 5 # the maximum number of connections is 5

Motd file =/etc/rsyncd. motd

 

# This will give you a separate log file
# Log file =/var/log/rsync. log

 

# This will log every fileTrAnsferred-up to 85,000 + per user, per sync
# Transfer logging = yes
Log foRmAt = % t % a % m % f % B
Syslog facility = local3
TimeOut = 300

[Linuxroot]# Specify the name of the authenticated backup module
Path =/# directory to be backed up

Comment = linuxroot # comment

Ignore errors # Ignore irrelevant IO errors
Auth users = root# The authenticated user name is a real system user that must exist on the server. Multiple users are separated by commas;If this row does not exist, it indicates that it is anonymous.

List = yes# Columns allowed

Read only = yes # Set to read-only

Hosts allow = 220.122.133.31 # allow connectionHost IP address of the server
Secrets file =/etc/rsyncd. secrets# Authentication file name, used to store passwords
ExClude = home/# Excude excluded directory list

3.Edit rsyncd. secrets (User name: password)

Root: 123456

4.Start rsync server

/Usr/bin/rsync -- daemon -- config =/etc/rsyncd. conf

# Linux Firewall uses iptables, so view firewall settings

Iptables-a input-p tcp-mStatE -- state NEW-m tcp -- dport 873-j ACCEPT
Check whether the firewall has opened port 873;
Iptables-L

Or:

Modify the/etc/xinetd. d/rsync file and change disable = yes to disable = no.
Finally, we need to start the rsync service on the server:
  Service xinetd restart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.