BitTorrent-Sync是一款基于P2P的分布式文件同步工具,简称btsync,非开源软件但免费使用。本文使用btsync实现两台服务器上的软件双向同步。

安装

直接从官网下载相应的安装包,为了在Linux服务器上安装,使用的是Linux x64版本BitTorrent-Sync_x64.tar.gz

然后解压到指定的文件夹,即可执行程序。


sudo mkdir -p /usr/local/btsync
sudo chown shenfeng /usr/local/btsync
tar -zxvf BitTorrent-Sync_x64.tar.gz -C /usr/local/btsync/

进入解压后的目录,可以看到3个文件,其中btsync为可执行文件。


$ ls
btsync LICENSE.TXT README

执行--help可以查看帮助信息


./btsync --help BitTorrent Sync 2.3 (239)
Usage:
btsync [ options ... ]
Options:
--help Print this message
--config Use a configuration file
--storage Storage path for identity and license
--identity Creates user identity
--license Apply owner license
--nodaemon Do not daemonize
--dump-sample-config Print a sample configuration file
--log Set log file
--webui.listen : Set the webui listening interface
--generate-secret Generate a read/write key
--get-ro-secret Get the read-only key associated to a read/write key

配置

编写启动脚本。


$ sudo vi /etc/init.d/btsync
#!/bin/sh
#
# description: starts and stops the btsync client CONF=/usr/local/btsync/btsync.cfg
PROC=/usr/local/btsync/btsync
PIDFILE=/usr/local/btsync/btsync.pid start() {
PID1=$(pidof btsync)
if [ -z ${PID1} ]; then
echo -n "Starting BitTorrent Sync: "
${PROC} --config ${CONF}
else
echo "BitTorrent Sync is already running at pid:${PID1}"
fi
return $?
} stop() {
echo -n "Stopping BitTorrent Sync: "
PID1=$(pidof btsync)
if [ ! -z ${PID1} ]; then
kill -9 ${PID1}
echo "OK"
else
echo "Failed"
fi
return $?
} status() {
PID1=$(pidof btsync)
PID2=$(cat ${PIDFILE})
echo -n "Checking BitTorrent Sync: "
if [ ! -z ${PID1} ] && [ "${PID1}" -eq "${PID2}" ]; then
echo "OK"
else
echo "Failed"
fi
return $?
} case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac

编写启动配置文件


{
"device_name": "vm_2",
"listening_port" : 8889, // 0 - randomize port "check_for_updates" : false,
"use_upnp" : false, "storage_path" : "/usr/local/btsync",
"pid_file" : "/usr/local/btsync/btsync.pid", "download_limit" : 0, // 0 - no limit
"upload_limit" : 0, "webui" :
{
"listen" : "0.0.0.0:8888",
"login" : "admin",
"password" : "btsync"
} ,
"folder_rescan_interval" : 1,
"lan_encrypt_data" : false,
}

启动程序,通过web页面进行登录和后续配置。


$ /etc/init.d/btsync start
Starting BitTorrent Sync: By using this application, you agree to our Privacy Policy, Terms of Use and End User License Agreement.
https://www.getsync.com/legal/privacy
https://www.getsync.com/legal/terms-of-use
https://www.getsync.com/legal/eula Webui is listening on 0.0.0.0:8888
BitTorrent Sync forked to background. pid = 15002

在浏览器页面登录控制页面,即服务器IP+8888端口。

使用配置文件中的账号密码进行登录。

在启动一台主机上,点击左上角的Add Folder按钮,增加需要同步的目录。

确认打开目录后,会生成该目录的Key,因为需要双向同步,那么选择READ+WRITE的Key。

登录第二台服务器,登录后,点击Add Folder的第三个选项。填入上面复制的Key之后,选择本地用于同步的目录就可以进行同步了。

参考文档

