Run MYSQL with data files in memory

This is needed to protect the flash card if your application updates the data tables heavily.

1. Put backup-mydb.sh in /usr/local/bin

2. Edit(set ROOTPW, …etc) and run the backup-mydb.sh script once.

3. Create mount point for new datadir, edit /etc/fstab , add lines:

# for mysql:
tmpfs           /var/mysqldata  tmpfs   defaults,size=16M       0 2

run:

mount /var/mysqldata
df -h

You see this line in the output:

tmpfs                  16M  1.2M   15M   8% /var/mysqldata

4. shutdown mysql, run:

invoke-rc.d mysql stop

5. Edit /etc/mysql/my.cnf, set

datadir         = /var/mysqldata

6. replace /etc/init.d/mysql with this modified version. (the modified one is based on 5.0.51a-24+lenny2)

7. start mysql, run

invoke-rc.d mysql start

The script will automatically restore all data files to /var/mysqldata

You can also run backup-mydb.sh by cron periodically.

Next time when you normally shutdown the system, the data files is auto backed up. When the system restart, the data files is auto restored.

voyage/run_mysql_with_data_files_in_memory.txt · Last modified: 2010-06-10 12:09 by admin
Back to top
GNU Free Documentation License 1.3
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0