The configuration process of Rsync's file synchronization under "Thunder" Linux

Source: Internet
Author: User
Tags rsync

Rsync's file synchronization implementation

I. Introduction of RSYNC

Rsync (remote synchronize) is a long-distance data synchronization tool, and a brief summary is a synchronization of the file directory data between hosts.

it has the following characteristics:the entire directory tree and file system can be saved in a mirror. It is easy to keep the original file permissions, time, soft and hard links and so on. install without special permissions. Fast: When you synchronize for the first time, rsync copies the entire content, but only the modified files are transferred the next time. Rsync can compress and decompress in the process of transmitting data, so it can use less bandwidth. Security: You can use SCP, SSH and other means to transfer files, of course, you can also through a direct socket connection. support for anonymous transmission for Web site mirror imagedegrees Niang above the analysis. (I'm too lazy to see it, it's better to see the text.) Look at me, I'll do it again, now! )

In general, it is a fault-tolerant, reliable and efficient file synchronization tool.

Second, environmental requirements (virtual machine built on the environment)

System: Ceotos 6.5 Kernel: 2.6.32-431.el6.x86_64

Host A:192.168.0.244/24

Host B:192.168.0.144/24

Rsync-3.1.2.tar.gz

Third, build rsync

Rsync is configured on host a:

Note: The most important 2 files of rsync 1, rsyncd.conf configuration file

2. Rsyncd.password User Password file

Other RSYNCD.MOTD these are secondary, and this is just a display of page information, similar to a message that prompts when accessing a server.

In this operation, I created the above three files directly under the ETC directory of host A.

-rw-r--r--1 root root 443 10:49/etc/rsyncd.conf-rw-r--r--1 root root 252 10:44/etc/rsyncd.motd-rw-r--r-- 1 root root  10:44/etc/rsyncd.password

RSYNC.PASSWD:

Nowview:nowcaster

RSYNC.MOTD: (Playing advertising)

                                       * *                Rsync                  * *                                       *                                       ********************************* *********

Rsyncd.conf: Here I just mainly test the function of this file synchronization, you need other more functions, you can add the relevant parameter module, you can refer to:

Http://www.cnblogs.com/mchina/p/2829944.html

#This is rsync conf##### #uid = Nowview  #需要添加的, and the following module inside the directory Backup property needs to be changed to Nowview user's gid = nowview  # About this UID and GID did not handle well, back in the synchronization of the backup file when the error, file permissions are not enough. Use Root is the most conservative, but security. This needs to be carefully tuned. Configuration parameters Max connections = 200timeout = 300pid File =/var/run/rsyncd.pidlock File =/var/run/rsync.locklog File =/va R/log/rsyncd.log #可以设置显示格式log format =%t%a%m%f%bmotd file =/etc/rsyncd.motd  #第一个打广告信息--[backup]   #同步的模块的名称p Ath =/home/backup  #模块下面的同步具体路径ignore errorsread only = Falselist = falsehosts Allow = *hosts deny = 0.0.0.0/32auth us ers = Nowview    #用户名secrets file =/etc/rsyncd.passwordexclude =  www/gr068/  #这是除了home目录的下www  With GR068 directory comment = Loading  ..... #第二个打广告信息, you can see it in the test below--

Find the main program of rsync, usually installed in the/usr/local/bin/rsync

Cp-a/usr/local/bin/rsync/usr/bin/rsync, put it under the bin.

Use daemon to start rsync below

PS look at the process, Rsync's default port is 873

[[Email protected] host A-144 home]# ps-ef |grep rsyncroot       5835      1  0 10:51?        00:00:00/usr/bin/rsync--daemon--config=/etc/rsyncd.confroot       5864   1323  0 11:08 pts/1    00:00:00 grep --color rsync
[[Email protected] host A-144 home]# netstat-lantup |grep 873tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      5835/rsync          TCP        0      0::: 873                      :::*                        LISTEN      5835/rsync          

Go on...

If you want to start the boot,

/usr/bin/rsync--daemon--config=/etc/rsyncd.conf   add to/etc/rc.d/rc.local below
Note: 1, this rsyncd.passwd file belongs to the group is root if your current user such as rsync that is to change to Rsync can
Chown Rsync.rsync/etc/rsyncd.password  
2, rsyncd.passwd  to change the permissions of the  password can not be accessed

Add Nowview user to host a

Useradd Nowview

Above in host a configuration all finished!

Iv. Testing

The following tests are performed on Host B.

There have been a variety of problems (carelessness –) that I have summed up in the test.

Note: 1, in order to facilitate the test, I will host A and Host B firewall directly shut off, if you have requirements in this area, directly to the 873 port from both sides to get through.

2, Host B does not have to do any configuration and operation, as long as the connectivity can be maintained. Unless you want to avoid password access, each time you enter a password to annoy you, it is under etc with host A as a password to create a document, note. This password document only needs to fill in the password. This password document is the same as 600 permissions!

Here's a simple access

[[Email protected] host B-244 ~]# rsync-avzp  nowview[email protected]::* *****************************************                                       **                Rsync                  * *                                       *                                       ******************************************

Test below to exempt password access

RSYNC-AVZP  --delete  [email protected]::backup  

In the root directory of Host B has created a backup directory of backup244, now the host share a module (that is, the/home/backup directory of documents, all back up to backup244 directory, to exempt password access, as well as the deletion of the corresponding host a deletion)

The effect is as follows

Top 20 files on Host a

