Posts Tagged ‘rtorrent’

玩转MSS(4)Rtorrent 安装

xeon Posted in 电脑杂谈,Tags: ,
0

基本上,都是抄来的,我做了些整理。

安装rtorrent 和相关软件

ipkg update

ipkg instal rtorrent

ipkg install screen

mkdir /opt/share/torrent/session

# ln -s /opt/share/torrent/
/shares/mss-hdd/Public/downloads/

备注

1:缺省的下载路径是/opt/share/torrent/,我没有修改他的路径,只是做了一个链接,由于/opt/share/torrent/
下缺少session文件夹,所以我创建一个。

配置rtorrent.conf 文件

当你装完rtorrent后,就会在/opt/etc/rtorrent.conf
,这是rtorrent的配置文件,我们需要修改这个文件,并把这个文件复制到/opt/root 目录下,并改名为.rtorrent.rc 。有一点需要注意的,在linux下修改配置文件,最好都是先做备份。

运行下面的命令

cd /

cp /opt/etc/rtorrent.conf
/opt/etc/rtorrent.conf_backup

cp /opt/etc/rtorrent.conf /opt/root/.rtorrent.rc

vi /opt/root/.rtorrent.rc

编辑.rtorrent.rc
,下面是我的配置文件的全部内容

##################################
配置文件开始
####################################

# This is an example resource file for rTorrent. Copy to

# ~/.rtorrent.rc and enable/modify the options as needed. Remember
to

# uncomment the options you wish to enable.

# 每个torrent文件允许连接的最大以及最小的peer的数目

min_peers = 40

max_peers = 250

# Same as above but for seeding completed torrents (-1 = same as
downloading)

#min_peers_seed = 10

#max_peers_seed = 50

# Maximum number of simultanious uploads per torrent.

max_uploads = 15

# 全局上传和下载速率,单位是KB. “0” 代表无限制

download_rate = 75

upload_rate = 28

# 默认下载目录,下载好的文件会放到这里

directory = /opt/downloads

# Default session directory. Make sure you don’t run multiple
instance

# of rtorrent using the same session directory. Perhaps using
a

# relative path?

session = /opt/downloads/.session

# 下面是一个非常有用的功能:监视目录

# 放在/opt/torrent目录底下的torrent文件会自动开始下载

# 配置好监视目录以后,只要通过samba或scp往这个目录传种子,就会自动开始下载

