CentOS6.5 for rsync + inotify Real-Time Synchronization

Source: Internet
Author: User
Tags inotify server installation and configuration rsync

CentOS6.5 for rsync + inotify Real-Time Synchronization

1. Architecture

Server: 192.168.202.135

Client: 192.168.202.129

2. rsync server installation and configuration

yum install rsync -y # Installing the rsync Service

Provide the configuration file for rsync:

vim /etc/rsyncd .conf # The file does not exist by default. Add the following content: uid=root # Users who start the service process gid=root # User group for starting a service process port=873 # Port number monitored when the rsync service is started by the daemon hostsallow=192.168.202.0 /24 # Clients allowed to connect to the service maxconnections=0 # Specify the maximum number of concurrent connections of the service. If it is 0, it indicates no limit. timeout=300 # Specify the timeout value pid file = /var/run/rsyncd .pid # Pid file path lock file = /var/run/rsync .lock # Lock file path log file = /var/log/rsyncd .log # Log File Path [backup] # Module Declaration path= /rsync/test # Specify the synchronization path of the current module on the rsync server. This parameter must be specified. read only=no # Whether to allow the client to upload files list=no # Whether the module should be listed when the customer requests to list available modules auth users = rsync # Specify a list of usernames separated by spaces or commas. Only these users can connect to this module. secrets file = /etc/rsync . passwd # Save the password and user name file, which must be generated by yourself

Set the password file:

vim /etc/rsync . passwd # Add the following content rsync :123456 chmod 600 /etc/rsync . passwd # Change the password file permission to 600

Note: When the strict modes parameter in the configuration file is true, the permission of the rsync authentication password file must be 600. Otherwise, the client cannot connect to the server. In the rsync authentication password file, specify a username: Password pair in the format of username: passwd.

Start the rsync service and set auto-start upon startup:

/usr/bin/rsync --daemon # Start the rsync service as a daemon echo "/usr/bin/rsync--daemon" >> /etc/rc . local # Add auto-start upon startup

3. install and configure the rsync Client

Install inotify-tools:

Before installing inotify-tools, check whether your Linux kernel has reached 2.6.13 and the CONFIG_INOTIFY option is enabled during compilation. You can also run the following command to check whether the following output is displayed, note:

[root@localhost~] #ls/proc/sys/fs/inotify/ max_queued_eventsmax_user_instancesmax_user_watches

Installation:

wgethttp: //cloud .github.com /downloads/rvoicilas/inotify-tools/inotify-tools-3 .14. tar .gz tar xvfinotify-tools-3.14. tar .gz cd inotify-tools-3.14 . /configure make ; make install

Compile the rsync. sh monitoring script:

#!/bin/bash host=192.168.202.135 src= /data/www/ des=backup user= rsync /usr/local/bin/inotifywait -mrq--timefmt '%d/%m/%y%H:%M' -- format '%T%w%f' \ -emodify,delete,create,attrib\ ${src}\ | while read file do rsync -vzrtopg--delete--progress${src}${user}@${host}::${des}--password- file = /etc/www . pwd && echo "${files}wasrsynced" >> /tmp/rsync .log2>&1 echo "---------------------------------------------------------------------------" done

Create an authentication file (only use the password to add the client authentication file) and run the rsync. sh script in the background:

echo 'rsync' >> /etc/www . pwd chmod 600 /etc/ww . pwd nohup sh /root/rsync .sh& echo "nohupsh/root/rsync.sh&" >> /etc/rc . local

References:

Rsync server installation and configuration: http://www.cnblogs.com/mchina/p/2829944.html

Rsync + inotify file batch update: http://kerry.blog.51cto.com/172631/734087/

Rsync + inotify for real-time data backup:

Http://blog.chinaunix.net/xmlrpc.php? R = blog/article & uid = 11840697 & id = 3890795

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.