[[email protected] host A-144 backup]# pwd/home/backup[[email protected] host A-144 backup]# for a in ' seq ';d o Touch $a. Txt;done #创建20个文件 [[email protected] host A-144 backup]# lltotal 0-rw-r--r--1 root root 0 16 14:33 10.  txt-rw-r--r--1 root root 0 14:33 11.txt-rw-r--r--1 root root 0 14:33 12.txt-rw-r--r--1 root root 0 16 14:33 13.txt-rw-r--r--1 root root 0 14:33 14.txt-rw-r--r--1 root root 0 14:33 15.txt-rw-r--r--1 root Roo T 0 14:33 16.txt-rw-r--r--1 root root 0 14:33 17.txt-rw-r--r--1 root root 0 14:33 18.txt-rw-r--r-- 1 root root 0 14:33 19.txt-rw-r--r--1 root root 0 14:33 1.txt-rw-r--r--1 root root 0 14:33 20.txt-r w-r--r--1 root root 0 14:33 2.txt-rw-r--r--1 root root 0 14:33 3.txt-rw-r--r--1 root root 0 16 14:33  4.txt-rw-r--r--1 root root 0 14:33 5.txt-rw-r--r--1 root root 0 14:33 6.txt-rw-r--r--1 root root 0 16 14:33 7.txt-rw-r--r--1 rootRoot 0 14:33 8.txt-rw-r--r--1 root root 0 14:33 9.txt 

The effect of Host B is as follows

[[Email protected] host B-244/]# rsync-avzp  --delete  [email protected]::backup/backup244/  --password-file =/etc/rsyncd.password ****************************************** * * Rsync * * *                                       *********** Receiving incremental file listdeleting 7897798798798789797/deleting Gggggggggdeleting 4564656566./1.  Txt10.txt11.txt12.txt13.txt14.txt15.txt16.txt17.txt18.txt19.txt2.txt20.txt3.txt4.txt5.txt6.txt7.txt8.txt9.txtsent 410 bytes  received 988 bytes  2796.00 bytes/sectotal size is 0  speedup is 0.00[[email protected] host B-244/]# Ls/backup244/10.txt  12.txt  14.txt  16.txt  18.txt  1.txt   2.txt  4.txt  6. TXT  8.txt11.txt  13.txt  15.txt  17.txt  19.txt  20.txt  3.txt  5.txt  7. TXT  9.txt

As you can see, all the files are backed up.

(What does the-AZVP parameter mean, refer to the above document for a detailed analysis)

The following from Host B push data pushed to the server (above is from host a pull data come over Host B)

The/home/backup directory for host A is empty

[[Email protected] host A-144 backup]# lltotal 0[[email protected] host A-144 backup]# pwd/home/backup

There is a file and a directory under Host B

[[Email protected] host B-244 backyyy]# ll total dosage 8-rw-r--r--. 1 root root 1857 July  13:55 oo.txxdrwxr-xr-x  2 root root 4096 July  14:04 work[[email protected] host B-244 Backy yy]# du-sh work/116k    work/[[email protected] host B-244 backyyy]# pwd/home/backyyy

Below to start pushing:

[[Email protected] host B-244 backyyy]# rsync-avzq/home/backyyy/  [email protected]::backup  

You can see the changes in the/home/backup directory above host a

[[Email protected] host A-144 backup]# Pwd/home/backup[[email protected] host A-144 backup]# lltotal 8-rw-r--r--1 root root 1857 Jul 13:55 oo.txxdrwxr-xr-x 2 root root 4096 Jul 14:04 Work[[email protected] host A-144 backup]# du-sh work/116k    

Basically rsync's push-pull data synchronization test is complete.

#################################################################

V. Summary

Error main common types and solutions:

1, Rsync:chgrp "/work/.yum.conf.vozf5y" (in Backup) failed:operation not permitted (1)
Rsync Error:some Files/attrs were not transferred (see previous errors) (code) at MAIN.C (1039) [sender=3.0.6]

This is a problem with file permissions when a client (Host B) backup occurs.

Solution: To change the UID and GID to root this is the quickest way to solve, or to tune the configuration file parameters, read and write there.

2. @ERROR: Auth failed on module rsync
Rsync Error:error starting Client-server protocol

In fact, not only the password error will be reported, in many cases it will report.

FIX: Check the following points: (1) Check the parameters of the configuration file secrets the file name, there is no error, password files path is not wrong, the password format is the main configuration: User name: Password format, the client only a password does not have a user name.

(2) Check that the server has no configuration auth users = user, not configured on the user's configuration, shared module backup path directory/home/backup This backup permission property is not corresponding to auth users.

(3), serious and comprehensive inspection of the configuration file, see the error client-server protocol this, generally involves a lot of problems are possible

3. password file must not be other-accessible
Continuing without password file

FIX: Password document permissions changed to 600 with permission attribute changed to user auth users = user

4. No route to host

The port between the hosts is not good.

Workaround: Either turn the iptables off or open the 873 port on either side

5. @ERROR: Invalid GID Nobody
Rsync Error:error starting Client-server protocol

Configuration file Error GID nobody

Resolution: This GID nobody in the configuration file can not be written in this, change to belong to the user or directly to root it

Summary: Generally understand the configuration file inside the deployment of permissions, the permissions of the group. Basically good less error, basically is the right to error. Other errors are caused by carelessness.

"Where there is a mistake, I hope you will give the point and thank you."

Subsequent...

With the rapid development of the labor force, every time the manual synchronization is really troublesome, if the host can be automated real-time synchronization that much efficiency!

The following arrivals match just perfect to solve the above mentioned problem, welcome to continue to pay attention to this blog, the next blog post for you to present the implementation of rsync+inotify real-time synchronization.

(For the first time, I would like to thank you for your great help.)

The configuration process of Rsync's file synchronization under "Thunder" Linux

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.