CentOS 6.5 Inotify+rsync Deployment

Source: Internet
Author: User
Tags inotify rsync

Rsync is a remote synchronization software, in the synchronization of files (files and directories) can maintain the original file permissions, modification time, including linked files can also be synchronized.

Where does this thing apply? No matter what business you are in, if you have more than dozens of servers, and these servers need to keep the files they have in real time, you will use this tool. For example, you have dozens of Web servers, Web files are often modified, how to batch sync these new Web files to all servers?


What is inotify again? It is a notification mechanism, over time, your original folder may be more and more large, if each synchronization will be the entire directory scan once again that can not imagine, inotify is a kernel provides a function, to achieve the monitoring of the directory, if the directory has any file deletion, modification, New It will capture this action and can send this event to other applications.


Host Name Ip Description
Linux01.localhost
10.10.6.12

Linux02.localhost 10.10.6.15
Run the rsync daemon as the server side and receive the push.



Installing rsync

Implementation principle:

Rsync uses the C/s structure, but the S-side is the server side, running rsync daemon, C-side through the command to push files to the S-side.

Installation:

Rpm-qa rsync #检查是安装了rsyncrpm-E rsync #如果安装了, then delete, the system comes with a lower version of the wget https://download.samba.org/pub/rsync/rsync-3.1.2 . tar.gz--no-check-certificate

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/89/E1/wKiom1ggOQPTaOL6AABLKuR6Ss0298.jpg-wh_500x0-wm_3 -wmp_4-s_2307816096.jpg "style=" Float:none; "title=" 0.JPG "alt=" Wkiom1ggoqptaol6aablkur6ss0298.jpg-wh_50 "/>

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/DE/wKioL1ggOQXjVSeVAADXf7CR8vw300.jpg-wh_500x0-wm_3 -wmp_4-s_2681841241.jpg "style=" Float:none; "title=" 1.JPG "alt=" Wkiol1ggoqxjvsevaadxf7cr8vw300.jpg-wh_50 "/>

Tar-xzf rsync-3.1.2.tar.gzcd rsync-3.1.2./configure--prefix=/usr/local/rsync--disable-ipv6

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/89/E2/wKiom1ggPhug-F3vAABntIlYpq0354.jpg-wh_500x0-wm_3 -wmp_4-s_2171279411.jpg "style=" Float:none; "title=" 5.JPG "alt=" Wkiom1ggphug-f3vaabntilypq0354.jpg-wh_50 "/>

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/DF/wKioL1ggPhvALmp9AABje6vAKAg056.jpg-wh_500x0-wm_3 -wmp_4-s_1749728479.jpg "style=" Float:none; "title=" 5.1.JPG "alt=" Wkiol1ggphvalmp9aabje6vakag056.jpg-wh_50 "/>

If you do not specify an installation directory, it is installed by default in the following directory:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/89/DF/wKioL1ggPlmzhIZSAABN5Is9DTc296.jpg-wh_500x0-wm_3 -wmp_4-s_3440622691.jpg "title=" 11.JPG "alt=" Wkiol1ggplmzhizsaabn5is9dtc296.jpg-wh_50 "/>

Make && make install


Set up accounts and directories:

Groupadd-r rsync #创建rsync系统组useradd-G rsync rsync-r-s/sbin/login #创建rsync系统账号并加入到rsync组

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/E1/wKiom1ggNoLig1X_AABWZiegTDA944.jpg-wh_500x0-wm_3 -wmp_4-s_2776443346.jpg "title=" 3.JPG "alt=" Wkiom1ggnolig1x_aabwziegtda944.jpg-wh_50 "/>

mkdir backup #创建用于接收推送文件的目录chown rsync.rsync./backup #设置改目录的属主和属组位rsync

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/89/E1/wKiom1ggNxXggiRUAADIk8kcfNc126.jpg-wh_500x0-wm_3 -wmp_4-s_2388742570.jpg "title=" 4.JPG "alt=" Wkiom1ggnxxggiruaadik8kcfnc126.jpg-wh_50 "/>

Edit profile: After compiling the installation it uses the default location of/etc/rsyncd.conf, but the default file does not exist and needs to be created manually.

Touch/etc/rsyncd.conf #守护进程使用的配置文件, must be rsyncd.conftouch/etc/rsyncd.passwd #用户名和密码文件, this name can be casually chmod 600/etc/ RSYNCD.PASSWD #修改密码文件权限

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/89/E2/wKiom1ggRB2wCspQAABUd-0nTYw624.jpg-wh_500x0-wm_3 -wmp_4-s_4030959988.jpg "title=" 6.JPG "alt=" Wkiom1ggrb2wcspqaabud-0ntyw624.jpg-wh_50 "/>

Vim/etc/rsyncd.conf #编辑配置文件
#[Global Configuration]#  server IP and listening port number address = 10.10.6.15port = 873#  to which user and which group to execute when the server transfers files. pid = rsyncgid = rsync#  before file transfer, the server daemon will chroot to the specified path, the advantage is real-time special protection, the disadvantage is the need to roo#  T-privilege use chroot = no#  max concurrency max connection = 10#  timeout length timeout =  300#  lock, log, and PID file location lock file = /var/run/rsync.locklog file = /var/run/ rsync.logpid file = /var/run/rsync.pid#  message file, when the client connects to the server, the contents of the file will be displayed to the client motd file  = /etc/rsyncd.mod#  files that store virtual users and Passwords secrets file = /etc/rsyncd.passwd#  allowed network segments hosts  allow = *#  does not allow the network segment #hosts deny = 0.0.0.0/32#  to allow customers to upload files, true does not allow, false allows. read only = false#[module Configuration], the so-called module configuration is actually the directory to use, the client pushes the file to the server side of which directory #  need to receive the synchronized directory path = / usr/local/backup#  whether to ignore the error ignore errorslist = false#  the virtual user, that is, the client with that user to connect to the server, Multiple users can be separated by a space or comma, and the user #  must be Secrets&nbsThe description of the module is auth users = rsync_backup#  in the p;file = /etc/rsyncd.passwd file, Client connection is displayed to client Commment = hello



Rsync can be run as a daemon, or it can be activated by xinetd, and if your server load is high it is recommended that rsync run in a separate daemon mode. The difference is that if run as a standalone daemon, it will always listen to the port ready to accept the file push, if it is managed by xinetd This super process, that is not pushed when the rsync is dormant, when there is push, by the XINETD this super process activates rsync, This is an additional overhead for busy servers.

This article is from the "Little Demon's Home" blog, so be sure to keep this source http://littledevil.blog.51cto.com/9445436/1870338

CentOS 6.5 Inotify+rsync Deployment

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.