以前一直在用Transmission,但有两个缺点,显得不太方便。
- 不能自动切换bt和pt,bt种子要开启dht,pt种子要手动关闭dht,不能同时下载bt和pt,不够智能。
- 上传速度太慢,连接性不强,保种可以,上传基本没速度。
换用qBittorrent,也是基于以上的考虑。
- 首先,qBittorrent自动切换pt和bt,二者可以同时进行。
- 其次,连接性非常强,上传速度非常快(这有个坑下边说)。
换了qBittorrent后,好几个pt站都养活了,美滋滋了好久。
安装qBittorrent
qBittorrent安装命令很简单
$sudo add-apt-repository -y ppa:qbittorrent-team/qbittorrent-stable
$sudo apt-get update && sudo apt-get install -y qbittorrent-nox
$sudo adduser qbtuser
安装完成先别急着运行,这里贴一些管理脚本
管理服务
$vim /etc/systemd/system/qbittorrent@.service
[Unit]
Description=qBittorrent Daemon Service
After=network.target
[Service]
#UMask=000
Type=forking
User=%I
LimitNOFILE=infinity
ExecStart=/usr/bin/qbittorrent-nox -d
#ExecStop=/usr/bin/killall -w -s 9 /usr/bin/qbittorrent-nox
Restart=on-failure
TimeoutSec=300
[Install]
WantedBy=multi-user.target
管理脚本
$vim /usr/local/bin/qb
#!/bin/bash
#
# https://github.com/Aniverse/inexistence
# Author: Aniverse
#
script_update=2019.07.10
script_version=r10002
################################################################################################
action=$1
iUser=$2
DefaultUser=$(cat /log/inexistence/iUser.txt 2>/dev/null | head -1)
[[ -z $DefaultUser ]] && DefaultUserDisplay="Error: No default user found" || DefaultUserDisplay="Default user: $DefaultUser"
[[ -z $iUser ]] && iUser=$DefaultUser
id -u "$iUser" >/dev/null 2>&1 || { echo -e "No invalid user input" ; exit 1 ; }
################################################################################################
[[ $iUser == root ]] && iHome=/root
[[ $iUser != root ]] && iHome=/home/$iUser
app=qBittorrent
app_systemd=qbittorrent
app_command=qbittorrent-nox
app_config=$iHome/.config/qBittorrent/qBittorrent.conf
app_log=$iHome/.config/qBittorrent/qbittorrent.log
################################################################################################
show_usage() {
echo -e "Usage: qb [action] [username]
Action:
a Start $app
b Stop $app
c Check $app status
l View ${app}'s log
r Restart $app
s Edit ${app}'s configuration file
x Enable ${app}'s auto-start after reboot
y Disable ${app}'s auto-start after reboot
$DefaultUserDisplay
"
exit 0
}
[[ -z $action ]] && show_usage
case $action in
a ) systemctl start $app_systemd@$iUser ;;
b ) systemctl stop $app_systemd@$iUser ;;
c ) systemctl status $app_systemd@$iUser ;;
r ) systemctl restart $app_systemd@$iUser ;;
x ) systemctl enable $app_systemd@$iUser ;;
y ) systemctl disable $app_systemd@$iUser ;;
l ) tail -300 $app_log ;;
s ) nano +40 $app_config ;;
* ) echo -e "ERROR: Unknown action" ; show_usage ;;
esac
再贴个配置
$mkdir -p /home/qbtuser/.config/qBittorrent/
$vim /home/qbtuser/.config/qBittorrent/qBittorrent.conf
[AutoRun]
enabled=false
program=
[BitTorrent]
Session\AsyncIOThreadsCount=8
Session\CheckingMemUsageSize=64
Session\DisableAutoTMMByDefault=false
Session\DisableAutoTMMTriggers\CategoryChanged=false
Session\DisableAutoTMMTriggers\CategorySavePathChanged=false
Session\DisableAutoTMMTriggers\DefaultSavePathChanged=false
[Preferences]
Advanced\AnnounceToAllTrackers=true
Advanced\RecheckOnCompletion=false
Advanced\trackerPort=9000
Bittorrent\AddTrackers=true
Bittorrent\MaxConnecs=99999
Bittorrent\MaxConnecsPerTorrent=99999
Bittorrent\MaxUploads=99999
Bittorrent\MaxUploadsPerTorrent=99999
Bittorrent\TrackersList=udp://tracker.coppersurfer.tk:6969/announce\n\nudp://tracker.leechers-paradise.org:6969/announce\n\nudp://tracker.opentrackr.org:1337/announce\n\nudp://tracker.internetwarriors.net:1337/announce\n\nudp://p4p.arenabg.com:1337/announce\n\nudp://9.rarbg.to:2710/announce\n\nudp://9.rarbg.me:2710/announce\n\nudp://tracker.openbittorrent.com:80/announce\n\nudp://exodus.desync.com:6969/announce\n\nudp://tracker.tiny-vps.com:6969/announce\n\nudp://retracker.lanta-net.ru:2710/announce\n\nudp://open.stealth.si:80/announce\n\nudp://tracker.torrent.eu.org:451/announce\n\nudp://tracker.moeking.me:6969/announce\n\nudp://tracker.cyberia.is:6969/announce\n\nudp://open.demonii.si:1337/announce\n\nudp://denis.stalker.upeer.me:6969/announce\n\nudp://ipv4.tracker.harry.lu:80/announce\n\nudp://explodie.org:6969/announce\n\nhttp://explodie.org:6969/announce\n\nudp://zephir.monocul.us:6969/announce\n\nudp://xxxtor.com:2710/announce\n\nudp://valakas.rollo.dnsabr.com:2710/announce\n\nudp://tracker3.itzmx.com:6961/announce\n\nudp://tracker.zum.bi:6969/announce\n\nudp://tracker.zerobytes.xyz:1337/announce\n\nudp://tracker.yoshi210.com:6969/announce\n\nudp://tracker.uw0.xyz:6969/announce\n\nudp://tracker.sbsub.com:2710/announce\n\nudp://tracker.nyaa.uk:6969/announce\n\nudp://tracker.lelux.fi:6969/announce\n\nudp://tracker.iamhansen.xyz:2000/announce\n\nudp://tracker.filemail.com:6969/announce\n\nudp://tracker-udp.gbitt.info:80/announce\n\nudp://retracker.netbynet.ru:2710/announce\n\nudp://retracker.akado-ural.ru:80/announce\n\nudp://opentracker.i2p.rocks:6969/announce\n\nudp://opentor.org:2710/announce\n\nudp://open.nyap2p.com:6969/announce\n\nudp://chihaya.toss.li:9696/announce\n\nudp://bt2.archive.org:6969/announce\n\nudp://bt1.archive.org:6969/announce\n\nhttps://tracker.nanoha.org:443/announce\n\nhttp://www.proxmox.com:6969/announce\n\nhttp://tracker.torrentyorg.pl:80/announce\n\nhttp://tracker.opentrackr.org:1337/announce\n\nhttp://tracker.bt4g.com:2095/announce\n\nhttp://open.acgnxtracker.com:80/announce\n\nhttp://h4.trakx.nibba.trade:80/announce\n\nudp://tracker4.itzmx.com:2710/announce\n\nudp://tracker2.itzmx.com:6961/announce\n\nudp://tracker.nextrp.ru:6969/announce\n\nudp://tr.bangumi.moe:6969/announce\n\nudp://retracker.sevstar.net:2710/announce\n\nudp://qg.lorzl.gq:2710/announce\n\nudp://bt2.54new.com:8080/announce\n\nudp://bt.okmp3.ru:2710/announce\n\nhttps://tracker.parrotlinux.org:443/announce\n\nhttps://tracker.opentracker.se:443/announce\n\nhttps://tracker.lelux.fi:443/announce\n\nhttps://tracker.gbitt.info:443/announce\n\nhttp://www.loushao.net:8080/announce\n\nhttp://vps02.net.orel.ru:80/announce\n\nhttp://tracker4.itzmx.com:2710/announce\n\nhttp://tracker3.itzmx.com:6961/announce\n\nhttp://tracker2.itzmx.com:6961/announce\n\nhttp://tracker1.itzmx.com:8080/announce\n\nhttp://tracker01.loveapp.com:6789/announce\n\nhttp://tracker.zerobytes.xyz:1337/announce\n\nhttp://tracker.yoshi210.com:6969/announce\n\nhttp://tracker.nyap2p.com:8080/announce\n\nhttp://tracker.lelux.fi:80/announce\n\nhttp://tracker.internetwarriors.net:1337/announce\n\nhttp://tracker.gbitt.info:80/announce\n\nhttp://tracker.bz:80/announce\n\nhttp://retracker.sevstar.net:2710/announce\n\nhttp://opentracker.i2p.rocks:6969/announce\n\nhttp://mail2.zelenaya.net:80/announce
Connection\GlobalDLLimitAlt=0
Connection\GlobalUPLimitAlt=2500
Connection\PortRangeMin=65303
Connection\ResolvePeerCountries=true
Connection\alt_speeds_on=true
Downloads\DiskWriteCacheSize=64
Downloads\PreAllocation=true
Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\0)
Downloads\TempPathEnabled=true
DynDNS\DomainName=changeme.dyndns.org
DynDNS\Enabled=false
DynDNS\Password=
DynDNS\Service=0
DynDNS\Username=
General\Locale=zh
MailNotification\email=
MailNotification\enabled=false
MailNotification\password=
MailNotification\req_auth=true
MailNotification\req_ssl=false
MailNotification\sender=qBittorrent_notification@example.com
MailNotification\smtp_server=smtp.changeme.com
MailNotification\username=
Queueing\MaxActiveDownloads=99999
Queueing\MaxActiveTorrents=99999
Queueing\MaxActiveUploads=99999
WebUI\Address=0.0.0.0
WebUI\AlternativeUIEnabled=false
WebUI\AuthSubnetWhitelist=@Invalid()
WebUI\AuthSubnetWhitelistEnabled=false
WebUI\CSRFProtection=true
WebUI\ClickjackingProtection=true
WebUI\HTTPS\CertificatePath=/home/qbtuser/WebUICertificate.crt#请填入自己的证书,位置不变
WebUI\HTTPS\KeyPath=/home/qbtuser/WebUIPrivateKey.pem#请填入自己的证书,位置不变
WebUI\HostHeaderValidation=true
WebUI\LocalHostAuth=true
WebUI\Port=8181
WebUI\RootFolder=
WebUI\ServerDomains=*
WebUI\SessionTimeout=3600
WebUI\UseUPnP=true
WebUI\Username=admin
修改权限并载入服务
$systemctl daemon-reload
$chmod 755 /usr/local/bin/qb
$chmod -R 777 /home/qbtuser
$sudo usermod -s /usr/sbin/nologin qbtuser#安全起见禁止qbtuser登陆
$qb x qbtuser#qbittorrent开机自启
$qb a qbtuser#开启qbittorrent
#快捷命令
Usage: qb [action] [username]
Action:
a #动作是启动qBittorrent
b #动作是停止qBittorrent
c #动作是查看状态qBittorrent status
l #动作是查看日志qBittorrent's log
r #动作是重启qBittorrent
s #动作是编辑qBittorrent's 配置
x #动作是允许qBittorrent's开机启动
y #动作是不允许qBittorrent's 开机启动
启动后,访问ip:8181 账号是admin,密码是adminadmin
给qBittorrent添加geoip数据库
$mkdir -p /home/qbtuser/.local/share/data/qBittorrent/GeoIP
qbittorrent的geoip数据库只能从 maxmind,下载mmdb格式的国家数据库,其他的ip数据库网站比如:www.ip2location.com、db-ip.com等的数据库,都不能正常识别。maxmind的GeoLite2Country数据库是免费的,注册一下便可以使用。
将tgz格式的数据库解压后,上传到文件夹
/home/qbtuser/.local/share/data/qBittorrent/GeoIP
然后,打开qBittorrent设置中的解析用户ip地址
接着重启qBittorrent:
$qb r qbtuser
数据库生效后,便可以在用户一栏看到国旗了
qBittorrent订阅种子
安装flexget
$apt-get install python-pip
$pip install --upgrade pyopenssl
$pip install --upgrade cryptography
$pip install flexget
$mkdir -p /root/.config/flexge
vim /root/.config/flexge/config.yml#建一个配置文件
tasks:
Web-BTSchool:
rss: http://pt.btschool.club/torrentrss.php........
accept_all: yes
seen:
fields:
- url
download: /home/torrent
Web-HDhome:
rss: http://hdhome.org/torrentrss.php......
accept_all: yes
seen:
fields:
- url
download: /home/torrent
web_server:
bind: 0.0.0.0
port: 445
web_ui: yes
# This is prepared for reverse proxy, do not uncomment it unless you know how it works
# base_url: /flexget
# schedules is disabled by default, you need to enable it or use cron to RSS
schedules:
- tasks: '*'
interval:
minutes: 1
更多实例和方法请参考官网
设置flexget webui密码
flexget web passwd deyigebush23 #密码要设置复杂些
写个开机启动服务
vim /etc/systemd/system/flexget.service
[Unit]
Description=flexget Daemon
After=network.target
[Service]
User=root
UMask=000
ExecStart=/usr/local/bin/flexget daemon start
ExecStartPre=/bin/rm -f /root/.config/flexget/.config-lock
ExecStop=/usr/local/bin/flexget daemon stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
$systemctl daemon-reload
$systemctl enable /etc/systemd/system/flexget.service
$systemctl start flexget
然后就可以输入密码访问ip:445了
qBittorrent的设置是
说一下qBittorrent的坑
首先qbittorrent速度快的话,需要设置一下
总是向同级的所有Tracker汇报,这选上,选上后连接性变强。
然而坑的地方就在这里,连接性变强,速度变快,你的电脑内存跟不上。同时添加多个种子的时候,我的10Gb内存经常爆炸。
增加内存可以解决问题,增加swap可以缓解一下,更改系统进程打开数可以优化一下。
增加swap
$grep SwapTotal /proc/meminfo#查看swap分区大小
$swapoff /swap.img#停掉挂载的swap分区
$dd if=/dev/zero of=/swap.img count=10 bs=1G
#以G为单位增加点swap,4G内存一下建议设为两倍与真实内存,4G以上建议设置等大小
$mkswap /swap.img
#格式化
$swapon /swap.img
#激活分区
$echo "/swap.img swap swap defaults 0 0" >>/etc/fstab
#开机挂载swap
#也可以直接安装动态swap软件
$sudo apt install swapspace
更改打开文件数限制
vim /etc/security/limits.conf
添加一下内容
* soft nofile 100001
* hard nofile 100002
root soft nofile 100001
root hard nofile 100002
inmgr soft nproc 65535
inmgr hard nproc 65535
inmgr soft nofile 60000
inmgr hard nofile 65535
然后重启一下ssh就可以了
这一切当然是值得的

限速2.5m/s的情况下,半个多月的上传量是4Tb多,肯定可以呀。