Comprehensive Architecture Design and Rsync Backup Implementation
Environment Configuration
A standardized environment setup is essential for our infrastructure:
- Optimized virtual machines
- Consistent hostname configuration
- IP address standardization
- Functional name resolution
Required Infrastructure Components
The following virtual machines are necessary for our architecture:
- Load balancers: 2 nodes
- Web servers: 2 nodes
- Storage server: 1 node
- Backup server: 1 node
- Cache server: 1 node
- Bastion host: 1 node
- Batch management server: 1 node
- Monitoring system: 1 node
Note: The bastion host and batch management server should not be co-located.
Domain Name Configuration
Configure /etc/hosts on all servers for proper name resolution:
cat >/etc/hosts<<EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.51 db01 db01.etiantian.org
172.16.1.61 m01
EOF</code>
Rsync Service Overview
Rsync is a versatile tool for data synchronization and backup. It combines features of several traditional utilities:
- Full and incremental data replication
- Local and remote file synchronization
- File and directory deletion capabilities
Rsync Key Features
Full vs. Incremental Replication
- Full replication: Copies all files regardless of changes (similar to scp)
- Incremental replication: Only copies new or modified files (rsync's strength)
A single rsync command can replace multiple utilities: cp, rm, ls, with enhanced capabilities.
Local Backup Strategy
For local backups, rsync can be combined with cron scheduling for automated backups.
Remote Backup Implementation
For remote backups, rsync provides more efficient transfer than scp by only syncing changed files.
# scp command options
-p: Preserves file modification time, access time, and permissions
-r: Recursive directory copying
Rsync Application Scenarios
- Cross-server data backup
- Scheduled backups using cron and rsync
- Real-time storage server synchronization for redundancy
- Integration with sersync for real-time synchronization
Rsync Operational Modes
Push vs. Pull Operations
- Push: Transfer data from local to remote server
- Pull: Retrieve data from remote server to local
Command Syntax
Local: rsync [OPTIONS...] SRC... [DEST]
Remote shell access:
Pull: rsync [OPTIONS...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTIONS...] SRC... [USER@]HOST:DEST
Rsync daemon access:
Pull: rsync [OPTIONS...] [USER@]HOST::SRC... [DEST]
rsync [OPTIONS...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTIONS...] SRC... [USER@]HOST::DEST
rsync [OPTIONS...] SRC... rsync://[USER@]HOST[:PORT]/DEST
Key Terms
- SRC: Source - Where data comes from
- DEST: Destination - Where data goes
- PULL: Retrieving data from remote
- PUSH: Sending data to remote
Local Rsync Operations
Directory vs. Directory Contents
- /tmp: Directory and its contents
- /tmp/: Only contents of the directory
Basic Command Format
rsync [source] [destination] - Data flows from source to destination
Common Parameters
-a: Archive mode - recursive copy with preserved attributes
-v: Verbose output - shows detailed sync process
-z: Compression - compresses data during transfer
--delete: Delete extraneous files from destination directory
Practical Examples
# Basic file copy
rsync -av /etc/hosts /tmp/
# Directory copy
rsync -av /etc/ /tmp/etc
# Sync with deletion
rsync -avz --delete /tmp/ /mnt/
# Remote push operation
rsync -avz /local/data/ user@remote:/remote/path/
# Remote pull operation
rsync -avz user@remote:/remote/path/ /local/data/
Advanced Rsync Applications
Rsync can be implemented in enterprise environments for:
- Network-wide backup solutions
- Real-time storage synchronization to prevent single point of failure
- Automated backup scheduling with cron
- Integration with monitoring systems for backup status tracking