Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
vms:bittorrent [2017/05/30 03:44]
admin created
vms:bittorrent [2017/06/02 04:36] (current)
admin [Transmission]
Line 3: Line 3:
 ===== Transmission ===== ===== Transmission =====
  
-We'll start with the installation of a **Transmission** server, based on a Debian template.+We'll start with the installation of a **Transmission** server, based on a [[vms:​debian|Debian template]]. 
 + 
 +=== Installation === 
 + 
 +<​Code:​json>​ 
 +> apt-get install transmission-daemon 
 +</​Code>​ 
 + 
 +This will start the transmission daemon process (service), it will be running under a new user created at install time: '​debian-transmission'​. Note that, at the same time, a directory belonging to this same user was also created: '/​var/​lib/​transmission-daemon'​. It contains a '​downloads'​ folder and a symlink to the configuration directory. 
 + 
 +We'll create a "​seeding"​ directory and edit the configuration file, for this we need to stop the service first: 
 +<​Code:​bash>​ 
 +> mkdir /​var/​lib/​transmission-daemon/​seeding 
 +> chown debian-transmission:​debian-transmission /​var/​lib/​transmission-daemon/​seeding 
 +> service transmission-daemon stop 
 +> nano /​var/​lib/​transmission-daemon/​info/​settings.json 
 +</​Code>​ 
 + 
 +Refering to [[https://​ctrl.blog/​entry/​how-to-server-seeding-dht-torrents]],​ here are the important settings to set: 
 + 
 +<​Code:​bash>​ 
 +"​download-dir":​ "/​var/​lib/​transmission/​seeding",​ 
 +"​incomplete-dir":​ "/​var/​lib/​transmission/​seeding",​ 
 +"​dht-enabled":​ true, 
 +"​lpd-enabled":​ true, 
 +"​pex-enabled":​ true, 
 +"​peer-limit-per-torrent":​ 10, 
 +"​port-forwarding-enabled":​ false, 
 +"​queue-stalled-enabled":​ false, 
 +"​speed-limit-down":​ 50, 
 +"​speed-limit-down-enabled":​ true, 
 +"​speed-limit-up":​ 50, 
 +"​speed-limit-up-enabled":​ true, 
 +"​upload-slots-per-torrent":​ 5, 
 +"​user-has-given-informed-consent":​ true, 
 +"​watch-dir":​ "/​var/​lib/​transmission/​seeding",​ 
 +"​watch-dir-enabled":​ true, 
 +</​Code>​ 
 + 
 +For a complete description of all options: [[https://​web.archive.org/​web/​20160428165927/​https://​trac.transmissionbt.com/​wiki/​EditConfigFiles]] 
 + 
 +For detailed instructions on how to use Transmission:​ [[https://​help.ubuntu.com/​community/​TransmissionHowTo]] 
 + 
 +=== System Configuration === 
 + 
 +To avoid Transmission eating up all the system'​s resources, edit ''/​lib/​systemd/​system/​transmission-daemon.service'':​ 
 + 
 +<​Code>​ 
 +> nano /​lib/​systemd/​system/​transmission-daemon.service 
 +ADD @ end of [Service] section 
 +[Service] 
 +... 
 +Nice=16 
 +IOSchedulingClass=idle 
 +CPUSchedulingPolicy=idle 
 +MemoryMax=25M 
 +MemoryHigh=35M 
 +ProtectSystem=true 
 + 
 +> systemctl daemon-reload 
 +</​Code>​ 
 + 
 +Note that we reload daemons for our changes to take effect. 
 + 
 +=== UDP socket buffers === 
 + 
 +Setting ''"​message-level":​ 3,''​ in ''/​var/​lib/​transmission-daemon/​info/​settings.json'',​ then monitoring ''/​var/​log/​syslog'',​ or better ''/​var/​log/​daemon.log''​ will show: 
 +<​Code>​ 
 +Jun  2 04:18:24 transmission-20 transmission-daemon[4243]:​ [2017-06-02 04:​18:​24.532 CEST] UDP Failed to set receive buffer: requested 4194304, got 425984 (tr-udp.c:​78) 
 +Jun  2 04:18:24 transmission-20 transmission-daemon[4243]:​ [2017-06-02 04:​18:​24.534 CEST] UDP Failed to set send buffer: requested 1048576, got 425984 (tr-udp.c:​89) 
 +</​Code>​ 
 + 
 +It seems Transmission is willing to get a 4MB receive buffer and a 1MB send buffer, while only 256K are available. We'll fix that using the following commands: 
 +<​Code>​ 
 +> echo '​net.core.rmem_max = 16777216'​ >> /​etc/​sysctl.conf 
 +> echo '​net.core.wmem_max = 4194304'​ >> /​etc/​sysctl.conf 
 +> sysctl -p 
 +</​Code>​ 
 + 
 +For production servers with hundreds of connections 16MB receive and 4MB send buffers are recommended [[https://​trac.transmissionbt.com/​ticket/​4321| read more here...]] 
 +===== mitorrent ===== 
 +[[https://​github.com/​da2x/​mitorrent]] 
 + 
 +First we must follow [[vms:​python:​dev|this installation guide]] to setup an appropriate python environment,​ we also need to have '​git'​ installed, so we can clone the GitHub repo. 
 + 
 +=== Install=== 
 +<​Code:​bash>​ 
 +> apt-get install git-core 
 +> su py3 
 +> cd $HOME 
 +> git clone https://​github.com/​da2x/​mitorrent.git 
 +> cd mitorrent 
 +> mkvirtualenv mitorrent 
 +> chmod +x mitorrent-runner.py 
 +</​Code>​ 
 + 
 +===Usage=== 
 +<​Code>​ 
 +> su py3 
 +> cd $HOME/​mitorrent 
 +> workon mitorrent 
 +> ./​mitorrent-runner.py path/​to/​original/​file > path/​to/​torrent/​file.torrent 
 +</​Code>​