Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How would you move mysql to a second harddrive?

Discussion in 'General Discussion' started by Vatoloco, Jul 11, 2005.

  1. Vatoloco

    Vatoloco Well-Known Member

    Joined:
    Jun 21, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    166
    I've got a system with two scsi harddrives and I want to move all the mysql databases to the second harddrive. Does anyone know if there is a simple way to do this or is it going to require making alot of changes in the cpanel configuration?
     
  2. BianchiDude

    BianchiDude Well-Known Member
    PartnerNOC

    Joined:
    Jul 2, 2005
    Messages:
    619
    Likes Received:
    0
    Trophy Points:
    166
    Just move /var to that second drive

    tip: dont follow symlinks
     
  3. gpreston

    gpreston Well-Known Member

    Joined:
    Jan 31, 2004
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    West Chester, PA
    You should be able to edit /etc/my.cnf and set datadir=/whatever in there. HTH
     
  4. Blue|Fusion

    Blue|Fusion Well-Known Member

    Joined:
    Sep 12, 2004
    Messages:
    378
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Cleveland, Ohio
    You can not just edit /etc/my.cnf because cPanel has several scripts hardcoded to use /var/lib/mysql, not to mention the process is started with --datadir=/var/lib/mysql despite the configuration file.

    What I did was make a 10GB partition on the second drive, format it as ext3, and mount it as /var/lib/mysql, using rsync to copy the databases to the new partition. Once everything is copied, just set the mountpoints in /etc/fstab as needed, and then mount it and fire up MySQL.
     
  5. gpreston

    gpreston Well-Known Member

    Joined:
    Jan 31, 2004
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    West Chester, PA
    Learn something new every day. Good to know, thanks mate.
     
  6. Vatoloco

    Vatoloco Well-Known Member

    Joined:
    Jun 21, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    166
    It sounds like this is exactly what I need to do it. I'm still learning all this linux stuff so it'll take me awhile to figure out all those commands but it's a good starting point for me and has given me alot of things to go look up. :)

    Thanks!
     
  7. Vatoloco

    Vatoloco Well-Known Member

    Joined:
    Jun 21, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    166
    This is probably a stupid question but once I mount the second hard drive to /var/lib/mysql how am I going to access the original /var/lib/mysql that's on my first drive to copy all of it over?
     
  8. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,470
    Likes Received:
    21
    Trophy Points:
    463
    Location:
    Go on, have a guess
    You should rename the original first to a different name (e.g. /var/lib/mysql.old) then mount the new partition and then either use rsync or cp -a to duplicate the files over.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Vatoloco

    Vatoloco Well-Known Member

    Joined:
    Jun 21, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    166
    Okay, so I'll rename my original directory to mysql.old and then after mounting the new drive to /var/lib/mysql, this command should copy everything, right?

    rsync -avz /var/lib/mysql.old /var/lib/mysql


    Edit: Through a little trial and error I figured out that wasn't quite right. I had to do this instead:

    rsync -avz /var/lib/mysql.old/ /var/lib/mysql

    (I found out the trailing slash was very important!) :)
     
    #9 Vatoloco, Jul 24, 2005
    Last edited: Jul 24, 2005
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice