Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Amazon EC2 server using Rsync + Inotify real-time synchronization     - MySQL multi-master multi-cluster deployment uses alive Galera (Database)

- Ubuntu Telnet service settings (Linux)

- Linux file compression and archiving (Linux)

- Qt shared memory interprocess communication (Programming)

- HBase table data processing tab (Database)

- CentOS 7 source code to compile and install PHP5.6 Nginx1.7.9 and MySQL (LNMP build environment) (Server)

- Installation and deployment of Hadoop 2.7.1 on Ubuntu 14.04 LTS (Server)

- GlusterFS distributed storage deployment (Server)

- Linux Systemd-- To start / stop / restart services in RHEL / CentOS 7 (Linux)

- Install Ubuntu text editor KKEdit 0.2.10 (Linux)

- Java memory mechanism Description (Programming)

- Based on Python: OpenCV simple image manipulation (Programming)

- Based kubernetes Construction Docker Cluster Management Comments (Server)

- Implement Oracle dynamic registration of non-standard port 1521 (Database)

- How to adjust the system time CentOS (Linux)

- RedHat Linux 9.0 under P4VP-MX motherboard graphics resolution of problems (Linux)

- Installation Mate Desktop in FreeBSD 10.1 (Linux)

- Copy and paste in Linux terminal and Vim (Linux)

- Eclipse, Tomcat configuration JNDI connection Oracle data source example (Server)

- System Security: Build Linux with LIDS steel castle (Linux)

 
         
  Amazon EC2 server using Rsync + Inotify real-time synchronization
     
  Add Date : 2018-11-21      
         
         
         
  Background:

Amazon needs to synchronize data between two servers, just pass on one machine, you can automatically sync to the other machine.

Install Rsync:

CentOS 6.7 with automatic on Rsync, does not require installation.

##Case Analysis
It is assumed that there are two servers: A and B. Where A is the primary web server (155.28.81.0), B is the server from the server (155.28.82.0). We want A server / home / test / backed up to the server B / home / test / directory.

A server configuration ##
#### A compilation server installation
Compile rsync installation is very simple, just the following simple steps:

[Root @ www ~] # cd / usr / local / src /
[Root @ www src] # wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz
[Root @ www src] # tar zxvf rsync-3.0.9.tar.gz
[Root @ www src] # cd rsync-3.0.9
[Root @ www rsync-3.0.9] # ./configure --prefix = / usr / local / rsync /
[Root @ www rsync-3.0.9] # make
[Root @ www rsync-3.0.9] # make install But note that rsync must be installed on servers A and B, based on server mode (passive) run rsync server on which the A, B and places the customer end mode (active) run rsync. Thus runs on web server A rsync daemon running on the client B timed program to back up the contents of the web server A to be backed up.

#### To create a user and password authentication file

[Root @ www rsync-3.0.9] # echo "backup: bk_passwd"> /usr/local/rsync/rsyncd.passwd Remember password file server end establishment, including user name and password, and the client side password file created only password, no user name.

#### Is set to read-only permissions

[Root @ www rsync-3.0.9] # cd / usr / local / rsync
[Root @ www rsync] # chmod 600 rsyncd.passwd might otherwise error:
@ERROR: Auth failed on module ***
rsync error: error starting client-server protocol (code 5) at main.c (1503)

#### Establishing rsync profile

[Root @ www rsync] # vi /usr/local/rsync/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 4
strict modes = yes
hosts allow = 121.42.46.213 # spaces can allow multiple
port = 873
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

[Test]
path = / home / test
ignore errors
read only = true
list = false
auth users = backup
secrets file = /usr/local/rsync/rsyncd.passwd#### way to start rsync daemon server

[Root @ www rsync] # rsync --daemon --config = / usr / local / rsync / rsyncd.confrsync default service port 873, the port server receiving client or anonymous authentication mode backup request.

#### If you want service is set from the start, you can add rc.local

Edit /etc/rc.d/rc.local, add at the end:

/ Usr / local / rsync / bin / rsync --daemon --config = / etc / rsyncd.conf

## Client Configuration B

Compile and install Ibid., Generic error occurs in the server B

#### Establishing access server A password authentication file

[Root @ www rsync] # echo "bk_passwd"> /usr/local/rsync/rsync.passwd#### set permissions to read-only

[Root @ www rsync] # chmod 0600 rsync.passwd #### after rsync installed, run the following command to synchronize backup

[Root @ www rsync] # rsync -vzrtopg --delete --progress --password-file = / usr / local / rsync / rsync.passwd backup@115.28.81.0 :: test / home / test wherein address backup@115.28. 81.0 :: test, backup server a user, 115.28.81.0 server a IP address or domain name, test server a configuration module.

