![]() If I fileSrcThis side adds a character in the middle of the file, so that the following file blocks will be displaced by a character, so that the sum is complete. checksumThen, and fileDstOf checksumBy contrast, you know which file blocks have changed.īut you are smart enough to have the following two questions: When the Synchronized Source Machine gets this list, it will fileSrcDo the same thing. rolling checksum(32bits),md5 checksume(128bits)File block number. Synchronized target end will fileDstOne checksumThe list is passed to the synchronization source, which includes three things. That is to say, weak checksumIt is used to distinguish differences, but strong is used to confirm the same. checksumThe algorithm ensures that the two file blocks are identical. adler32The collision probability of the algorithm is too high, so we need to introduce strong ones. md4The algorithm is too slow, so we need a fast algorithm to identify the different file blocks, but weak. Why do you want to do this? Because a few years ago it ran on hardware. checksum, 128Bit, formerly used md4Now use md5 hashAlgorithm. One is called rolling checksumIt is weak.512One byte (the last block will be less than this number), and then calculate two for each block. blocks Checksumalgorithmįirst of all, we will fileDstOn average, the files are divided into several small pieces, such as each. We will name the synchronization source file as fileSrcSynchronized destination file is called fileDst。 1. So we have to figure out a way to make the documents on both sides invisible, but we still know what the difference is between them. diffBut in this way, we passed on the whole document, which is contrary to the original intention that we only want to transfer different departments. diff。 If we do diffYou have to transfer one file to another machine to do it. diffBut these two problems can’t be done on two different machines. If we need to synchronize the two files and keep them in line, and just want to transfer different parts, then we need to do the files on both sides. rsyncThe main feature is incremental transmission, which only transmits the changed parts. Rsyncyes linuxAn efficient algorithm for downward synchronization of files is used to synchronously update files and directories of two computers, and to properly use different blocks in the lookup file to reduce data transmission. The content of this section reproduces the core algorithm of RSYNC greatly, because the original article is too well written, no longer dog tail mink, interested can directly view the original text. ![]() RsyncThe function is very powerful, the information on the Internet is also very complete, here do some simple summary. But at this point we have a better way, that is rsync+crontabTo achieve timing incremental transmission to maintain file consistency. If there is a need for consistency between servers, we can use scpTo replicate, if long-term consistency is required, you can cooperate crontabThe script is used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |