Haripad, Alleppey+91 7907 137617mailbox@netventure.innet.venture

Move Mysql To Second Disk – Step by Step

Post 34 of 72

IO is a often a bottleneck with databases and if your dedicated server has a second physical disk use that to improve IO throughput.

Here are the steps. Please note that these are steps for a CentOS 5.x system with /disk2 as the second HDD mount.

Step 1. Stop mysql

service mysqld stop

Step 2. locate my.cnf –To locate your mysql config file

Step 3. Open the file in your favourite browser like nano,pico or vi

Step 4. Look for the line for datadir. This is the current location of your mysql database files.
datadir=/var/lib/mysql

Step 5. Create a backup of your mysql folder

cp -R /var/lib/mysql /var/lib/mysql_backup

Step 6. Move mysql folder to /disk2
mv /var/lib/mysql /disk2/

Step 7. Change the ownership for the files to mysql
chown -R mysql.mysql /disk2/mysql

Step 8. Create a symbolic link from /var/lib/mysql to /disk2/mysql

ln -s /disk2/mysql/ /var/lib/mysql

Step 9. Edit the my.cnf file and modify the parameters as below

datadir=/disk2/mysql
socket=/disk2/mysql/mysql.sock
basedir=/disk2

10. Start up mysql

service mysqld start

If, for any reason, mysqld fails to start check the log file

tail -10 /var/log/mysqld.log

If you need any help, please feel free to get in touch.

,

Menu