The above command line -vzrtopg where v is verbose, z is compressed, r is recursive, topg original file attributes are maintained in the case of the main parameters, time, - progress means showing details of the progress - -delete means that if the server to delete this file, then the client is also appropriate to delete the file, keep it real consensus. --password-file = / usr / local / rsync / rsync.passwd to specify a password file, so that you can interactively without having to enter a password to use in the script, to note here is this property to the password file permissions set to be readable only by root.

Here the contents of the backup stored in the backup machine / home / test / directory.

#### Install inotify

[Root @ www rsync] # cd / usr / local / src /
[Root @ www src] # wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
[Root @ www src] # tar zxvf inotify-tools-3.14.tar.gz
[Root @ www src] # cd inotify-tools-3.14
[Root @ www inotify-tools-3.14] # ./configure --prefix = / usr / local / inotify
[Root @ www inotify-tools-3.14] # make
[Root @ www inotify-tools-3.14] # make install

Rsync synchronization scripts:

#! / Bin / bash
#variables
current_date = $ (date +% Y% m% d_% H% M% S)
source_path = / home / www /
log_file = / usr / local / rsync / rsync_client.log
  
#rsync configuration
rsync_server = 115.28.81.0
rsync_module = www
rsync_user = backup
rsync_pwd = / usr / local / rsync / rsync.passwd
INOTIFY_EXCLUDE = '(.. * / * Log |.. * / * Swp) $'
INOTIFY_EXCLUDE_LIST = '/ usr / local / inotify / inotify_exclude.lst'
RSYNC_EXCLUDE = '/ etc / rsync_exclude.list'
  
#rsync client pwd check
if [! -e $ {rsync_pwd}]; then
    echo -e "rsync client passwod file $ {rsync_pwd} does not exist!"
    exit 0
fi
  
#inotify_function
#This Function is used to monitor folder (/ home / www) files, but exclude subfolders (storage, bootstrape / cache).
inotify_fun () {
    / Usr / local / inotify / bin / inotifywait -mrq --timefmt '% Y /% m /% d-% H:% M:% S' --format '% T% w% f'
          --exclude $ {INOTIFY_EXCLUDE} --fromfile $ {INOTIFY_EXCLUDE_LIST} -e modify, delete, create, move, attrib $ {source_path}
          | While read file
      do
          / Usr / bin / rsync -auvrtzopgP --exclude-from = $ {RSYNC_EXCLUDE} --progress --bwlimit = 500 --password-file = $ {rsync_pwd} $ {source_path} $ {rsync_user} @ $ {rsync_server}: : $ {rsync_module}
      done
}
#inotify log
inotify_fun >> $ {log_file} 2> & 1

Wherein INOTIFY_EXCLUDE_LIST = '/ usr / local / inotify / inotify_exclude.lst' as follows:
[Ec2-user @ ip-172-31-7-248 rsync] $ cat /usr/local/inotify/inotify_exclude.lst
/ Home / www
@ / Home / www / www.xxx.com / storage
@ / Home / www / www.xxx.com / bootstrap / cache
@ / Home / www / xxx.com / storage

RSYNC_EXCLUDE = '/ etc / rsync_exclude.list'

[Ec2-user @ ip-172-31-7-248 rsync] $ cat /etc/rsync_exclude.list
www.xxx.com/storage
www.xxx.com/bootstrap/cache
xxx.com/storage
     
         
         
         
  More:      
 
- Zypper command for SUSE Linux package management (Linux)
- Installation and Configuration JDK8 In CentOS 7 (Linux)
- Oracle create user authorization and in PLSQL (Database)
- Linux + Apache + PHP + Oracle based environment to build (Server)
- Ubuntu install ruby (Linux)
- Configuring automatic mail GAMIT under CentOS system (Linux)
- Dockerfile use to build a mirror-based CentOS 7 (Linux)
- Configuration based on open source Lucene Java development environment (Server)
- Atheros AR8161 / AR8162 network card driver problem solving in CentOS 6.4 (Linux)
- Availability Hadoop platform - Oozie Workflow (Server)
- Linux system started to learn: how to view the Linux thread of a process (Linux)
- OpenSSH version smooth upgrade method (Linux)
- MySQL5.7 JSON type using presentation (Database)
- Github Remote Assistance (Linux)
- mysqldump issue a note (Database)
- See Shell Script Linux Server network traffic (Server)
- Use Ambari rapid deployment Hadoop big data environment (Server)
- To configure and use multiple Tomcat under Linux environment (Server)
- Distributed Hadoop1.2.1 cluster installation (Server)
- SLF4J Tutorial (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.