transmission是下载BT的比较好的软件

在idc机房大规模分发kvm qcow2虚机镜像文件的时候,如果采用BT的方式,速度将是异常的快啊。

aria2比transmission好的地方就是支持磁力链,两种工具各有所长。

首先说说transmission,如果是机房装,只装一个transmission-cli就足够了。如果要图形,就需要装transmission-daemon。

安装epel源,然后安装:

rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm  
yum install transmission-daemon transmission-cli  

编辑transmission-daemon的配置:

mkdir -p /var/lib/transmission/.config/transmission  
vi /var/lib/transmission/.config/transmission/settings.json  

内容如下:

{
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": false,
    "blocklist-url": "http://www.example.com/blocklist",
    "cache-size-mb": 4,
    "dht-enabled": true,
    "download-dir": "/data/film",
    "download-queue-enabled": true,
    "download-queue-size": 5,
    "encryption": 1,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/data/film/Torrent",
    "incomplete-dir-enabled": false,
    "lpd-enabled": false,
    "message-level": 2,
    "peer-congestion-algorithm": "",
    "peer-id-ttl-hours": 6,
    "peer-limit-global": 200,
    "peer-limit-per-torrent": 50,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": "default",
    "pex-enabled": true,
    "port-forwarding-enabled": true,
    "preallocation": 1,
    "prefetch-enabled": 1,
    "queue-stalled-enabled": true,
    "queue-stalled-minutes": 30,
    "ratio-limit": 2,
    "ratio-limit-enabled": false,
    "rename-partial-files": true,
    "rpc-authentication-required": false,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "xxxxxxxx",
    "rpc-port": 9091,
    "rpc-url": "/transmission/",
    "rpc-username": "admin",
    "rpc-whitelist": "127.0.0.1,192.168.89.184,192.168.89.180,192.168.89.238,192.168.89.217",
    "rpc-whitelist-enabled": true,
    "scrape-paused-torrents-enabled": true,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "seed-queue-enabled": false,
    "seed-queue-size": 10,
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "start-added-torrents": true,
    "trash-original-torrent-files": false,
    "umask": 0,
    "upload-slots-per-torrent": 14,
    "utp-enabled": true
}

注意几个地方, 密码、端口、用户、把自己机器的ip加入白名单

"rpc-password": "xxxxxxxx",
"rpc-port": 9091,
"rpc-username": "admin",
"rpc-whitelist": "127.0.0.1,192.168.89.184,192.168.89.180,192.168.89.238,192.168.89.217",
"rpc-whitelist-enabled": true,

按需配即可。

修改transmission-daemon的界面,换成kettu:

wget wget https://codeload.github.com/endor/kettu/zip/master  
unzip -x master -d /usr/share/transmission/  
mv /usr/share/transmission/web  /usr/share/transmission/web-bak  
mv /usr/share/transmission/kettu-master /usr/share/transmission/web  

启动:

service transmission-daemon start  

然后打开http://xxx.xxx.xxx.xxx:9091/就可以看到了

ok, transmission就完工了。

下面说说aria2:

安装:

yum install aria2.x86_64  
mkdir /etc/aria2  
touch /etc/aria2/aria2.conf  
touch /etc/aria2/session.lock  
touch /var/log/aria2.log &&chown nobody:nobody /var/log/aria2.log  
chown nobody:nobody /etc/aria2 -R  

查看一下版本号,版本不同认证不同:

aria2c --version  
aria2 version 1.16.4  

另种认证方式,只能二选一:

  • 密码验证(1.15.2以上,1.18.6以下版本)
  • token验证(1.18.4以上版本)

我们的版本是1.16.4,用密码认证:

vi /etc/aria2/aria2.conf  
daemon=true  
continue=true  
enable-rpc  
rpc-allow-origin-all=true  
rpc-listen-all=true  
#用以下命令生成token,openssl rand -hex 15
#rpc-secret=616d343b1465b51ca65675b2bfef98
rpc-user=admin  
rpc-passwd=xxxxxxxx

dir=/home/store/Download  
save-session=/etc/aria2/session.lock  
input-file=/etc/aria2/session.lock  
dht-file-path=/etc/aria2/dht.dat  
disable-ipv6=true  
log-level=warn  

