First, Rsync introduction.
Full name remote rynchronization.
Can be used to quickly replicate synchronous and remote backups between hosts, similar to SCP commands, but better than SCP commands, which can be incrementally copied.
It is also similar to the CP command, which is used for full or incremental copies between different local partitions or directories.
The ability to delete files and directories is also possible, similar to the RM command.
Second, rsync characteristics.
1. Support copying special type files such as device, link file.
2. You can exclude a specified file or directory, which is equivalent to excluding tar packaging.
3. You can keep the properties of the original file unchanged, such as the owner, group, modification time, soft and hard links, permissions and so on.
4. Incremental backups can be achieved, and backup efficiency is much higher than SCP full-volume copies.
5. You can use RCP, RSH, SSH channels to transfer files.
6. You can transfer files through the socket process.
7. Supports process mode transfer for anonymous or authenticated users (non-system users).
Three, common enterprise production scenario application
1. Data backup between servers.
2. Combine inotify to realize real-time data synchronization.
3. Back up the entire network data to a fixed backup storage server.
Iv. installation Deployment Configuration Combat Walkthrough
1. Local Backup
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/75/F6/wKioL1ZF23vzm--dAAA9xJisQyA170.jpg "Ti Tle= "1.jpg" alt= "Wkiol1zf23vzm--daaa9xjisqya170.jpg"/>
2. Rsync maintains parameter-avz for all attributes of the file
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/F8/wKiom1ZF3FazY7xGAAC55ppG5E8745.jpg "title=" 2.jpg " alt= "Wkiom1zf3fazy7xgaac55ppg5e8745.jpg"/>
3. Rsync implementation Delete
In fact, it is a kind of removal, it can be said to delete the copy, exclude the same files in the specified directory, delete the other, if the specified directory is empty directory, then delete all. Note that the specified directoryis followed by/and the deletion method is only relevant to the contents of the file in the specified directory, regardless of the directory name.
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/75/F6/wKioL1ZF3hPggYHeAAKLFEz4awI728.jpg "title=" 3.jpg " alt= "Wkiol1zf3hpggyheaaklfez4awi728.jpg"/>
4. Rsync channel push-pull, use the-e parameter to specify the channel.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/F6/wKioL1ZF4C3hkf-0AAGr14kPiyg783.jpg "title=" 4.jpg " alt= "Wkiol1zf4c3hkf-0aagr14kpiyg783.jpg"/>
5. Rsync parameters
-V Detailed Progress
-Z Compression transfer
-a archive mode, which transfers recursively, preserving file attributes.
6. Rsync Process Mode Walkthrough
Lab Environment:
The 192.168.0.31 NFS server acts as a server for rsync, receiving data synchronization for 192.168.0.21NGINX servers and 192.168.0.90MYSQL databases.
The default configuration file for the rsync process does not exist, created manually, vim/etc/rsyncd.conf
################################################################
UID = rsync
GID = rsync
Use chroot = no
Max connections = 200
Timeout = 300
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
[Asling]
Path =/home/data-asling
Ignore errors
Read Only = False
List = False
Hosts allow = 192.168.0.0/24
Hosts Deny = 192.168.0.0/32
Auth users = Rsync_backup
Secrets file =/etc/rsync.password
#################################################################
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/75/F8/wKiom1ZF7QSzyiWQAAFybWLbR70905.jpg "title=" 5.jpg " alt= "Wkiom1zf7qszyiwqaafybwlbr70905.jpg"/>
Start the process mode rsync, command rsync--daemon
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/75/F9/wKiom1ZF7pqjtr3-AAAhzHwxQGk358.jpg "title=" 6.jpg " alt= "Wkiom1zf7pqjtr3-aaahzhwxqgk358.jpg"/>
Increase the user and password, and set the password file permissions to 600.
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/75/F6/wKioL1ZF8H-QuTBkAAA4ip5M2W4509.jpg "title=" 7.jpg " alt= "Wkiol1zf8h-qutbkaaa4ip5m2w4509.jpg"/>
The client only needs to exist rsync software, configure the Etc/password password:
No user name is required here, the password file modification permission is 600 after configuration is complete.
echo "123456" >/etc/rsync.password
Client Pull Server instance (enter password mode)
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/75/F9/wKiom1ZF-WfBDbsiAACQ6IR-k_o009.jpg "title=" 8.jpg " alt= "Wkiom1zf-wfbdbsiaacq6ir-k_o009.jpg"/>
You need to specify the password file when using the password file, using the parameter--password-file=/path
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/75/F9/wKiom1ZF-grjU3jSAAE5FwNEbXI524.jpg "title=" 9.jpg " alt= "Wkiom1zf-grju3jsaae5fwnebxi524.jpg"/>
Five, enterprise-level application of practical combat
1. Client Exclusion Package
Use the--exclude= method to exclude
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/75/FA/wKiom1ZGEtbQqSuvAACESHZTtZ4619.jpg "title=" 2.jpg " alt= "Wkiom1zgetbqqsuvaaceshzttz4619.jpg"/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/75/F7/wKioL1ZGFBvglLmqAAB-xLSmRHY689.jpg "title=" 3.jpg " alt= "Wkiol1zgfbvgllmqaab-xlsmrhy689.jpg"/>
Use the--exclude-from= method to exclude
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/75/FA/wKiom1ZGFYPQcM_jAAFeq2eqAR8457.jpg "title=" 4.jpg " alt= "Wkiom1zgfypqcm_jaafeq2eqar8457.jpg"/>
2. Server-side exclusion package
Use the--exclude= method to exclude
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/75/FA/wKiom1ZGFxzz-_ygAAE7qsrnhZo126.jpg "style=" float: none; "title=" 5.jpg "alt=" Wkiom1zgfxzz-_ygaae7qsrnhzo126.jpg "/>
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/75/F7/wKioL1ZGF2mCQU4KAACMDvhAxAQ274.jpg "style=" float: none; "title=" 6.jpg "alt=" Wkiol1zgf2mcqu4kaacmdvhaxaq274.jpg "/>
3. Enterprise Important application: No difference synchronization (use of--delete parameters)
High-risk operation! Use with caution!
1. Client Exclusion Package
4. sharing multiple directories
Place the same parameters outside the module.
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/75/FA/wKiom1ZGHobA7W0lAAErJicgCGY583.jpg "title=" 7.jpg " alt= "Wkiom1zghoba7w0laaerjicgcgy583.jpg"/>
Sync Tool Rsync Learning notes