Unison
如何在 Ubuntu 和 CentOS 7 之間同步執行
我正在嘗試在 Ubuntu 實例和 CentOS 7 實例之間同步數據。這就像一個雙向 rsync,所以我認為unison將是最好的工具。我在兩個實例上都安裝了它,但是當我嘗試連接它們時,我收到一個錯誤,因為版本不同:
unison -testServer . ssh://myuser@myremotehost/efs/home/ Contacting server... myuser@myremotehost's password: Fatal error: Received unexpected header from the server: expected "Unison 2.48\n" but received "Unison 2.40\n\000\000\000\000\017", which differs at "Unison 2.40". This can happen because you have different versions of Unison installed on the client and server machines, or because your connection is failing and somebody is printing an error message, or because your remote login shell is printing something itself before starting Unison.
因此,我嘗試使版本匹配,但是當我查看時,我只看到 Ubuntu 上可用的一個版本。
myuser@mylocalhost:/nas/$ apt policy unison unison: Installed: 2.48.4-1ubuntu1 Candidate: 2.48.4-1ubuntu1 Version table: *** 2.48.4-1ubuntu1 500 500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages 100 /var/lib/dpkg/status
當我查看 CentOS 7 時,我看不到任何版本
$ yum --showduplicates list unison Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: d36uatko69830t.cloudfront.net * epel: mirror.prgmr.com * extras: d36uatko69830t.cloudfront.net * updates: d36uatko69830t.cloudfront.net Error: No matching Packages to list
但是,我可以毫無問題地安裝它:
$ sudo yum install unison Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: d36uatko69830t.cloudfront.net * epel: d2lzkl7pfhq30w.cloudfront.net * extras: d36uatko69830t.cloudfront.net * updates: d36uatko69830t.cloudfront.net Package unison240-gtk-2.40.128-5.el7.x86_64 already installed and latest version Nothing to do
我在查找版本時做錯了嗎?我怎樣才能讓它們匹配?
本地主機是:
myuser@mylocalhost:/nas$ cat /etc/*release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04
遠端主機是:
$ cat /etc/*release CentOS Linux release 7.6.1810 (Core)
根據@Freddy 的評論,關鍵是在 CentOS 上從原始碼編譯一致:
yum install ocaml ocaml-camlp4-devel ctags ctags-etags cd ~ wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.4.tar.gz tar xvfz unison-2.48.4.tar.gz cd src make sudo cp -v unison /usr/local/sbin/ sudo cp -v unison /usr/bin/ cd ~ rm -fr src
然後你就可以同步執行了:
在本地伺服器上,轉到所需的位置,然後使用
unison -testServer . ssh://myuser@myremotehost//path/to/data/
要做真正的事情,只需
-testServer
從上面刪除。在這樣做之前tmux也是一個好主意。