Skip to content
Weston Nielson edited this page Mar 20, 2017 · 24 revisions

Ubuntu Install

This is a guide to get Plex Remote Transcoder setup on two Ubuntu machines--a master and a transcode slave. The first machine will be the master node with IP address 192.168.0.2 and the transcode slave node with IP address 192.168.0.3. This guide assumes that you have already installed the Plex Media Server (PMS) .deb package on the master (directions can be found here if needed). The slave should be a vanilla install of Ubuntu Server 14.04. A good way to follow along if you don't have access to multiple machines is to simply create a few virtual machines using something like VirtualBox (take a look at this tutorial for a quick way to get started).

For this guide, we've installed Ubuntu 14.04 on two virtual machines using VirtualBox. On the master we've installed the latest copy of Plex Media Server (PMS), which at the time of writing is version 2.4.18.

NOTE This works on Ubuntu 16.04 with very small changes in the steps below. Most notably, make sure that you are using python 2.7 (not python 3). In my case, I had to install python 2.7 with sudo apt-get install python2.7, as it did not ship preinstalled. Everything else is pretty much identical.

Configure the Master Node

Install Plex Remote Transcoder

First off, let's install Plex Remote Transcoder:

git clone https://github.com/wnielson/Plex-Remote-Transcoder.git
cd Plex-Remote-Transcoder
sudo python setup.py install

You may need to install git (sudo apt-get install git) and setuptools (sudo apt-get install python-setuptools) if you don't already have them installed.

Now we need to configure Plex Remote Transcoder via the prt command that was installed in the previous step

sudo prt install

You will be prompted for the IP address of the master node. In this example, it is 192.168.0.2. Behind the scenes this command will rename the original Plex New Transcoder to plex_trancoder and install a new Plex New Transcoder provided by Plex Remote Transcoder. Set up the configuration with

sudo install -o plex -g plex ~/.prt.conf ~plex/

which will copy the configuration file into the plex user's home directory and update its permissions.

Now we need to tell the master about the transcode slave. We need to do this as the plex user, which can be accomplished via the following command

sudo -u plex -H prt add_host

which will prompt you for the slave details. For our example, the values we should enter are

Host: 192.168.0.3
Port: 22
User: plex

That does it for Plex Remote Transcoder.

Configure Network Shares

The slave nodes must be able to access certain directories contained on the master node. The easiest way to go about doing this is by sharing the directories over the network. In our case, we're going to use NFS, but if you are more comfortable with a different protocol the approach should be similar.

If your master node doesn't have NFS installed, you can do so via

sudo apt-get install nfs-kernel-server

Once that is complete, you will have a new file named /etc/exports which defines the network shares. For Plex Remote Transcoder to work, we need to share four things

  1. The Plex configuration directory
  2. The Plex binaries directory
  3. The temporary Plex transcoder directory
  4. Every directory that PMS looks for media in

The first directory is /var/lib/plexmediaserver and the second is /usr/lib/plexmediaserver. The third directory can be found/changed via Plex's web interface. Log in, go to settings, select your server, click "Show Advanced", click on "Transcoder" and the path will be under "Transcoder temporary directory". In this example, I've set this to /opt/plex/tmp. Finally, for this example we are assuming that all media is contained in /mnt/media.

If you also decide to use /opt/plex/tmp (or something similar) make sure the directory exists (sudo mkdir -p /opt/plex/tmp) and that it is writable (sudo chown -R plex:plex /opt/plex).

With these paths in mind, we can now create the network shares. Open /etc/exports with your favorite editor (make sure to do so as sudo) and add the following:

/var/lib/plexmediaserver 192.168.0.3(ro,sync,no_subtree_check)
/usr/lib/plexmediaserver 192.168.0.3(ro,sync,no_subtree_check)
/opt/plex/tmp 192.168.0.3(rw,sync,no_subtree_check)
/mnt/media 192.168.0.3(rw,sync,no_subtree_check)