schedule =
watch_directory,5,5,load_start=/opt/torrent/*.torrent

#schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.

#schedule = low_diskspace,5,60,close_low_diskspace=100M

# Stop torrents when reaching upload ratio in percent,

# when also reaching total upload in bytes, or when

# reaching final upload ratio in percent.

# example: stop at ratio 2.0 with at least 200 MB uploaded, or else
ratio 20.0

#schedule = ratio,60,60,stop_on_ratio=200,200M,2000

# The ip address reported to the tracker.

#ip = 127.0.0.1

#ip = rakshasa.no

# The ip address the listening socket and outgoing connections
is

# bound to.

#bind = 127.0.0.1

#bind = rakshasa.no

# Port range to use for listening.

#port_range = 6890-6999

# Start opening ports at a random position within the port
range.

#port_random = no

# Check hash for finished torrents. Might be usefull until the bug
is

# fixed that causes lack of diskspace not to be properly
reported.

#check_hash = no

# 是否使用UDP trackers,建议选yes

use_udp_trackers = yes

# Alternative calls to bind and ip that should handle dynamic
ip’s.

#schedule = ip_tick,0,1800,ip=rakshasa

#schedule = bind_tick,0,1800,bind=rakshasa

# 是否允许协议加密,建议改成allow_incoming,enable_retry,prefer_plaintext的组合体,具体原因就不解释了

# allow_incoming, try_outgoing, require, require_RC4, enable_retry,
prefer_plaintext

#

# The example value allows incoming encrypted connections, starts
unencrypted

# outgoing connections but retries with encryption if they fail,
preferring

# plaintext to RC4 encryption after the encrypted handshake

#

encryption = allow_incoming,enable_retry,prefer_plaintext

#

# Do not modify the following parameters unless you know what
you’re doing.

#

# Hash read-ahead controls how many MB to request the kernel to
read

# ahead. If the value is too low the disk may not be fully
utilized,

# while if too high the kernel might not be able to keep the
read

# pages in memory thus end up trashing.

#hash_read_ahead = 10

# Interval between attempts to check the hash, in
milliseconds.

#hash_interval = 100

# Number of attempts to check the hash while using the mincore
status,

# before forcing. Overworked systems might need lower values to get
a

# decent hash checking rate.

#hash_max_tries = 10

# Max number of files to keep open simultaniously.

#max_open_files = 128

# Number of sockets to simultaneously keep open.

#max_open_sockets = <no
default>

# Example of scheduling commands: Switch between two ip’s every
5

# seconds.

#schedule = “ip_tick1,5,10,ip=torretta”

#schedule = “ip_tick2,10,10,ip=lampedusa”

# Remove a scheduled event.

#schedule_remove = “ip_tick1”

#选择utf-8可以在samba中看到中文

encoding_list = UTF-8

#rtorrent创建的文件夹(或文件)的权限,默认是0644,建议改成0000(感谢xuanwuhu),使所有用户都能访问。

#也只有这样在samba中才可以直接打开、拷贝、删除rtorrent创建的文件

umask = 0000

#下面两个选项打开dht的功能,照做即可,另外如果想让 rtorrent 在启动的时候就使用
DHT,可以把dht=auto改为dht=on

dht = auto

dht_port = 6778

#允许peer交换,当然允许了,多多益善啊

peer_exchange = yes

#最后这个参数和web配置以及远程管理有关

scgi_port = 127.0.0.1:5000

#scgi_local = /opt/var/run/rpc.socket

运行rtorrent

这个时候,你就可以在telnet到mss上运行直接运行rtorrent,不过有一点需要注意的,如果你关闭telnet的窗口,那么rtorrent也就停止了。所有你需要screen这个软件。

screen是个窗口管理器,在screen中运行的程序可以进入后台运行(进入后台后就可以关闭telnet,但是程序仍然在运行),并且可以随时调回前台,所以玩路由器或NAS的这个工具是必须要掌握的,非常有用哦!!

使用screen

在telnet中输入screen回车,将看到一大堆英文,这个时候再按一次回车,将进入一个新的screen窗口我简称之为窗口1,此时运行你想要的程序例如rtorrent,然后按Ctrl+A,D(这个代表按住Ctrl不放按A,然后松开手按D),就能使这个screen窗口1进入后台运行,这个时候即使关了telnet都是可以的,rtorrent仍然在后台运行,以后如果我想再回到窗口1,只要重新telnet连上路由,运行screen
-r即可,你就又回到了窗口1了,用类似的方法你还可以开启窗口2,窗口3等等,这里就不介绍了,如果你有兴趣可以google搜索“linux
screen 用法”

我们只要用screen将rtorrent放入后台运行,然后往监视目录中放种子文件就能完成下载,非常轻松哦,要查看状态,就telnet连上路由,然后screen
-r即可,最高效的用法!!

重启服务

重启rtorrent和lighttpd

/opt/etc/init.d/S80lighttpd stop

/opt/etc/init.d/S80lighttpd start

killall rtorrent

启动rtorrent,就要用screen来启动

rtorrent

在windows上安装rtorrent客户端管理程序

安装lighttpd

ipkg install lighttpd
第三步,修改lighttpd配置文件,使用编辑器编辑/opt/etc/lighttpd/lighttpd.conf
首先在server.modules中加入一行
server.modules              = (
#                               “mod_rewrite”,
#                               “mod_redirect”,
#                               “mod_alias”,
“mod_access”,
#                               “mod_cml”,
#                               “mod_trigger_b4_dl”,
#                               “mod_auth”,
#                               “mod_status”,
#                               “mod_setenv”,
#                               “mod_fastcgi”,
#                               “mod_proxy”,
#                               “mod_simple_vhost”,
#                               “mod_evhost”,
#                               “mod_userdir”,
#                               “mod_cgi”,
#                               “mod_compress”,
#                               “mod_ssi”,
#                               “mod_usertrack”,
#                               “mod_expire”,
#                               “mod_secdownload”,
#                               “mod_rrdtool”,
“mod_accesslog”,         <——这里加个逗号
“mod_scgi”)                <——-这是新加的一行
然后在lighttpd.conf的最后加上
scgi.server = (
“/RPC2” =>
( “127.0.0.1” =>
(
“socket” => “/opt/var/run/rpc.socket”,
“check-local” => “disable”,
“disable-time” => 0, # don’t disable scgi if connection fails
)
)
)
保存退出。

第四步,重启rtorrent和lighttpd
/opt/etc/init.d/S80lighttpd stop
/opt/etc/init.d/S80lighttpd start

killall rtorrent
rtorrent


http://ntorrent.googlecode.com/files/nTorrent-bin-0.5-beta-win.zip

现在是这个版本了。下载回来后,运行ntorrent,

(可能是我机器已经安装java运行库,没有提示需要这个。

protocol : ssh

host : MSS的IP

port : 22

mountpoint : 5000

用户名和密码需要填写,之前在玩转mss二中有讲过,

修改文件夹的权限

linux下用命令 chmod 777 目录。相关的一般就是torrent下的东西了。

备份配置文件

linux的配置,其实就是修改配置文件,把运行良好的配置文件备份下来,以后安装调试就好办多了。我的习惯是在/public/downloads/mss/config
把所有的配置文件都放在这个文件夹下。

# cp /opt/root/.rtorrent.rc
/shares/mss-hdd/Public/downloads/mss/config/backup.rtorrent.rc

# cp /opt/etc/lighttpd/lighttpd.conf
/shares/mss-hdd/Public/downloads/mss/config/backup.lighttpd.conf

# cp /opt/etc/vsftpd.user_list
/shares/mss-hdd/Public/downloads/mss/config/backup.vsftpd.user_list

# cp /opt/etc/init.d/S99local
//shares/mss-hdd/Public/downloads/mss/config/backup.S99local

要注意的问题

1:下载的路径,缺省都是指向/opt/share/torrent,
我没有修改他的路径,而且通过link的命令,做了一个链接,链接到public/downloads
目录下,我觉得这样会更加简单些。

2:rotrrent还有一个功能,你可以把bt的文件直接放到rtorrent的目录下,他就会自动下载。

update:

如果打开rtorrent出现错误如下:

rtorrent: Could not lock session directory:
“/opt/share/torrent/session/”, held by “(none):+266”.

直接进入Session中删掉Rtorrent.lock即可。

2011.8.2 update:

今天突然发现整个文件夹不见了。/opt/share/torrent/下面还在。重新用ln命令链接即可。