Difference between revisions of "Backend migration"

From MythTV Official Wiki
Jump to: navigation, search
(Retiring an old backend: Add info for people who didn't plan ahead.)
(Retiring an old backend: Order in which cards/inputs are defined no longer matters.)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
__TOC__
 
__TOC__
 +
 +
= Overview of a Basic Upgrade =
 +
*Review the Release Notes e.g. {{CurrentRelease}} (don't forget to read the Release Notes of any skipped releases.)
 +
*Shut down all <code>mythfrontend</code> processes (on all hosts).
 +
*Shut down the <code>mythbackend</code> process, Master and Slave(s).
 +
*[[Database_Backup_and_Restore#The_Role_of_mythconverg_backup.pl_When_Changing_MythTV_Versions|Back up the MythTV database]].
 +
*Upgrade/install the new mythtv packages on all backend(s).
 +
*Upgrade/install the new mythtv packages on all frontend(s).
 +
*Run <code>mythtv-setup</code> on the Master Backend*. The database will automatically be upgraded.
 +
*Exit <code>mythtv-setup</code>.
 +
*Start the backend process.
 +
*Start the frontend process on your frontend system(s) .
 +
<pre>*Users with headless backends, type: ssh -l mythtv -Y <BackendHost> mythtv-setup</pre>
 +
 
= Building a new backend to replace an existing machine =
 
= Building a new backend to replace an existing machine =
 
If you want to build a new master backend, and test it before taking it into service, then follow these steps:
 
If you want to build a new master backend, and test it before taking it into service, then follow these steps:
Line 25: Line 39:
 
* If you still have access to the to-be-retired backend system:
 
* If you still have access to the to-be-retired backend system:
 
** Start mythtv-setup on the to-be-retired backend system and go to Capture Cards and select "Delete all capture cards on <hostname>" (use the "on <hostname>" option so you leave your cards on the other backends defined).
 
** Start mythtv-setup on the to-be-retired backend system and go to Capture Cards and select "Delete all capture cards on <hostname>" (use the "on <hostname>" option so you leave your cards on the other backends defined).
***Or, if you're physically moving cards to other hosts (and, therefore, need to re-connect all inputs to get them in the right order), this will be taken care of when you do the "Delete all capture cards" (to delete all cards from all hosts) before re-creating cards and re-connecting inputs).
+
***Or, if you're physically moving cards to other hosts, use "Delete all capture cards" (to delete all cards from all hosts) before re-creating cards and re-connecting inputs).
 
*** For further information See, also, http://www.gossamer-threads.com/lists/mythtv/users/264034#264034
 
*** For further information See, also, http://www.gossamer-threads.com/lists/mythtv/users/264034#264034
** While still in mythtv-setup on the to-be-retired backend system, go into Storage Directories, and Delete each Storage Group on the to be retired host (select the group and hit DELETE (by default, 'D')). If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary.  Note, though, that since MythVideo requires an explicit override of the Videos Storage Group on each host, you probably have overrides that need deleting.
+
** While still in mythtv-setup on the to-be-retired backend system, go into Storage Directories, and Delete each Storage Group on the to be retired host (select the group and hit DELETE (by default, 'D')).   If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary.  If you want to be sure, or you would like to redo your Storage Group definitions to make sure they're only specified on the master backend, perform this step on the master backend system, as described in the "If you no longer have access to the to-be-retired backend system" section, below.
  
 
* If you no longer have access to the to-be-retired backend system (the host died/broke/...):
 
* If you no longer have access to the to-be-retired backend system (the host died/broke/...):
Line 33: Line 47:
 
*** This will delete all cards and inputs from all hosts.  Then, re-create the capture cards on the remaining hosts and re-connect inputs.
 
*** This will delete all cards and inputs from all hosts.  Then, re-create the capture cards on the remaining hosts and re-connect inputs.
 
*** For further information See, also, http://www.gossamer-threads.com/lists/mythtv/users/264034#264034
 
*** For further information See, also, http://www.gossamer-threads.com/lists/mythtv/users/264034#264034
** In mythtv-setup on the master backend system (it must be the master backend system), go into Storage Directories, and Delete each Storage Group (select the group and hit DELETE (by default, 'D')). If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary.  Note, though, that since MythVideo requires an explicit override of the Videos Storage Group on each host, you probably have overrides that need deleting.
+
** In mythtv-setup on the master backend system (it must be the master backend system), go into Storage Directories, and Delete each Storage Group (select the group and hit DELETE (by default, 'D')). Be sure to delete the actual storage group and not just the storage directories.  If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary.  Note, though, that performing this step cannot do any harm, even if you forget to re-create any custom Storage Groups.
*** This will delete all Storage Groups and Storage Group directory lists from all hosts.  Then, re-create the Storage Groups and re-define directory lists.  For Storage Groups that require overrides (the Video storage groups), you will need to re-define directory lists on each host.
+
*** This will delete all Storage Groups and Storage Group directory lists from all hosts.  Then, re-create the Storage Groups and re-define directory lists.  You do not need to create all the same custom Storage Groups you previously had as long as you put all the same directories into what Storage Groups you do create.  Make sure that you create any special "built-in" Storage Groups you were using (such as Videos, Trailers, Screenshots, DB Backups, or ...) by using the provided buttons (such as "(Create Videos group)").
  
 
* Update your database to tell mythbackend that a new host now owns the recordings from the to-be-retired backend host:
 
* Update your database to tell mythbackend that a new host now owns the recordings from the to-be-retired backend host:
Line 40: Line 54:
 
<pre>mysql -umythtv -p mythconverg -e "UPDATE recorded SET hostname = 'new_hostname' WHERE hostname = 'old_hostname';"</pre>
 
<pre>mysql -umythtv -p mythconverg -e "UPDATE recorded SET hostname = 'new_hostname' WHERE hostname = 'old_hostname';"</pre>
  
(fixing the host names as necessary).  Eventually, we will have code that makes step #3 unnecessary.  Currently, there's no code in MythTV to allow doing this, so you have to edit the DB directly--which means you take all the risks that doing so entails, so [[Database Backup and Restore]]. Mike would recommend a backup before/between making any of the above modifications just in case you make a mistake.
+
The [[Database Backup and Restore]] tool has a utility for migrating a backend from one hostname to another, but it is a blanket change for all settings and hardware as well. It cannot be used to just shift recordings. As always, a database backup before doing any manual database manipulation is recommended. Note that this is only required for recordings. The location of any video content will be updated automatically based off a matching hash, with no loss of metadata, next time a '''''Scan For Changes''''' is triggered from the '''''Watch Videos''''' menu.
 +
 
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Latest revision as of 16:53, 26 June 2013

Overview of a Basic Upgrade

  • Review the Release Notes e.g. 34.0 (don't forget to read the Release Notes of any skipped releases.)
  • Shut down all mythfrontend processes (on all hosts).
  • Shut down the mythbackend process, Master and Slave(s).
  • Back up the MythTV database.
  • Upgrade/install the new mythtv packages on all backend(s).
  • Upgrade/install the new mythtv packages on all frontend(s).
  • Run mythtv-setup on the Master Backend*. The database will automatically be upgraded.
  • Exit mythtv-setup.
  • Start the backend process.
  • Start the frontend process on your frontend system(s) .
*Users with headless backends, type: ssh -l mythtv -Y <BackendHost> mythtv-setup

Building a new backend to replace an existing machine

If you want to build a new master backend, and test it before taking it into service, then follow these steps:

  • Build the machine, install the OS, etc.
  • It is suggested that unless you have a dedicated network on which to test the new machine, to give it a new IP address and hostname.
  • Test the machine.

When you are ready to press the machine into service as the master backend:

  • Stop all frontend and backend processes on all machines.
  • Back up the database on your existing master backend.
  • Copy the resulting backup file to the new machine.
  • Restore the database on the new machine. Depending on how your distribution initialises the database upon installation of the backend, you may need to use the procedure for replacing the database by the backup.
  • Before doing anything else, if you used a different hostname for the new machine, change the hostname of the master backend.
  • Start up mythtv-setup and also change the master backend IP address on the General Settings page.
  • Copy all media (recordings, videos, music, etc) from the old machine to the same directory structure on the new machine.
  • Modify /etc/mythtv/mysql.txt and /etc/mythtv/config.xml on all machines to point to the new database server.
  • If your frontends NFS-mount anything from the master backend, change those mounts to point to the new backend.
  • Start the master backend and all mythtv processes on all machines.

Retiring an old backend

3 steps are required to (properly) retire a backend system

  • If you still have access to the to-be-retired backend system:
    • Start mythtv-setup on the to-be-retired backend system and go to Capture Cards and select "Delete all capture cards on <hostname>" (use the "on <hostname>" option so you leave your cards on the other backends defined).
    • While still in mythtv-setup on the to-be-retired backend system, go into Storage Directories, and Delete each Storage Group on the to be retired host (select the group and hit DELETE (by default, 'D')). If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary. If you want to be sure, or you would like to redo your Storage Group definitions to make sure they're only specified on the master backend, perform this step on the master backend system, as described in the "If you no longer have access to the to-be-retired backend system" section, below.
  • If you no longer have access to the to-be-retired backend system (the host died/broke/...):
    • Start mythtv-setup on any host and go to Capture Cards and select "Delete all capture cards" (not "Delete all capture cards on <hostname>").
    • In mythtv-setup on the master backend system (it must be the master backend system), go into Storage Directories, and Delete each Storage Group (select the group and hit DELETE (by default, 'D')). Be sure to delete the actual storage group and not just the storage directories. If you've configured your system such that you've only defined Storage Groups on the master backend (and did not override any Storage Group directory lists on remote backends), this step will be unnecessary. Note, though, that performing this step cannot do any harm, even if you forget to re-create any custom Storage Groups.
      • This will delete all Storage Groups and Storage Group directory lists from all hosts. Then, re-create the Storage Groups and re-define directory lists. You do not need to create all the same custom Storage Groups you previously had as long as you put all the same directories into what Storage Groups you do create. Make sure that you create any special "built-in" Storage Groups you were using (such as Videos, Trailers, Screenshots, DB Backups, or ...) by using the provided buttons (such as "(Create Videos group)").
  • Update your database to tell mythbackend that a new host now owns the recordings from the to-be-retired backend host:
mysql -umythtv -p mythconverg -e "UPDATE recorded SET hostname = 'new_hostname' WHERE hostname = 'old_hostname';"

The Database Backup and Restore tool has a utility for migrating a backend from one hostname to another, but it is a blanket change for all settings and hardware as well. It cannot be used to just shift recordings. As always, a database backup before doing any manual database manipulation is recommended. Note that this is only required for recordings. The location of any video content will be updated automatically based off a matching hash, with no loss of metadata, next time a Scan For Changes is triggered from the Watch Videos menu.