Help - Search - Members - Calendar
Full Version: Separate mySQL to second hard disk
The Planet Forums > Control Panels > cPanel/WHM > Cpanel/WHM HOWTOs
Tony
Hi there,

I have this machine configuration
Intel Dual Xeon 2.4 GHz, 2GB RAM, (2) 73GB SCSI Hard Drives
With Cpanel for Hed Hat Enterprise

I want to split the mySQL onto the second hard drive (away from apache) for more efficient access and hop to reduce load on server. How can I do this? I’m sure many of you have done this. Will anyone help me?

Thank you in advance.
Tony
coralbridge
Everything works fine.

However, when I run 'service exim restart', I get the following:


Shutting down clamd: [ OK ]
Shutting down exim: [FAILED]
Shutting down antirelayd: [ OK ]
Shutting down spamd: [ OK ]
Starting clamd: [ OK ]
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Starting spamd: [ OK ]
panayot
The bad thing about cpanel is that it expects mysql datadir to be in /var/lib/mysql/ no matter what you specify in my.cnf. I copy the /var/lib/mysql/ to /drive2/mysql/

CODE
cd /var/lib

cp -Rp mysql /drive2/


If all went well, the old data dir can be renamed or deleted

CODE
mv mysql mysql_old


The mysql.sock never gets copied to /drive2 so I need to create it again and also help cpanel find the mysql.sock that will be created in /drive2/mysql, I make a link from /var/lib:

CODE
ln -s /drive2/mysql mysql


I put this in my.cnf:

CODE
datadir = /drive2/mysql

socket = /drive2/mysql/mysql.sock


then I execute mysqld_safe start (the purpose is to recreate the mysql.sock) and after the command completes, restart mysql from within whm.

that's it icon_biggrin.gif

Some more on backup:

Since I use my second drive to backup cpanel accounts, now after moving mysql datadir to this drive it is more wise to backup myslq data on the primary drive so that whichever drive gets corrupted, you still have all data on the other one.

So on the primary drive I have a directory /backup and then have this running twice a week as cronjob

CODE
mysqldump --flush-logs --delete-master-logs --master-data --all-databases > /backup/backup_all_mysql.sql --default-character-set=cp1251 --quote-names


upon making the backup, this also deletes all binary transaction logs because they are no more needed. This .sql file plus the binnary logs will always be able to restore your myslq dbs without any loss. For example if you had the cronjob run on sunday, and you got a crash on tuesday and lost all mysql databases, then you first restore from the .sql file, and then (provided that you also kept the binary logs on the drive different from where mysql datadir is - I keep them together with the .sql files in /backup) restore all update/delete transactions made sunday through tuesday from the binnary log.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.