First, the experimental environment
Host Name
|
Network card IP
|
Default Gateway
|
Use
|
Nfs-server
|
10.0.0.11
|
10.0.0.254
|
Rsync Server Side
|
web-client01
|
10.0.0.12
|
10.0.0.254
|
Rsync Customer Service Side
|
web-client02
|
10.0.0.13
|
10.0.0.254
|
Rsync Customer Service Side
|
Second, the experimental steps
1. What is rsync?
Rsync is an open-source, fast, versatile tool that enables full-scale and incremental data backup synchronization, and is suitable for a wide range of operating systems.
2.rsync Features
1) Support copy of link file special files
2) can exclude files or directories, similar to the--exclude function of packaging command tar
3) enables incremental and full backup data functions
4) Can transfer files and data via socket
3.rsync Applications in the enterprise
1) Synchronize all client server data to the backup server
2) Synchronize data between two servers regularly
3) Implementation of multiple server data real-time backup mechanism (RSYNC+INOTIFY/RSYNC+SERSYNC)
Production Scenario Cluster Architecture server sub-scheme
1) for the company's important data chaos and leadership of the proposed backup of the entire network of data solutions
2) by locally packaged backup, then rsync+inotify/rsync+sersync the data back to a fixed storage server, then checks and sends alerts to the administrator for backup results on the storage server.
3) regularly back up the data in the IDE room to the internal server, prevent the engine room fire and other factors.
rsync command:
rsync [OPTION ...] Src... [DEST]
-A: means the file is transferred in the archive mode
-R: Subdirectories in recursive mode (recursive)
-V: Verbose mode output
-Z: Compress during transfer
-P: Hold Property
--exclude: Exclude
--exclede-from: What to exclude from what
--bwlimit: Speed limit
Rsync-avz/etc/hosts/tmp---Similar copy (CP)
Rsync-r--delete/null//data/---Similar delete (RM)
Pull:rsync [OPTION ...] [[email protected]] Host:src ... [DEST]
Push:rsync [OPTION ...] Src... [[email protected]] Host:dest
Rsync-avzp-e ' ssh-p '/etc/hosts/[email protected]:/tmp
Rsync-avzp-e ' ssh-p ' [email protected]:/data//tmp/chen
4. How the Daemon (socket) transmits data
1.1 Service-side configuration is as follows:
1) Check if rsync is installed and no Yum can be used to install
Rpm-qa rsync
Yum-y Install Rsync
2) Configuring the Rsync configuration file
#Rsync Server
#created by Chen 2016.6.9
# #rsyncd. conf start##
UID = rsync
GID = rsync
Use chroot = no
Max connections = 2000
Timeout = 300
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
Ignore errors
Read Only = False
List = False
Hosts allow = 10.0.0.0/24
Hosts Deny = 0.0.0.0/32
Auth users = Rsync_backup
Secrets file =/etc/rsync.password
#####################################
[Backup]
Comment = Backup by Chen
Path =/backup
#####################################
3) Create users and shared directories
Useradd rsync-s/sbin/nologin-m
Mkdir/backup
Chown-r Rsync.rsync/backup
4) write the password file to/etc/rsync.password and grant permissions
echo "Rsync_backup:chen" >/etc/rsync.password
chmod 600/etc/rsync.password
5) Start the Rsync service
Rsync--daemon
6) Check that the port is open
NETSTAT-TUNPL |grep 873
Lsof-i: 873
1.2 Client side configuration is as follows:
1) write the password file to/etc/rsync.pasword
echo "Rsync_backup:chen" >/etc/rsync.pasword
2) The Remote data synchronization test, whether to achieve the Pull/push function
rsync-avz/tmp [Email Protected]::backup--password-file=/etc/rsync.password
Rsync-avz [Email Protected]::backup--password-file=/etc/rsync.password
Note: The push-pull of rsync data can only be performed on the customer service side
5. Client exclusion Commands
Rsync-avz--exclude=a/data/[Email protected]::backup--password-file=/etc/rsync.password
Rsync-avz--exclude={a. g}/data/[email protected]::backup--password-file=/etc/rsync.password
6. Server-side exclusion commands
Place the following command in/etc/rsyncd.conf (not commonly used)
Exclude=a B/tmp/chen
7. No differential backup (careful use, there is a certain risk of operation, generally in the data between the two servers must be the same time use)
Rsync-avz--delete/tmp/[Email protected]::backup--password-file=/etc/rsync.password
Rsync-avz--delete [Email protected]::backup/tmp--password-file=/etc/rsync.password
For more detailed steps, please click here: http://purify.blog.51cto.com/10572011/1768103
This article is from "Wake up your not alarm clock but dream" blog, please be sure to keep this source http://purify.blog.51cto.com/10572011/1787771
Re-summary of rsync remote Data backup configuration