Rsync + inotify deployment

Source: Internet
Author: User
Tags inotify rsync website ip

To meet the requirements, the previous rsync timed PUSH Service cannot meet the actual needs.

Environment Introduction:

The nginx cluster of a website is set up because the number of website content is updated frequently, but it takes a lot of time to update the data of one website. Therefore, rsync + inotify is used to push data to the cluster host in real time.

Remote website IP Address: 172.16.100.99/usr/html

Remote website IP Address: 172.16.100.97/usr/html

Local push IP Address: 172.16.100.98/web/Data

Environment:

Redhat5.9

Rsync-3.1.1.tar.gz

Inotify-tools-3.14.tar.gz


Remote ip99 installation:

1.compile and install rsync-3.1.1.tar.gz

Tar zxvf rsync-3.1.1.tar.gz

CD rsync-3.1.1

./Configre

Make

Make install

2. Compile the rsyncd. conf configuration file.

Uid = nobody

Gid = nobody

Max connections = 10

Use chroot = No

Strict mode = No

PID file =/var/run/rsyncd. PID

Lock file =/var/lock/rsync. Lock

Log File =/var/log/rsyncd. Log

[Web99]

Path =/usr/html

Comment = nginx's page comment

Read Only = No

Write only = No

Ignore errors

Uid = root

Gid = root

Host deny = *

Host allow = 172.16.100.98

List = false

Auth users = backup99

Secrets file =/etc/server. Pass

3. Compile a password file that can access the pushing host.

VI/etc/server. Pass

Backup99: 123456

4. Change Password File Permissions

Chmod 600/etc/server. Pass

Remote ip97 installation:

1.compile and install rsync-3.1.1.tar.gz

Tar zxvf rsync-3.1.1.tar.gz

CD rsync-3.1.1

./Configre

Make

Make install

2. Compile the rsyncd. conf configuration file.

Uid = nobody

Gid = nobody

Max connections = 10

Use chroot = No

Strict mode = No

PID file =/var/run/rsyncd. PID

Lock file =/var/lock/rsync. Lock

Log File =/var/log/rsyncd. Log

[Web97]

Path =/usr/html

Comment = nginx's page comment

Read Only = No

Write only = No

Ignore errors

Uid = root

Gid = root

Host deny = *

Host allow = 172.16.100.98

List = false

Auth users = backup97

Secrets file =/etc/server. Pass

3. Compile a password file that can access the pushing host.

VI/etc/server. Pass

Backup97: 123456

4. Change Password File Permissions

Chmod 600/etc/server. Pass

Remote ip98 Installation:

1.compile and install rsync-3.1.1.tar.gz

Tar zxvf rsync-3.1.1.tar.gz

CD rsync-3.1.1

./Configre

Make

Make install

2.compile and install inotify-tools-3.14.tar.gz

Tar zxvf inotify-tools-3.14.tar.gz

CD inotify-tools-3.14

./Configure

Make

Make intall

3. Compile the inotify synchronization script

VI inotify-sync.sh

#! /Bin/bash
Host1 = 172.16.100.99
Host2 = 172.16.100.97
Src = // web/data/
Dst1 = web99
Dst2 = web97
# Dst2 = Images
User1 = backup99
User2 = backup97
Inotifywait-mrq -- timefmt '% d/% m/% Y % H: % m' -- format' % T % w % F % e'-e modify, create, delete, attrib $ SRC | while read files
Do
Rsync-vzrtopg -- delete -- Progress -- exclude "* access *" -- exclude "* debug *" -- password-file =/etc/server. pass $ SRC [email protected] $ host1: $ dst1
Rsync-vzrtopg -- delete -- Progress -- exclude "* access *" -- exclude "* debug *" -- password-file =/etc/server. pass $ SRC [email protected] $ host2: $ dst2
Echo "$ {files} was rsyncd">/var/log/rsync. log 2> & 1
Done


This article is from the "frequently used documentation" blog, please be sure to keep this source http://yujianglei.blog.51cto.com/7215578/1568742

rsync + inotify deployment

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.