以前介紹過強大的BT軟體Transmission,也介紹過搭配FlexGet變身成超強BT下載機 🤖🤓🤖
可是瑞帆,年代都好久了啊 🤓 但Transmission自從2.92版本爆出漏洞後,更新速度就很緩慢,所以就想著搞一套新的來玩耍,剛好就看到了採用libtorrent-rasterbar做核心的qBittorrent,同樣自帶網頁介面,各版本支援性更高,在CentOS 6.10 (Final)、7.6.1810安裝上也順利成功運行,所以把過程做個紀錄 🤖🤓🤖
1. 安裝依賴套件
1 2 |
yum groupinstall -y "Development Tools" yum install -y qt-devel boost-devel openssl-devel qt5-qtbase-devel qt5-linguist GeoIP-update |
2. 手動鞭譯安裝libtorrent-rasterbar
1 2 3 4 5 6 7 8 |
cd /usr/src wget https://github.com/arvidn/libtorrent/releases/download/libtorrent_1_1_12/libtorrent-rasterbar-1.1.12.tar.gz tar -zxf libtorrent-rasterbar-*.tar.gz cd libtorrent-rasterbar-* ./configure --prefix=/usr CXXFLAGS=-std=c++11 make && make install ln -s /usr/lib/pkgconfig/libtorrent-rasterbar.pc /usr/lib64/pkgconfig/libtorrent-rasterbar.pc ln -s /usr/lib/libtorrent-rasterbar.so.9 /usr/lib64/libtorrent-rasterbar.so.9 |
3. 手動鞭譯安裝qBittorrent
1 2 3 4 5 6 |
cd /usr/src wget -O qBittorrent-release-3.3.16.tar.gz https://github.com/qbittorrent/qBittorrent/archive/release-3.3.16.tar.gz tar -zxf qBittorrent-release-*.tar.gz cd qBittorrent-release-* ./configure --prefix=/usr --disable-gui CPPFLAGS=-I/usr/include/qt5 make && make install |
4. 建立qBittorrent設定檔
1 2 3 4 5 |
mkdir -p ~/.config/qBittorrent cat > ~/.config/qBittorrent/qBittorrent.conf <<- EOF [Preferences] WebUI\Enabled=true EOF |
5. 新增qBittorrent服務啟動腳本要用到的使用者,密碼部分要輸入兩次!
1 2 |
useradd qBittorrent passwd qBittorrent |
6. 建立qBittorrent服務啟動腳本,網頁介面用的port改為8998(預設是8080)
1 2 3 4 5 6 7 8 9 10 |
cat > /etc/systemd/system/qbittorrent.service <<- EOF [Unit] Description=qBittorrent torrent server [Service] User=qBittorrent ExecStart=/usr/bin/qbittorrent-nox --webui-port=8998 Restart=on-abort [Install] WantedBy=multi-user.target EOF |
7. 設定防火牆,將自訂的網頁介面用的8998連接埠加入白名單(預設是8080),8999是qBittorrent用的通訊埠
1 2 3 4 5 6 7 8 9 10 |
service iptables stop iptables -A INPUT -p tcp --dport 8998 -j ACCEPT iptables -A INPUT -p udp --dport 8999 -j ACCEPT service iptables save systemctl restart iptables ###firewalld請改成下列指令 firewall-cmd --permanent --add-port=8998/tcp firewall-cmd --permanent --add-port=8999/udp firewall-cmd --reload |
8. 啟用qBittorrent服務啟動腳本並啟動
1 2 3 4 |
chmod +x /etc/systemd/system/qbittorrent.service systemctl enable qbittorrent systemctl daemon-reload systemctl start qbittorrent |
9. 進入網頁介面,記得一定要先改密碼
http://你的IP:8998
預設帳號:admin
預設密碼:adminadmin
Tools >> Options >> Web UI
User Interface Language // 修改成正體中文
Authentication // 修改密碼
10. 打完收工,回到SSH畫面,清潔溜溜 🤓
1 2 |
cd /usr/src rm -fr libtorrent-rasterbar-* qBittorrent-release-* |
額外的指令
檢查qBittorrent啟動狀態
1 2 3 |
systemctl status qbittorrent -l ps ax | grep qbittorrent-* netstat -atunp | grep qbittorrent-* |
(可選)最佳化系統的吞吐量、支撐能力
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
ulimit -n 51200 sysctl -w net.core.default_qdisc=fq sysctl -w net.core.rmem_default=65536 sysctl -w net.core.wmem_default=65536 sysctl -w net.core.rmem_max=67108864 sysctl -w net.core.wmem_max=67108864 sysctl -w net.core.netdev_max_backlog=4096 sysctl -w net.ipv4.tcp_congestion_control=htcp sysctl -w net.ipv4.tcp_mtu_probing=1 sysctl -w net.ipv4.tcp_rmem='4096 87380 33554432' sysctl -w net.ipv4.tcp_wmem='4096 65536 33554432' ###個人常用的最佳化指令開始 sysctl -w net.core.optmem_max=25165824 sysctl -w net.core.somaxconn=4096 sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv4.route.flush=1 sysctl -w net.ipv4.tcp_fastopen=3 sysctl -w net.ipv4.tcp_fin_timeout=30 sysctl -w net.ipv4.tcp_keepalive_time=1200 sysctl -w net.ipv4.tcp_max_syn_backlog=4096 sysctl -w net.ipv4.tcp_max_tw_buckets=1440000 sysctl -w net.ipv4.tcp_mtu_probing=1 sysctl -w net.ipv4.tcp_syncookies=1 sysctl -w net.ipv4.tcp_tw_recycle=0 sysctl -w net.ipv4.tcp_tw_reuse=1 sysctl -w fs.file-max=2097152 ###個人常用的最佳化指令結束 sysctl --system |
- Compiling qBittorrent nox for CentOS from source@qBittorrent Wiki
- Setting up qBittorrent as a daemon on CentOS 7@qBittorrent Wiki
- Linux Tuning @ESnet