Setting up a Slave Backend

For discussion of topics specific to MythTV on linux
Post Reply
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Setting up a Slave Backend

Post by AndyInNYC »

I have a Ubuntu 16.04 64 bit machine running MythTV .28 - aside from some odds and ends, it appears to be working correctly. I have the machine's IP address set in both sections as 192.168.40.28, which is the machine address.

I have another, near identical machine, with a tuner card in it which I'd like to configure as a slave backend. This machine's IP is .30 (see above).

It's my understanding that I should:

apt-get the backend only
and then .... ?

I'm kind of lost after the fact that I need the back end only.

I've read I need to edit sql.txt; not set up video sources, etc.

What steps are required to get a working slave backend which talks to the master backend and will allow the frontends to work?

Thanks all.

Andrew
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Setting up a Slave Backend

Post by bill6502 »

Hi,

A backend (in 0.28 and earlier) acts as a slave if the IP address is different
from the Master IP address. Your .28 and .30. I don't recognize sql.txt. There
was an old file named mysql.txt, but that's long been replaced with config.xml
both typically in the .mythtv directory of the user that runs the backend. They
may exist in /etc/mythtv for your Mythbuntu. Refer to https://www.mythtv.org/wiki/Config.xml

In the Database section, the address (or hostname) will be that of the master, assuming
your DB lives on that same host.

Use mythtv-setup:

Note that the Storage Groups on the slave typically reference directories on itself.
No need to mount filesystems from the master. See: https://www.mythtv.org/wiki/Storage_Gro ... e_Backends
for details. I like the solution just before 'Example 2'.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

bill,

I'm having 2 problems

The slave machine is 192.168.40.30. The main backend is 192.168.40.28

Using the slave (.30) I get the 'can't connect to database' error when running mythtv-setup. I have 192.168.40.28 as the backend address (the backend works at the moment).

I have run usermod to make mythtv (as well as the two other users on the machine) members of mythtv and video.

I have edited every instance of config.xml on the machine (there were 3) to use 'mythtv' as the password.

Still no help

The main backend only uses the Default Storage Group. This is set to /media/RAID/Media/TVShows which is located on a RAID array in the system.

I'm still not sure what to set for the Storage Group (Default) on the Slave (if it ever runs) so that this same location is used for shows recorded using the slave's tuner.

So, #1 - what must change to connect to the master backend?
#2 - what do I set for storage groups on the slave?


Thanks.


Andrew
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Setting up a Slave Backend

Post by bill6502 »

AndyInNYC wrote: I have edited every instance of config.xml on the machine (there were 3) to use 'mythtv' as the password.
...
I'm still not sure what to set for the Storage Group (Default) on the Slave (if it ever runs) so that this same location is used for shows recorded using the slave's tuner.

So, #1 - what must change to connect to the master backend?
#2 - what do I set for storage groups on the slave?
...
Also be sure that the address (or hostname) in config.xml is that of your master. When
starting up, MythTV programs need to know where the database is.

When you start the backend (sudo systemctl start mythtv-backend most likely) look in it's
log (/var/log/mythtv/mythbackend.log) for a line containing this:

Using configuration directory =

That will tell you which directory the config.xml file being used is in. Typically, the
other two are symbolic links to that file, so you should really only have one piece
of data.

The Wiki has a much better discussion, but on my system, the Default Storage Group on
the slave contains Storage Directories that are intentionally different than any used on the
master. That means that if the slave isn't up, the master won't try to write to them.

If the slave has its own /media/RAID directory, an example would be /media/RAID/SlaveMedia/TVShows.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

I've edited each instance of the config.xml.

Starting mythtv-setup from a terminal screen, it opens the graphic screen, but prints the following to terminal:

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.40.28' (111)
status: Name "com.ubuntu.Upstart" does not exist

So, it knows where to look, but can't get there.

Thoughts?

I'm till completely missing the point on Storage Groups. I'd like the recordings to be saved on the master in the same directories - is that possible, or am I daft?


Thanks for your prompt replies.