NOTE The rw option on /mnt/media is necessary if you want Plex's media optimizer feature to work correctly.

In these shares we explicitly told NFS to only share these with the slave (IP address 192.168.0.3). Additionally, the temporary transcoder directory, /opt/plex/tmp, must be exported read-write (hence the rw option). The other directories are simply exported as read-only (ro).

After you've added this to /etc/exports, make sure to restart the NFS daemon so that the changes can take effect.

sudo service nfs-kernel-server restart

Configure the Slave Node

Install Plex Remote Transcoder

Now it is time to configure the slave node. Like on the master, lets start by installing Plex Remote Transcoder

git clone https://github.com/wnielson/Plex-Remote-Transcoder.git
cd Plex-Remote-Transcoder
sudo python setup.py install

Again, install git and python-setuptools as needed via apt-get. However, there is no need to run prt install on the slave.

Add Plex User

To make permissions issues easier, it is convenient to have the same plex user on the slave as is on the master. The easiest way to go about doing this is to create a new plex user on the slave and give it the same UID and GID as the plex user on the master. To do this, execute the following on the master

id plex

which should return something like

uid=105(plex) gid=112(plex) groups=112(plex)

Your numbers may be different, so write them down.

Now, back on the slave we can create the new plex user

sudo addgroup --gid 112 plex
sudo adduser --uid 105 --gid 112 plex --home /var/lib/plexmediaserver --no-create-home

Make sure to use the UID and GID that you wrote down in the previous step.

Now if we do id plex on the slave, we should get the same output as on the master.

Configure Network Shares

We need to tell the slave how to mount the network shares that we've exposed on the master. Open up /etc/fstab with and editor, as sudo, and add the following:

192.168.0.2:/var/lib/plexmediaserver /var/lib/plexmediaserver nfs defaults 0 0
192.168.0.2:/usr/lib/plexmediaserver /usr/lib/plexmediaserver  nfs defaults 0 0
192.168.0.2:/opt/plex/tmp /opt/plex/tmp  nfs defaults 0 0
192.168.0.2:/mnt/media /mnt/media nfs defaults 0 0

Notice that we've pointed to mounts to the master at 192.168.0.2. Also, make sure that these paths exists

sudo mkdir -p /var/lib/plexmediaserver
sudo mkdir -p /usr/lib/plexmediaserver
sudo mkdir -p /opt/plex/tmp
sudo mkdir -p /mnt/media

and that NFS is installed (sudo apt-get install nfs-kernel-server). Now we can mount the shares

sudo mount -a

If you do ls /*/lib/plexmediaserver you should see files listed--these are being shared to the slave by the master and everything is working as it should.

Enable Key-Based Authentication

In order for this all to work the plex user on the master must be able to login to the slave without a password. The secure way to do this is via key-based authentication.

On the master, change to the plex user and generate a key

sudo su plex
ssh-keygen

Accept the defaults and when prompted don't add a password, just hit "return". Now we need to copy that key from the master to the slave.

To install the key, do

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Now try connecting to the slave

It should say something along the lines of "the authenticity of host can't be established", just type "yes" and continue. If everything went as planned, you should now be logged into the slave without having supplied a password!

Configure Network Auth

The slaves need to be able to communicate with the master PMS server without having to use authentication. To set this up, go to the server settings via your browser, navigate to the 'Network' tab (make sure "Show Advanced" is on). Scroll down to "List of IP addresses and networks that are allowed without auth". In that box, put in your slave addresses or network. In the case of this tutorial, we would need to enter 192.168.0.3.

All Done

That's it! You should now be able to fire up a video and watch it being transcoded on the slave instead of the master.

Uninstall

To uninstall PRT, you have a couple of options but the easiest is to simply (re)install the original PMS dpkg:

sudo dpkg -i plexmediaserver_0.9.16.6.1993-5089475_amd64.deb

Now your Plex install should be back to normal.