启动:

/usr/bin/aria2c --conf-path=/etc/aria2/aria2.conf --log=/var/log/aria2.log

安装aira2-webui

wget https://codeload.github.com/ziahamza/webui-aria2/zip/master -O webui-aria2.zip &&unzip webui-aria2.zip -d /home/www/ &&mv /home/www/webui-aria2-master /home/www/webui-aria2 &&chown nobody:nobody /home/www/webui-aria2 -R  
vi /home/www/webui-aria2/configuration.js  

configuration.js

angular  
.module('webui.services.configuration',  [])
.constant('$name', 'Aria2 WebUI')  // name used across the entire UI
.constant('$titlePattern', 'active: {active} - waiting: {waiting} - stopped: {stopped} — {name}')
.constant('$pageSize', 11)         // number of downloads shown before pagination kicks in
.constant('$authconf', {           // default authentication configuration, never fill it in case the webui is hosted in public IP as it can be compromised
  host: '192.168.2.1',
  path: '/jsonrpc',
  port: 6800,
  encrypt: false,
  auth: {                          // either add the token field or the user and pass field, not both.
  /* token: '616d343b1465b51ca65675b2bfef98' */
  /*-----------------------------*/
  user: 'admin',
  pass: 'xxxxxxxx'
  },
  directURL: ''                   // If supplied, links will be created to enable direct download from the aria2 server, requires appropriate webserver to be configured
})
.constant('$enable', {

  torrent: true,  // bittorrent support only enabled if supported by aria2 build, set to false otherwise to permanently disable it

  metalink: true, // metalink support only enabled if supported by aria2 build, set to false to permanently disable it

  sidebar: {            // configuration related to the sidebar next to the list of downloads
    show: true,         // set to false to completely hide the sidebar. Other elements inside will be automatically hidden

    stats: true,        // set to false to hide the global statistic section (contains the speed graph for now)

    filters: true,      // set to false to hide the  Download Filters

    starredProps: true // only shown when at least one property is added to the starred list, set to false to permanently hide the Quick Access Settings inside the sidebar
  }
})
.constant('$starredProps', [   // default list of Quick Access Properties. Can be overridden by making modification through the Global Settings dialog
  // go to Global Settings dialog to see their description
  'dir', 'conf-path', 'auto-file-renaming', 'max-connection-per-server'
])
.constant('$downloadProps', [ // Similar to starred Quick Access properties but for adding new downloads.
  // go to Advance Download Options when adding a new download to view the list of possible options
  'http-user', 'http-passwd', 'pause', 'dir', 'max-connection-per-server'
])
.constant('$globalTimeout', 1000)  // interval to update the individual downloads
;

生成启动文件:

vi /usr/local/bin/aria2-webui  

aria2-webui

#!/usr/bin/env python

import os  
import posixpath  
import urllib  
import BaseHTTPServer  
from SimpleHTTPServer import SimpleHTTPRequestHandler

# modify this to add additional routes
ROUTES = (  
##  [url_prefix ,  directory_path]
    ['',       '/home/www/webui-aria2'],  # empty string for the 'default' match
#   ['/media', '/var/www/media']
)

class RequestHandler(SimpleHTTPRequestHandler):

    def translate_path(self, path):
        """translate path given routes"""

        # set default root to cwd
        root = os.getcwd()

        # look up routes and set root directory accordingly
        for pattern, rootdir in ROUTES:
            if path.startswith(pattern):
                # found match!
                path = path[len(pattern):]  # consume path up to pattern len
                root = rootdir
                break

        # normalize path and prepend root directory
        path = path.split('?',1)[0]
        path = path.split('#',1)[0]
        path = posixpath.normpath(urllib.unquote(path))
        words = path.split('/')
        words = filter(None, words)

        path = root
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            if word in (os.curdir, os.pardir):
                continue
            path = os.path.join(path, word)

        return path

if __name__ == '__main__':  
    BaseHTTPServer.test(RequestHandler, BaseHTTPServer.HTTPServer)
chmod 755 /usr/local/bin/aria2-webui  

运行:

nohup /usr/local/bin/aria-webui >/dev/null &  

打开网址:http://xxx.xxx.xxx.xxx:8000/

comments powered by Disqus