Andrew
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

By the way, SQLServer isn't running on the slave - do I need to install it and create users (mythtv)?

Andrew
perkins1724
Junior
Posts: 33
Joined: Tue Nov 18, 2014 7:44 am
Australia

Re: Setting up a Slave Backend

Post by perkins1724 »

By the way, SQLServer isn't running on the slave - do I need to install it and create users (mythtv)?
You only need one mysql database but your remote machine needs mysql to act as a client. Check that you can remote access the database from your slave backend machine by trying from a terminal (replace user / password as needed):

Code: Select all

mysql -umythtv -pmythtv -h192.168.40.28 mythconverg
If you get "mysql: command not found" then you need to install mysql as a client on remote machine. If you are only using mysql on the remote machine for accessing remote databases then my understanding is that you shouldn't need to do any other setup (users, my.cnf, etc).

Given you get the message "Can't connect to MySQL server on '192.168.40.28' (111)" I don't think missing client is the problem, but try the above one-liner in a terminal and see what the output is.

Your master machine needs to be configured to allow remote access. There can be a few things to check, but firstly do you have any remote frontends that are working? If you have remote frontends working then a lot of the remote access setup must already be correct.

Items to check:
- port 3306 is open in firewall on master (3306 is the mysql port)
- mysql has bound to the correct ip address on the master and not just localhost. Try on the master

Code: Select all

netstat -peanut | grep 3306
and post output. A bind address of 0.0.0.0 means it is listening on all IPv4 addresses.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

Wow! lots of information.

First, the one liner:
mysql -umythtv -pmythtv -h192.168.40.28 mythconverg

returns:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.40.28' (111)

Second, I have a Kodi box with a MythTV add-on which works with the backend correctly - views, changes channels, deletes viewed programs, etc. The Kodi Box (an Amlogic S905 device) is on 192.168.40.215

Third, the command:
netstat -peanut | grep 3306

returns:

(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 123 21859 -
I'm not sure any firewall is running on the main backend machine. This machine is behind my router. iptables, for example, isn't running. My PBX machine has a firewall since I'm port forwarding (on the router) various ports. That machine is pretty particular about whom it dates.

Next steps?

Andrew
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

Wow! lots of information.

First, the one liner:
mysql -umythtv -pmythtv -h192.168.40.28 mythconverg

returns:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.40.28' (111)

Second, I have a Kodi box with a MythTV add-on which works with the backend correctly - views, changes channels, deletes viewed programs, etc. The Kodi Box (an Amlogic S905 device) is on 192.168.40.215

Third, the command:
netstat -peanut | grep 3306

returns:

(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 123 21859 -
I'm not sure any firewall is running on the main backend machine. This machine is behind my router. iptables, for example, isn't running. My PBX machine has a firewall since I'm port forwarding (on the router) various ports. That machine is pretty particular about whom it dates.

Next steps?

Andrew
perkins1724
Junior
Posts: 33
Joined: Tue Nov 18, 2014 7:44 am
Australia

Re: Setting up a Slave Backend

Post by perkins1724 »

(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 123 21859 -
Yep, MySQL is binding to localhost (127.0.0.1) only.

Need to find the config file for the bind address. I see that you are Ubuntu 16.04 so check for the presence of this file:

Code: Select all

/etc/mysql/mysql.conf.d/mysqld.cnf
And look for a line starting with bind-address=
Change that line to

Code: Select all

bind-address=0.0.0.0
to bind to any IPv4 address on your master backend (which I think is what most people do) or

Code: Select all

bind-address=192.168.40.28
for slightly tighter security

If there is no bind address line in that file (or its not present), check for some of these files to see if you can find the bind address line:
/etc/my.cnf
/etc/mysql/my.cnf
/etc/mysql/conf.d/mythtv.cnf
/etc/mysql/mysql.conf.d/mythtv.cnf

Will need to restart MySQL once you have made changes. Something like:

Code: Select all

sudo systemctl restart mysql
probably.
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Setting up a Slave Backend

Post by wesnewell »

If you're having a bind problem, just put this file in the appropriate place on the mater backend server and then upgrades won't overwrite it. I'm still running 14.04LTS so it may be a different location on your system.
wes@mythfe0:~$ cat /etc/mysql/conf.d/xmythtv.cnf
[mysqld]
bind-address = 0.0.0.0
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

OK, the bind problem appears to be solved. Thanks.

Now for the Storage (where to save the TV shows). I'm (obviously) still confused here.

On the master, I have a directory and share /media/RAID/Media/TVShows which is where the master will save the streams.

How do I get the slave to store files in the same directory?


Andrew
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Setting up a Slave Backend

Post by wesnewell »

I haven't run a slave backend in over 10 years, but I think I saved them to the local drive anyway because it was only used when that machine was on during prime time. If you want to save to the master just make it the storage directory in the slave backend setup.How you do that will probably depend on the type of shared network you're using. I always used NFS, but it's been so long ago I don't recall the details. This will probably help if you need to set it up. It may not be needed on newer systems. Also be aware that saving across the network will eat up shared bandwidth and may cause problems.
https://www.howtoforge.com/how-to-confi ... untu-14.04
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: Setting up a Slave Backend

Post by AndyInNYC »

Wesnewell,

Both machines (.28 and .30) are running Ubuntu 16.04. The master (.28) has a 3Ware hardware RAID card and the data there serves and the primary storage for my business and the home files.

I'll check to see where the mount point is and set up the backup machine to use the TVShows directory. I would have thought there would be a software option just to push the data over the network to the master backend for storage - guess I'm wrong.

I'm not terribly concerned about bandwidth. All of the machines have gigabit cards; I shouldn't be saturating the network pushing the occasional show back to the master backend.

My next trick will be to see about reordering/numbering channels - Fox 29 seems to come in as 25 in my listing on my frontend and I want to see if the card in the backup tunes certain channels better than the cards in the master.

All of this and I still pay DirecTV $200/month. I must be a glutton for punishment.


Andrew
perkins1724
Junior
Posts: 33
Joined: Tue Nov 18, 2014 7:44 am
Australia

Re: Setting up a Slave Backend

Post by perkins1724 »

I haven't got around to setting up slave backends yet. But this link I think has some excellent reading on the topic. https://www.mythtv.org/wiki/Storage_Gro ... e_Backends In particular see the quick rules listed.

My quick understanding:

MythTV doesn't redirect in-progress recordings (specifically the process writing tuner output to filesystem) from the slaveBE to the masterBE for the masterBE to then save to filesystem storage. So if your slaveBE has tuners that you want to record from, then you need to have some filesystem storage accessible to the slaveBE (ie local disk, mounted network share, pretty much just something writeable by the slaveBE OS). It can (optionally) be the same storage as is accessible to the masterBE, and it can (optionally) be at the same mount point / directory as is on the masterBE - but it doesn't need to be. Not all directories need to be available on all BE's.

HOWEVER:
- storage groups should only ever be defined on the masterBE, never the slaveBE. The storage group on the masterBE may contain filesystem directories that are not accessible to the masterBE but that's fine. The slaveBE will query the masterBE (database) for the filesystem directories that correspond to the requested storage group and test which ones it can (or cannot) write to and happily work with the ones it can access (ignore the ones it cannot).
- always make sure that the filesystem directories are folders inside the mount point, not the mount point itself, to prevent unintended behaviour (and problems) in the event that for some reason the mount fails.
- if the recording on a filesystem is only available on the slaveBE, then the slaveBE needs to be running for a frontend to play the recording (if the recording on a filesystem is available to both slaveBE and masterBE (even if at different mount locations / directories) but was made on the slaveBE and the slaveBE is off the masterBE will 'hunt' for the file in the directories available to the masterBE to try and find it).
- the slaveBE needs to be accessible to remote frontends in the same way as the masterBE is (specifically (default) ports 6543 and 6544).

Hope this helps, feel free to ask any follow up questions.
Post Reply