[mythtv-users] ramfs for mysql

Simon Hobson linux at thehobsons.co.uk
Wed Jan 4 19:02:11 UTC 2012


Josu Lazkano wrote:

>cp -R /var/lib/mysql /tmp/mysqltmp/
>chown -R mysql:mysql /tmp/mysqltmp/mysql/

You don't need to fiddle with ownerships and permissions - just use 
the "-p" option to cp and it will preserve ownership and permissions.

>How could I copy all data on system stop and then copy again on system start?

If you need to ask that, then it may not be the right option for you.

You probably want to modify the mysql start/stop script. The system 
calls this during startup & shutdown. You need to have the shutdown 
option copy all the tables to a safe place after stopping the daemon, 
and the startup option copy the safe copies to the ram disk before 
starting the daemon.
If the system is running for a long time, you almost certainly want 
to stop mysql from time to time and copy the tables to safe storage - 
otherwise you risk losing potentially weeks or months of updates. If 
you've modified the start/stop script, then this could be achieved by 
a cronjob that just just stops and immediately starts mysql.
As a refinement, you could have the start option check to see if the 
files on ram disk are the same age as those on real disk and skip the 
copy - thus saving the copy back if the system hasn't been restarted 
and so has the current DB files already on ram disk.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.


More information about the mythtv-users mailing list