Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Unison under Centos7

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "how to use Unison under Centos7", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use Unison under Centos7" can help you solve your doubts.

Unison is a file synchronization tool that can be used on both windows and unix platforms. It enables two folders (local or network) to keep their contents consistent.

Environment Centos7 (1): 192.168.43.165Centos7 (2): 192.168.43.166 install Unison

Install the Epel source on both systems, and then install unison:

[root@192_168_43_165 ~] # yum-y install epel-release [root@192_168_43_165 ~] # yum makecach [root @ 192 "168" 43 "165] # yum-y install unison two operating systems configure ssh secret-free login [root@192_168_43_165] # ssh-keygen [root@192_168_43_165] # ssh-copy-id root@ 192.168.43.166 [root @ 192" 168 "43" 165 ~ ] # cd ~ / .ssh [root @ 192 / 168 / 43 / 165.ssh] # cat id_rsa.pub > authorized_ Keys [root @ 192 / 168 / 43 / 165.ssh] # scp id_rsa root@192.168.43.166:/root/.ssh how to use Unison

Unison is used to synchronize a set of files in a directory to another location with a similar structure, which can be a local host or a remote host.

Local file synchronization

Create two folders under the root home directory, one is "Files" and one is "Backup". Create files in Files and synchronize them to Backup.

[root@192_168_43_165 ~] # mkdir Files backup [root @ 192 / 168 / 43 / 165] # cd Files/ [root @ 192 / 168 / 43 / 165 Files] # touch file {1.. 10} .txt

Now run the unison command to synchronize the files to the Backup folder.

[root@192_168_43_165 ~] # unison-batch / root/Files / root/Backup

Check the Backup folder and find that the files have been synchronized.

Now modify a file in the Backup folder, then add the given file, and finally execute the command to see if it will be synchronized to the Files folder:

[root@192_168_43_165 Backup] # echo "testtesttest" > file2.txt [root @ 192: 168: 43: 165 Backup] # echo 'hello worldview' > index.html

Execute the unison command:

[root@192_168_43_165 ~] # unison-batch / root/Files / root/Backup

You can see that the contents of the Backup folder are synchronized to the Files.

Remote file synchronization

If remote file synchronization is required, Unison must be installed on both the local and remote servers.

Now create two folders under the root directory of the two servers for synchronizing files.

# create a folder on the first server. [root@192_168_43_165 ~] # mkdir Files# creates a folder on the second server. [root@192_168_43_166 ~] # mkdir Files

Let's use the-testServer option to test connectivity between the local and remote servers.

[root@192_168_43_165 ~] # unison-testServer / root/Files ssh://root@192.168.43.166//root/FilesContacting server...Connected [/ / 192_168_43_165//root/Files-> / / 192_168_43_166//root/Files]

After we have no problem with connectivity, we can execute the command to synchronize files:

[root@192_168_43_165 ~] # unison-batch / root/Files ssh://root@192.168.43.166//root/Files use Unison to synchronize files using Unison to synchronize files

Check the / root/Files folder on the second server to see if the files have been synchronized:

After reading this, the article "how to use Unison under Centos7" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report