In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This paper gives an example of the method of using rsync to synchronize backup files in CentOS6.5 environment. Share with you for your reference, the details are as follows:
Rsync is the next file synchronization tool in linux, which is introduced as follows: Rsync is a remote data synchronization tool that can quickly synchronize files between multiple hosts through LAN/WAN. Rsync was originally a tool to replace rcp, which is currently maintained by rsync.samba.org. Rsync uses the so-called "Rsync algorithm" to synchronize files between local and remote hosts, which transfers only different parts of the two files instead of the whole file each time, so it is quite fast. The machine running Rsync server is also called backup server, and one Rsync server can back up the data of multiple client at the same time, or multiple Rsync server can back up the data of one client. Rsync can be paired with rsh or ssh or even daemon mode. Rsync server will open a service channel (port) of 873 and wait for the other party to connect with Rsync. When connecting, Rsync server checks whether the password matches, and if checked by the password, you can start the file transfer. When the first connection is complete, the entire document will be transferred once, and the next time only the different parts between the two files will be transferred. Rsync supports most Unix-like systems, and has been well tested on Linux, Solaris, and BSD. In addition, it also has corresponding versions under the windows platform, the more well-known are cwRsync and Sync2NAS.
The basic features of Rsync are as follows:
1. You can mirror and save the entire directory tree and file system
two。 It is easy to maintain the permissions, time, soft and hard links of the original file, etc.
3. Can be installed without special permission
4. Optimized process, high efficiency of file transfer
5. You can use rcp, ssh, etc., to transfer files, of course, through a direct socket connection
6. Anonymous transmission is supported.
On linux, if we want to copy files remotely, we can use the scp command. Scp is also a very simple and lightweight command, so what's the difference between today and rsync? In fact, the main difference is reflected in the title of the article. Rsync synchronization will only copy and backup incremental files, but will not backup existing files that have not changed. What does it mean?
Sanxian gives an example as follows: on server A, there is an a.txt file in a folder. The first time we backup a folder on server An on server B, we will copy the a.txt file to a folder on server B. now we add a new b.txt under folder an on server A, and perform synchronization again, and we will find that only file b has been synchronized this time. The original a file has not changed, if we change the contents of an or b file on A service, then when we synchronize again, we will synchronize the changed files, which is the biggest difference from scp, because scp does not have this function. If there is no rsync component, you can first execute the yum install rsync command to install, Sanxian used the rsync command, do not need to configure any conf files, only need to use the command line on it, very concise.
The test machine IP is as follows:
Serial number IP address abbreviation 1192.168.46.32A machine 2192.168.46.11B machine
First, take a look at the files under the logs folder on machine A:
[root@h2 logs] # ll
Total dosage 4
-rw-r--r-- 1 root root 3 August 30 02:29 a.txt [root@h2 logs] #
Then, on machine B, we execute the synchronization command as follows:
[root@h3 logs] # ll
Total dosage 0
[root@h3 logs] # rsync-av-- delete 192.168.46.32:/root/logs / root/logg/receiving incremental file listlogs/logs/a.txtsent 34 bytes received 107 bytes 282.00 bytes/sectotal size is 3 speedup is 0.02 [root@h3 logs] # ll
Total dosage 4
-rw-r--r-- 1 root root 3 August 30 02:29 a.txt [root@h3 logs] #
Then, under the log file on machine A, add a b.txt, and then test the synchronization command:
[root@h3 logs] # rsync-av-- delete 192.168.46.32:/root/logs / root/logg/receiving incremental file listlogs/logs/b.txtsent 34 bytes received 125 bytes 318.00 bytes/sectotal size is 5 speedup is 0.03 [root@h3 logs] #
Through the log, we found that if we add a new one that only synchronizes the new files using rsync: now we add a line to the a.txt under the log folder on server A, and execute the synchronization command again:
[root@h3 logs] # rsync-av-delete 192.168.46.32:/root/logs / root/logg/receiving incremental file listlogs/a.txtsent 37 bytes received 128 bytes 330.00 bytes/sectotal size is 9 speedup is 0.05 [root@h3 logs] #
We found that the rsync command can also be well recognized. Finally, let's take a look at it and change the an and b files on server A, one to add a line and one to delete one line to measure the increment:
[root@h3 logs] # rsync-av-- delete 192.168.46.32:/root/logs / root/logg/receiving incremental file listlogs/logs/a.txtlogs/b.txtsent 65 bytes received 174bytes 478.00 bytes/sectotal size is 10 speedup is 0.04 [root@h3 logs] #
We found that rsync can also identify it very well. Finally, let's take a look at how to send data to server An on server B. Note that Sanxiangang's demonstration above is to download data from server A from server B. now we are going to demonstrate how to actively send data to server An on service B. the principle is the same, it is all operated incrementally, but the location is changed by writing IP:
[root@h3 logs] # rsync-av-- delete / root/logg/logs/b.txt 192.168.46.32:/root/sending incremental file listb.txtsent 87 bytes received 37 bytes 248.00 bytes/sectotal size is 10 speedup is 0.08 [root@h3 logs] #
I hope what is described in this article will be helpful to the maintenance of CentOS server.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.