使用BitTorrent-Sync实现双机文件双向同步的更多相关文章

  1. BitTorrent Sync - 神奇的文件同步软件,无需服务器让多台电脑互相同步!

    176,487 微博 腾讯 空间 微信 141 49 如今人们对文件备份和同步的需求已经越来越强烈了.像 Dropbox 一样的云存储网盘有很多,但它们都有一个局限性,就是所有的文件都得经过它们的服务 ...

  2. Linux下 Unison 实现文件双向同步

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://hx100.blog.51cto.com/44326/612301 一.Uniso ...

  3. Linux下实现文件双向同步

    修改的地方时:私钥和公约处. 其次 vi /root/.unison/default.prf 这个文件在这个位置 root = /tmp/test root = ssh://root@10.10.3. ...

  4. BitTorrent Sync 基于BT的文件同步

    BitTorrent Sync 神奇的文件同步软件,无需服务器让多台电脑间无限制互相同步!   BitTorrent Labs 推出的实验性项目,可以在多台电脑间进行点对点自动分享/同步文件,由于没有 ...

  5. 在 Linux 上安装配置 BitTorrent Sync [转]

    背景介绍:目前我们线上的前端服务器数量比较多,超过200多台,每次发布新应用的时候,都是将软件包放在一台专门的Push服务器上,再由所有的前端服务器通过rsync自动同步.但随着前端服务器的数量越来越 ...

  6. unison + inotify 实现文件实时双向同步部署步骤

    unison + inotify 实现文件实时双向同步部署步骤 一. Unison简介 Unison是Windows.Linux以及其他Unix平台下都可以使用的文件同步工具,它能使两个文件夹(本地或 ...

  7. 两种常用文件分享方式 - 网络硬盘快速分享, 点对点的文件共享 BitTorrent Sync

    普通的用户经常通过电子邮件.QQ传递等方式进行文件的分享,但是由于不同的网络环境有的时候可能会有不同的限制,所以我们就需要寻找其他的方式来替代.今天就为大家推荐两个既常用又与众不同的分享方式. 中国论 ...

  8. unison+inotify实现文件双向自动同步

    nfs适合存小图片和小文件,有一个致命的缺点,就是其中一台web服务挂掉之后,会直接导致web页面无法访问,动态的那种数据, 而且数据量很大的数据不适合nfs Unison是一款跨平台(window, ...

  9. 文件夹同步/备份软件推荐 (SyncToy/FreeFileSync/Compare Advance/GoodSync/Allway Sync/Compare Advance)

    关于文件同步的文章,已经很多次出现在异次元上了,因为它们很多都能实实在在提高工作便利性.比方说有我们熟悉的云端同步软件 Dropbox.金山快盘,以及曾经还介绍过可本地使用的 Allway Sync  ...

随机推荐

  1. System.Web.Optimization找不到引用

    在程序包管理控制程序中录入:Install-Package Microsoft.AspNet.Web.Optimization,安装即可.

  2. CAP Confusion: Problems with ‘partition tolerance’

    by Henry Robinson, April 26, 2010 The 'CAP' theorem is a hot topic in the design of distributed data ...

  3. hduacm 5104

    http://acm.hdu.edu.cn/show #include <cstdio> #include <cstring> #include <algorithm&g ...

  4. jquery删除原事件

    $(document).ready(function(){ var fn = $("#exportCsv").attr( "onclick" ); // 获取原 ...

  5. 知名杀毒软件Mcafee(麦咖啡)个人版 资源汇总兼科普(来自卡饭)

    虽然早已不是用咖啡了,但我也实时关注的咖啡的一举一动,潜水看帖日久,发现小白众多,好多有价值的帖子淹没于帖海当中,甚是惋惜.     我有如下建议      1.咖啡区管理层,能否吧一些优秀的资源教程 ...

  6. CNAPS Code 查询(招商银行)

    招商银行的妹子实在太傻了,根本不知道什么是CNAPS Code.联行号,完全答非所问. 最后还是自己搞定了,如图: 最后再看看招行人员的英语水平,真是不知道什么是东西:

  7. STL 自学

    STL 一.vector动态数组 1 包含头函数 #include<vector> 2 函数的声明: vector<int> v; vector<int> v[ma ...

  8. JS获取上传文件的名称、格式、大小

    <input id="File1" type="file" onchange="checkFile(this)" /> 方式一) ...

  9. springMVC文件上传(转)

    原文链接: http://www.cnblogs.com/lonecloud/p/5989905.html 在Spring-mvc.xml注入bean 1 <!-- 配置文件上传,如果没有使用文 ...

  10. Hadoop 重启各个节点

    对于datanode可以在master中配置,然后在maste启动的时候,一并去启动这些节点 .对于死掉的节点,也可以通过以下命令启动 .重启挂掉的节点进入到 挂掉的机器 bin/hadoop-dae ...