1. 在两台机器上创建 RSA密钥
以下操作要在本地机和远程机上都执行一遍
(1)以 root 用户登录
(2)在 root 用户的 主目录内创建.ssh 目录并设置正确的权限
[iyunv@gsgatzhapp1 ~]# mkdir ~/.ssh
[iyunv@gsgatzhapp1 ~]# chmod 700 ~/.ssh
(3)使用 ssh-keygen 命令生成第 2 版本的 SSH 协议的 RSA 密钥
[iyunv@gsgatzhapp1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
17:e4:7c:79:8d:a0:00:3b:d9:f7:7a:56:f3:ac:54:4d oracle@gsgatzhapp1
在提示保存私钥(key)和公钥(public key)的位置时,使用默认值。如果需要私钥密码(passphrase),则输入一个私钥密码(如果使用私钥密码,使用 ssh 执行远程命令时需要输入私钥密码,因此,本案例中未使用私钥密码),因此,直接回车即可。
Unison可以在一台主机上使用,同步两个文件夹,也可以在网络上是用。
1:本地使用
使用方法:
#unison 111 222 #同步本地的111和222文件夹
Contacting server...
Looking for changes
Warning: No archive files were found for these roots. This can happen either
because this is the first time you have synchronized these roots,
or because you have upgraded Unison to a new version with a different
archive format.
Update detection may take a while on this run if the replicas are
large.
Unison will assume that the 'last synchronized state' of both replicas
was completely empty. This means that any files that are different
will be reported as conflicts, and any files that exist only on one
replica will be judged as new and propagated to the other replica.
If the two replicas are identical, then no changes will be reported.
Press return to continue.[<spc>] Reconciling changes
111 222
<---- file aaaaaaaaaaaaa [f] ?
Commands:
<ret> or f or <spc> follow unison's recommendation (if any)
I ignore this path permanently
E permanently ignore files with this extension
N permanently ignore paths ending with this name
m merge the versions
d show differences
x show details
l list all suggested changes
p or b go back to previous item
g proceed immediately to propagating changes
q exit unison without propagating any changes
/ skip
> or . propagate from left to right
< or , propagate from right to left
<---- file aaaaaaaaaaaaa [f] f
Proceed with propagating updates? [] y
Propagating updates
UNISON started propagating changes at 15:06:08 on 27 Aug 2007
[BGN] Copying aaaaaaaaaaaaa
from /222
to /111
[END] Copying aaaaaaaaaaaaa
UNISON finished propagating changes at 15:06:08 on 27 Aug 2007
Saving synchronizer state
Synchronization complete (1 item transferred, 0 skipped, 0 failures)
如果检测到两个文件夹有所不同,unison会提示,让你选择相应的操作。如上例所示.
表示右边222的文件夹有新的文件,是否同步到左边的111文件夹,f表示force,然后将确认,进行更新,如果输入?会有更详细的介绍。
五:unison FAQ
如何在和远程服务器同步大量数据,上传一部分数据后,超时:
9% 559:15 ETARead from remote host bluehost: Connection reset by peer
Fatal error: Lost connection with the server
实际操作中,最好的方法是,第一次先把要上传的文件打成包,用 ftp 上传,然后展开到服务器中,之后执行一次 unison 同步即可。
data timefmt comment
20xx/xx/xx %Y/%m/%d 20xx/xx/xx works well
December/96 %B/%y warning if mis-spelled
20xx/xxx %Y/%b 3-letters abbreviation
20xx/xx/xx %Y/%j “%j” is a day of the year (1-365)
02:45:03 %H:%M:%S “%H”, 24-hour
1076909172 %s seconts since 1/1/1970 00:00
可能出现的错误:
Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches'.