FreeBSD in the background
Contents
What's this about?
My primary Myth box is a home-built mini-itx machine running KnoppMyth. My original plan (which I will complete one day!) was to have it tftp-booting from my FreeBSD server under the stairs, so it can run completely silent. For now, however, it has a 10-gig harddrive hanging off the back of it to run the system. Playing back the streams is hard work however (the 1GHz Via chip can just about handle it), so most of the grunt work is delegated to the server...
NFS storage
There's a dedicated 200 gig drive in the server, for program storage, which is NFS exported and mounted on the Myth box; this works very well indeed. I have this mounted at /myth on the server, and then mounted at /myth on the client (having matching mountpoints makes everything much simpler when moving functions between the different machines). The line in /etc/exports on the server looks like this:
/myth -maproot=0 -alldirs -network 192.168.127
and the line in /etc/fstab on the client is:
<server>:/myth/ /myth nfs rw,nolock,rsize=8192,wsize=8192 0 0
MySQL
This wasn't really neccessary, but I did it because it could: I already had MySQL running on the server, so this is serving up the mythconverg database.
Moving the database is dead easy; take a backup, stop mythbackend, restore the backup to the new server, tweak mysql.txt on the Myth box, and restart mythbackend. Thus:
Take a backup
You're doing this every night anyway, right? ;) It's:
/usr/bin/mysqldump --user=<user> --password=<passwd> mythconverg > backup.sql
You can pipe it through bzip of gzip of you like.
Stop mythbackend
Well, on my Knoppmyth install, it's /etc/init.d/mythtv-backend stop. That's it. YMMV.
Restore the backup
You need an account first. Start the mysql client as root and do something like:
CREATE DATABASE mythconverg; GRANT ALL ON mythconverg.* TO '<user>'@'<ip_of_myth_box>' IDENTIFIED BY '<passwd>'; FLUSH PRIVILEGES;
It's probably a good idea to check that you can connect to this database from the Myth client:
mysql -h <database_server> -u <username> -p <passwd>
If that works, it's a promising sign. If it doesn't, then stop now and find out why, because nothing else is going to work...
Tweak mysql.txt
This tells your Myth install where and how to connect to the database. On Knoppmyth it's at /etc/mythtv/mysql.txt. Mine now looks like this:
DBHostName=<database_server> DBUserName=<username> DBName=mythconverg DBPassword=<passwd>
Restart myth
Unsurprisingly, it's /etc/init.d/mythtv-backend start
And it should all Just Work.
Apache
Mythweb can push apache very hard at times (have a look at top(1) while you run a search for 'news', for example). So I moved this onto the server, too. On the server, what I did was:
rsync -av <myth_box>:/usr/share/mythtv/mythweb /usr/local/www/data/
(of course, apache (with mod_php5) was already up and running on the server). Now, this directory contains a bunch of symlinks pointing to various bits of the /myth/ tree, which is why using the same mountpoints on server and client is a Good Thing. Chances are, if you now point a browser at '<server>/mythweb/, it'll all be there.
Virtual host
I also added a DNS CNAME for 'mythweb', pointing to the server, then added an apache virtual host like this:
<VirtualHost <server_ip>> DocumentRoot /usr/local/www/data/mythweb/ ServerName mythweb.<your _domain> ErrorLog "|/usr/local/sbin/cronolog -l /var/log/apache/myth.error.log -p 1day /var/log/apache/myth.error.%Y%m%d.log" CustomLog "|/usr/local/sbin/cronolog -l /var/log/apache/myth.access.log -p 1day /var/log/apache/myth.access.%Y%m%d.log" combined </VirtualHost>
(you'll need cronolog installed for this particular example to work).
MORE SOON!!!