{"id":199102,"date":"2020-08-26T10:46:14","date_gmt":"2020-08-26T02:46:14","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=199102"},"modified":"2020-08-23T17:46:39","modified_gmt":"2020-08-23T09:46:39","slug":"unison-sync-files","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/unison-sync-files.html","title":{"rendered":"\u4f7f\u7528Unison \u540c\u6b65\u6587\u4ef6"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nUnison\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u6587\u4ef6\u540c\u6b65\u5de5\u5177\uff0c\u5b83\u5728\u540c\u6b65\u8ba1\u7b97\u673a\u6216\u5b58\u50a8\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u65f6\u975e\u5e38\u6709\u7528\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u73af\u5883<\/strong><\/div>\n
    \n
  • Centos7(1): 192.168.43.165<\/li>\n
  • Centos7(2): 192.168.43.166<\/li>\n<\/ul>\n
    \u5b89\u88c5Unison<\/strong><\/div>\n

    \u5728\u4e24\u4e2a\u7cfb\u7edf\u4e2d\u90fd\u8981\u5b89\u88c5epel\u6e90\uff0c\u7136\u540e\u90fd\u8981\u5b89\u88c5unison\uff1a<\/p>\n

    \r\n[root@192_168_43_165 ~]# yum -y install epel-release\r\n[root@192_168_43_165 ~]# yum makecache\r\n[root@192_168_43_165 ~]# yum -y install unison\r\n<\/pre>\n
    \u4e24\u53f0\u64cd\u4f5c\u7cfb\u7edf\u914d\u7f6essh\u514d\u5bc6\u767b\u5f55<\/strong><\/div>\n
    \r\n[root@192_168_43_165 ~]# ssh-keygen \r\n<\/pre>\n

    \"\"<\/p>\n

    \r\n[root@192_168_43_165 ~]# ssh-copy-id root@192.168.43.166\r\n[root@192_168_43_165 ~]# cd ~\/.ssh\r\n[root@192_168_43_165 .ssh]# cat id_rsa.pub > authorized_keys\r\n[root@192_168_43_165 .ssh]# scp id_rsa root@192.168.43.166:\/root\/.ssh\r\n<\/pre>\n
    \u5982\u4f55\u4f7f\u7528Unison<\/strong><\/div>\n

    Unison\u7528\u4e8e\u5c06\u76ee\u5f55\u4e2d\u7684\u4e00\u7ec4\u6587\u4ef6\u540c\u6b65\u5230\u7ed3\u6784\u76f8\u4f3c\u7684\u53e6\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u8be5\u4f4d\u7f6e\u53ef\u4ee5\u662f\u672c\u5730\u4e3b\u673a\u6216\u8fdc\u7a0b\u4e3b\u673a\u3002<\/p>\n

    \u672c\u5730\u6587\u4ef6\u540c\u6b65<\/strong><\/span><\/div>\n

    \u5728root\u5bb6\u76ee\u5f55\u4e0b\u9762\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\u5939\uff0c\u4e00\u4e2a\u662f\"Files\"\uff0c\u4e00\u4e2a\u662f\"Backup\"\u3002Files\u91cc\u9762\u521b\u5efa\u6587\u4ef6\uff0c\u540c\u6b65\u5230Backup\u91cc\u9762\u3002<\/p>\n

    \r\n[root@192_168_43_165 ~]# mkdir Files Backup\r\n[root@192_168_43_165 ~]# cd Files\/\r\n[root@192_168_43_165 Files]# touch file{1..10}.txt\r\n<\/pre>\n

    \"\"
    \n\u73b0\u5728\u8fd0\u884cunison<\/code>\u547d\u4ee4\uff0c\u540c\u6b65\u6587\u4ef6\u5230Backup\u6587\u4ef6\u5939\u91cc\u9762\u3002<\/p>\n

    \r\n[root@192_168_43_165 ~]# unison -batch \/root\/Files \/root\/Backup\r\n<\/pre>\n

    \"\"
    \n\u67e5\u770b\u4e00\u4e0bBackup\u6587\u4ef6\u5939\uff0c\u53d1\u73b0\u6587\u4ef6\u540c\u6b65\u8fc7\u6765\u4e86\u3002
    \n\"\"
    \n\u73b0\u5728\u4fee\u6539\u4e00\u4e0bBackup\u6587\u4ef6\u5939\u91cc\u9762\u7684\u67d0\u4e2a\u6587\u4ef6\uff0c\u7136\u540e\u518d\u6dfb\u52a0\u5df2\u7ed9\u6587\u4ef6\uff0c\u6700\u540e\u6267\u884c\u4e00\u4e0b\u521a\u624d\u7684\u547d\u4ee4\uff0c\u770b\u770b\u662f\u5426\u4f1a\u540c\u6b65\u5230Files\u6587\u4ef6\u5939\u4e2d\uff1a<\/p>\n

    \r\n[root@192_168_43_165 Backup]# echo \"testtesttest\" > file2.txt \r\n[root@192_168_43_165 Backup]# echo 'hello world!' > index.html\r\n<\/pre>\n

    \"\"
    \n\u6267\u884cunison<\/code>\u547d\u4ee4\uff1a<\/p>\n

    \r\n[root@192_168_43_165 ~]# unison -batch \/root\/Files \/root\/Backup\r\n<\/pre>\n

    \"\"
    \n\u53ef\u4ee5\u770b\u5230Backup\u6587\u4ef6\u5939\u91cc\u9762\u7684\u5185\u5bb9\u540c\u6b65\u5230Files\u91cc\u9762\u4e86
    \n\"\"<\/p>\n

    \u8fdc\u7a0b\u6587\u4ef6\u540c\u6b65<\/strong><\/span><\/div>\n

    \u5982\u679c\u9700\u8981\u8fdb\u884c\u8fdc\u7a0b\u6587\u4ef6\u540c\u6b65\uff0c\u5fc5\u987b\u5728\u672c\u5730\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5Unison\u3002<\/p>\n

    \u4e0b\u9762\u73b0\u5728\u4e24\u53f0\u670d\u52a1\u5668\u7684root\u76ee\u5f55\u4e0b\u9762\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\u5939\uff0c\u4e3a\u540c\u6b65\u6587\u4ef6\u4f7f\u7528\u7684\u3002<\/p>\n

    \r\n# \u5728\u7b2c\u4e00\u53f0\u670d\u52a1\u5668\u521b\u5efa\u6587\u4ef6\u5939\u3002\r\n[root@192_168_43_165 ~]# mkdir Files\r\n# \u5728\u7b2c\u4e8c\u53f0\u670d\u52a1\u5668\u521b\u5efa\u6587\u4ef6\u5939\u3002\r\n[root@192_168_43_166 ~]# mkdir Files\r\n<\/pre>\n

    \u4e0b\u9762\u4f7f\u7528-testServer<\/code>\u9009\u9879\u6d4b\u8bd5\u672c\u5730\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8fde\u901a\u6027\u3002<\/p>\n

    \r\n[root@192_168_43_165 ~]# unison -testServer \/root\/Files ssh:\/\/root@192.168.43.166\/\/root\/Files\r\nContacting server...\r\nConnected [\/\/192_168_43_165\/\/root\/Files -> \/\/192_168_43_166\/\/root\/Files]\r\n<\/pre>\n

    \"\"
    \n\u8fde\u901a\u6027\u6ca1\u95ee\u9898\u4e4b\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6267\u884c\u547d\u4ee4\u540c\u6b65\u6587\u4ef6\u4e86\uff1a<\/p>\n

    \r\n[root@192_168_43_165 ~]# unison -batch \/root\/Files ssh:\/\/root@192.168.43.166\/\/root\/Files\r\n<\/pre>\n

    \"\"<\/p>\n

    \"\"
    \n\u67e5\u770b\u7b2c\u4e8c\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u7684\/root\/Files<\/code>\u6587\u4ef6\u5939\uff0c\u6587\u4ef6\u662f\u5426\u540c\u6b65\u8fc7\u6765\u4e86\uff1a
    \n\"\"<\/p>\n

    \u603b\u7ed3<\/strong><\/div>\n

    Unison\u975e\u5e38\u6613\u4e8e\u4f7f\u7528\uff0c\u4e0d\u9700\u8981\u989d\u5916\u7684\u7cbe\u529b\u3002\u5b83\u53ef\u4ee5\u5728GUI\u4ee5\u53ca\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u4efb\u4f55\u4e00\u79cd\u65b9\u5f0f\u8fdb\u884c\u81ea\u5b9a\u4e49\u540c\u6b65\u3002\u5982\u679c\u9700\u8981\u4f7f\u7528\u56fe\u5f62\u754c\u9762\uff0c\u53ef\u4ee5\u5728\u684c\u9762\u73af\u5883\u6267\u884cunison-gtk-2.40<\/code>\u6253\u5f00\u56fe\u5f62\u754c\u9762\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    Centos7(1): 192.168.43.165 Centos7(2): 192.168.43.166 \u5728 […]<\/p>\n","protected":false},"author":309,"featured_media":199103,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-199102","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=199102"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199102\/revisions"}],"predecessor-version":[{"id":199116,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199102\/revisions\/199116"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/199103"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=199102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=199102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=199102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}