Installing the configuration BitTorrent Sync on Linux

Source: Internet
Author: User
Tags btsync

Background introduction:
At present, we have more than 200 front-end servers online, each time we release new applications, we put the packages on a dedicated push server, and all the front-end servers are automatically synced through rsync. But with the number of front-end servers increasing, the bandwidth of the push server has become a bottleneck.

The BitTorrent sync is a solution. At the same time, its cross-platform support is also very good, whether it is the Windows,linux,mac OS, or even the mobile phone side has the corresponding client. Although not currently open source, but can be used free of charge, or very good.

Below is the installation and configuration steps in our pure Linux test environment on-line:

Servers:
Master:idc2-server1
Slave:idc2-server2, Idc2-server3

  1. Download BitTorrent Sync, on all servers
    $ sudo wget http://download-lb.utorrent.com/endpoint/btsync/os/linux-x64/track/stable-O/tmp/btsync_x64.tar.gz
    $ sudo mkdir/opt/btsync
    $ cd/opt/btsync
    $ sudo tar xzf/tmp/btsync_x64.tar.gz

  2. Create a service management script on all servers
    $ sudo vim/etc/init.d/btsync

    #!/bin/SH# # Description:starts and stops the Btsync clientconf=/opt/btsync/Btsync.cfgproc=/opt/btsync/Btsyncpidfile=/opt/btsync/Btsync.pidstart () {PID1=$(pidofBtsync)if[-Z ${PID1}]; Then    Echo-N"starting BitTorrent Sync:"${proc}--Config ${conf}Else    Echo "BitTorrent Sync is already running at PID:${PID1}"  fireturn $?} stop () {Echo-N"stopping BitTorrent Sync:"PID1=$(pidofBtsync)if[!-Z ${PID1}]; Then    Kill-9${PID1}Echo "OK"  Else    Echo "Failed"  fireturn $?} status () {PID1=$(pidofBtsync) PID2=$(Cat${pidfile})Echo-N"Checking BitTorrent Sync:"  if[!-Z ${PID1}] && ["${PID1}"-eq"${pid2}"]; Then    Echo "OK"  Else    Echo "Failed"  fireturn $?}   Case " $" inchstart) Start;  stop) stop;; Restart) StopSleep 1start;;  status) status; *)    Echo$"Usage: $ {start|stop|restart|status}"Exit2Esac
    Btsync Code

    sudo chmod +x/etc/init.d/btsync

  3. Create a directory for synchronization on all servers
    sudo mkdir/opt/btsync_transfer

  4. Create a configuration file on Idc2-server1
    sudo vim/opt/btsync/btsync.conf

     {   "device_name":"Idc2-server1",  "Listening_port":8889,//0-randomize Port  "check_for_updates":false,  "Use_upnp":false,  "Storage_path":"/opt/btsync",  "Pid_file":"/opt/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": -,  "Lan_encrypt_data":false,  "lan_use_tcp":true}
    btsync.conf Code
  5. Create the keys required for synchronization on Idc2-server1
    Sudo/etc/init.d/btsync start
    Open Web ui:http://idc2-server1:8888
    User name: admin
    Password: btsync

    Click "Add Folder",
    Enter "/opt/btsync_transfer" in "Path"
    Click "Generate" to get "Secret" as "Aluorwdewolv354zhphft4tsqo67jwqan"
    As shown in the following:

  6. Create a configuration file on Idc2-server2 and Idc2-server3:
    sudo vim btsync.cfg

    {#定义设备名称, general write hostname or IP"device_name":"Idc2-server2", #是使用随机端口还是固定端口, 0 means random"Listening_port":8889,//0-randomize Port#是否检查文件更新"check_for_updates":false, #使用UPnP进行端口映射"Use_upnp":false, #storage_path包含一些运行时产生的状态文件, if not defined, produces a. sync hidden directory in the directory where the binary command runs"Storage_path":"/opt/btsync", #定义pid文件的路径"Pid_file":"/opt/btsync/btsync.pid", #是否对上传/download for speed limit, 0 means unlimited speed"Download_limit":0,//0-no Limit  "Upload_limit":0,   "WebUI": {#如果去掉listen项, disables Web UI"Listen":"0.0.0.0:8888",     "Login":"Admin", #如果去掉login/password, it means no validation"Password":"Btsync"}, #如果你在配置文件中设置了shared folders, the Web UI is blocked, and the configuration file overrides the settings in the UI. "shared_folders": [{#你的secret, you can use--generate-Secret parameter Generation"Secret":"Aluorwdewolv354zhphft4tsqo67jwqan",//* Required Field#同步的目录"dir":"/opt/btsync_transfer",//* Required Field#是否自动删除文件"Use_sync_trash":false, #是否使用中继服务器"Use_relay_server":true, #是否使用tracker服务器"Use_tracker":true,      "Search_lan":true, #设置不用查找就可以直接连接的机器"known_hosts" :       [        "idc2-server1:8889"      ]     }   ]   ,  "Folder_rescan_interval": -,  "Lan_encrypt_data":false,//encryption is very painful in terms of speed. Disabling it for LAN-increase the speed.   "lan_use_tcp":true}
    btsync.cfg Code

    Sudo/etc/init.d/btsync start
    Idc2-server3 with Idc2-server2 settings, just change the IP, host name can be

  7. You can view the status of the synchronization by placing some files in the/opt/btsync_transfer
    Open Web ui:http://idc2-server1:8888
    #将示例配置文件保存到当前目录下:
    ./btsync–dump-sample-config > sync.conf
    #启动btsync服务
    ./btsync–config sync.conf

  8. Precautions
    If you choose Read-only synchronization (server-local), if you do not want to synchronize after the file transfer, remember to delete the synchronized directory on the local client, otherwise the server side deleted the file, the local will automatically delete the file. Of course, read-write synchronization is more so.

    Resources:

    Http://heylinux.com/archives/2917.html

    http://my.oschina.net/guol/blog/202002

Installing the configuration BitTorrent Sync on Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.