Unison Introduction
Rsync data mirroring is a single item, and the client is only kept in sync with the server, and when the client adds or deletes some files, it does not sync to the servers side. and Unison can complete bidirectional synchronization, any one end of the data changes, will be updated to the corresponding end. Unison is developed using the OCaml language, and the two ends are updated to a consistent state by comparing the files on both ends based on the rsync algorithm.
Unison characteristics
Cross-platform
Two-way synchronization, automatic update of two copies there are no conflicting parts, conflicting parts are selected by the user to update the policy
Support for incremental synchronization, the file status is logged each time the synchronization is complete, and the next time synchronization, the last state as the starting point for synchronization
Installing unison
The first thing to install is OCaml
# CD ocaml-4.02.1
#./configure
# make World opt
# make Install
# CD unison-2.48.3
# Make Uistyle=text threads=true
Error occurred:
Which:no Etags in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/latest/bin:/usr/local/ Tomcat/bin:/root/bin)
/bin/sh:line 1:etags:command not found
MAKE[1]: [tags] Error 127 (ignored)
MAKE[1]: leavingdirectory '/unison/unison-2.48.3 '
Workaround:
# yum Install Ctags-etags
# Make Uistyle=text threads=true
Copy the unison command to a path path
# CP Unison/usr/local/bin
The unison command uses
# Unison/test1/test2
Unison < local directory > ssh://remote_ip/< absolute path >
# Unison/test1 Ssh://192.168.1.13//test2
TestServer
Test connectivity, connect to the server and exit
unison/ssh://[email protected]/-testserver
Servercmd
Tell unison what the server unsion command is
unison/ssh://[email protected]/-testserver-seervercmd=/usr/local/bin/unison
Auto
Receives the default action, waits for the user to confirm whether the execution
Batch
Fully automatic mode, accept the default action and execute
Ignore
Ignore XXX
Directories or paths that are ignored when synchronizing
IgnoreCase
Whether to ignore file name capitalization
Follow
Follow xxx
Whether to follow the symbolic link
Patch
Patch XXX
Synchronizes only the specified directories and files, not the entire directory, and can be specified multiple times
Owner Group
Synchronization belongs to the main genus Group
perms =-1
Keep Read and Write permissions
Repeat
Retry
Sshargs =-C
Xferbycopying
Immutable xxx
Specify a directory that does not change, ignoring when scanning
Slient
Silent mode
Times
Synchronization modification Time
Masthreads N
Maximum number of threads
Rsync
Default ture, activate rsync transfer mode
Log
Record log
LogFile
Log file
Using Unison with configuration files
Synchronizing the/www/mingxiao directory of native and 192.168.1.13
First, the confidential and 192.168.1.13 two-machine mutual trust, the specific method no longer write
Vim/root/.unison/ixbda.prf
root = /www/mingxiao #要同步的文件夹root =ssh://[email protected]//www/mingxiao # To synchronize the folder #force = /www/mingxiao #以本地文件为标准, sync the directory to the remote host, turn it on and turn it into a single synchronization Path = web1path = web2 #只同步 Web1 and WEB2 directories under the/www/mingxiao directory ignore = path tmp #忽略同步/www/ Mingxiao/tmp Directory #prefer =ssh://[email protected]//www/mingxiaobatch = true #全自动模式 , accept and execute the default action maxthreads = 300 #同步时最大线程数repeat = 1 #间隔一秒后, start a new sync check retry = 3 #重试次数owner = truegroup = trueperms = -1 #保持同步过来读写权限sshargs = -C #使用ssh压缩传输方式 perms = -1fastcheck = false # True indicates that the files are compared between the two files at the time of synchronization, and if False, the contents of the two files are compared. Suggested truersync = false#debug = verbosesshargs = -cxferbycopying = trueconfirmbigdel = false #默认值是true, indicating that when one of the two directories that need to be synchronized is empty, Unison will stop and this is set to false, even if the empty unison does not stop running log = truelogfile = /tmp/unison.log
# unison Ixbda to start syncing
This article is from the "on the Road" blog, please be sure to keep this source http://mingxiao.blog.51cto.com/8124243/1675361
Unison bidirectional Sync Tool uses