路由器離線BT新寵Aria2:實測比Transmission快很多

在之前的一篇文章討論過利用Transmission這個Openware套件在Openwrt/DD-wrt的路由器上實現路由器BT而不需要開啓電腦。本文爲大家推薦一個更好的套件:Aria2,他比Transmission更好的地方有:

  • Aria2支持的下載種類更多,包括磁力鏈接(MagnetLink)和一些類似PT的source源
  • 界面更加先進aria2webgui
  • 感覺Aria2設置比Transmission更加簡單(貌似不需要端口映射之類的設置)
  • 最重要的是:Aria2下載速度更快!

而本文將与大家一起爲路由器安裝上Aria2!

1、安裝Aria2

套件名稱就aria2,不熟悉安裝方法的話請參考詳細安裝步驟

然後需要安裝Aria2的網頁管理套件,先到這裡下載:https://github.com/ziahamza/webui-aria2

然後解壓縮到路由器的/www/aria2裡面,現在可以輸入192.168.1.1/aria2看看是否能開啓管理頁面,注意這時候是一定會出現錯誤的,因為aria還沒有啓動服務。

 

2、啓動和測試

aria2 webgui啓動命令是:

aria2c –enable-rpc –rpc-listen-all=true –rpc-allow-origin-all -c

啓動完了會顯示6800端口正在監聽,這時候打開192.168.1.1/aria2,看看紅色的錯誤提示是否消失,如果消失就OK了。

理論上現在已經能使用了,但是下面兩部能大大提高aria2的效率

 

3、建立aria2配置文件

aria2默認是沒有保存設定的功能的,重啓路由就會消失,所以建立配置文件比較重要。你總不想每次下載都要設置路徑調整參數吧。

首先建立一個文件aria2.conf,哪裡建立都行,我是放在/etc/aria2/

文件內容如下:

#允许rpc
enable-rpc=true
#允许所有来源, web界面跨域权限需要
rpc-allow-origin-all=true
#允许非外部访问
rpc-listen-all=true
#RPC端口, 仅当默认端口被占用时修改
#rpc-listen-port=6800

#文件保存路径, 默认为当前启动位置
dir=/mnt/sda7/bt
#文件缓存, 使用内置的文件缓存, 如果你不相信Linux内核文件缓存和磁盘内置缓存时使用, 需要1.16及以上版本
#disk-cache=0
#另一种Linux文件缓存方式, 使用前确保您使用的内核支持此选项, 需要1.15及以上版本(?)
#enable-mmap=true
#文件预分配, 能有效降低文件碎片, 提高磁盘性能. 缺点是预分配时间较长
#所需时间 none < falloc ? trunc << prealloc, falloc和trunc需要文件系统和内核支持
file-allocation=prealloc
#启用本地节点查找
bt-enable-lpd=true
#添加额外的tracker
#bt-tracker=<URI>,…
#单种子最大连接数
#bt-max-peers=55
#强制加密, 防迅雷必备
#bt-require-crypto=true
#当下载的文件是一个种子(以.torrent结尾)时, 自动下载BT
follow-torrent=true
#BT监听端口, 当端口屏蔽时使用
#listen-port=6881-6999

我是參考下面兩個網頁修改的,謝謝!

http://blog.binux.me/2012/06/aria2_yaaw/

http://blog.binux.me/2012/12/aria2-examples/

 

然後在startup裡面加入:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

aria2c –conf-path=/etc/aria2/aria2.conf -D

exit 0

這樣就自動啓動了。

 

4、設置SWAP分區

Openwrt的WIKI裡面說,設置swap對BT速度很大幫助。我們也要一個SWAP!

首先建立一個固定大小的空文件,這裡是512M:

dd if=/dev/zero of=/mnt/sda7/swapfile bs=1024 count=524288

然後mkswap /mnt/sda7/swapfile 把空文件格式化成swap

最后swapon /mnt/sda7/swapfile 掛載swap分區

我在startup script裡面加上了swapon /mnt/sda7/swapfile 令每次啓動都會自動掛載。詳情可以參考:

http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

最后附上一張截圖,速度還不錯吧,這是沒有優化過連接數的performance:

aria2

 

剩下一筆買NAS的錢,呵呵~~

我使用的是BUFFALO WZR-300HP(WZR-HP-G300NH2的新版)路由器,如果你還未買路由器,可參考這篇文章,如果打算買Atheros芯片路由請看這篇

 

最后,Upsangel爲大家奉上玩轉路由器附加強大功能的攻略(架設vpn server,共享printer,scanner, 離線BT等),請參考小弟在hkepc的得獎文章:OpenWRT, DD-WRT資源彙總索引 – http://www.hkepc.com/forum/viewthread.php?tid=2025967&extra=page%3D1

6 Comments
  1. Should the command to start aria2 webgui actually be “aria2c –enable-rpc –rpc-listen-all=true –rpc-allow-origin-all -c” ??

    • seems this website convert the double dash into a long dash automatically… yes….
      you may treat daemon as the silent background running mode of the aria2c. If you don’t run it in daemon, you need a live command terminal to keep the aria2c process alive, once you exit the terminal, the webgui cannot work. webgui depends on the aria2c process.

  2. seems this website convert the double dash into a long dash automatically…

    Besides, I received error “IPv6 RPC: failed to bind port 6800” when running the above command.

    Should it add the “daemon” option as well?

    Thanks

  3. 请注意,aria2c命令后的参数是–,而不是单独的一个-

    • 首先感谢这篇教程.用过这篇教程后,始终有问题,最后发觉是命令参数”–“的问题.
      提请注意,教程的命令最好使用命令编码显示,不然命令符显示错误,困扰很大.

你可以一針見血

by Upsangel
Logo