Linux Advanced Skills: rsync synchronization (1), linuxrsync

Source: Internet
Author: User
Tags rsync rsync usage

Linux Advanced Skills: rsync synchronization (1), linuxrsync
1. rsync Introduction

RsyncIs an application software in Unix. It can synchronously update files and directories of two computers and use differential encoding to reduce data transmission. An important feature in rsync that is not seen in most similar programs or protocols is that the image only needs to be sent once for each target. Rsync can copy/display directory attributes, copy files, and perform selective compression and recursive copy.

The diagram of rsync is as follows:


2. Set up the rsync service:

Note:
1. In this experiment, three nodes are used, of which Node 1 serves as the external synchronization machine. The content of the other two synchronization nodes 1.
2. Do a good job of time synchronization, firewall shutdown, selinux is also recommended to close (to facilitate the experiment ).
3. Set the yum source (add a high-availability package ).

This is the console of our experiment:


1. First, we need to install rsync. rsync has been added to the yum source of the redhat6.5 system, so we can install it directly:


Set its configuration file:


To explain the above content, we set the access user and group to root, the maximum number of connections is 36000, And the directory cannot be changed. Then we set the log directory, process, and lock files. The structure of the content below is very similar to that of nfs, including published directories, descriptions, and whether to read and write data and object-oriented data.

When starting this service, we need to install the xinetd DAEMON service because rsync is a background process. Therefore, xinetd must be used for startup.


Modify the configuration file of rsync under the daemon to enable the Service:


Set disable to no to enable the Service.


We can see that after the xinetd service is restarted, our rsync has also been enabled:


Install the httpd service for testing:


Modify the rsync configuration file and set the synchronization directory to the default release directory of httpd:


Install the software sersync on 192.168.2.102 (the software package must be downloaded online ):


Modify the sersync configuration file:




Create the Directory and file to be synchronized:


Enable the sersync daemon on the master server to run sersync in the background and enable real-time synchronization.


Then we access 192.168.2.103 through a browser, and we can see that the displayed content is actually the content of 192.168.2.102: // opt/tongbu/index.html. Only 192.168.2.103 is synchronized to the default release content of httpd.

3. Summary:

This is a simple and practical synchronization method. Next we will explain the deeper usage of rsync.







In linux, how does one determine whether a single or a file is successfully synchronized when rsync is used to synchronize files?

This problem can be solved. You only need to add a command after your command line.
# Rsync... | echo! $
What is the meaning of the command? That is to say, if the previous command fails, the echo will be executed! $ Command, and! $ Variable indicates the parameter followed by the execution of the previous command. That is to say, if an error occurs when the rsync command synchronizes a file, the file name will be! $ Is recorded, so I think using this command we can know that the file encountered a problem when executing the rsync command. The command was successfully tested by myself. However, because my rsync didn't fail, I modified | to & for testing. The principle is the same.
I don't know if this is what LZ wants?

Rsync Usage Details in linux

Rsync has its own data synchronization protocol. You do not need to use the rsync protocol, but use the ssh remote shell to provide data synchronization. The rsync protocol seems to save traffic, and ssh seems to have to transmit all the data.

Www.samba.org/ftp/rsync/rsync.html

Let's take a look at the specific introduction.

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.