Beerock
By:
Beerock

Trying to add a 10GB volume to a dedicated droplet running MySQL

February 5, 2018 102 views
MySQL Ubuntu 16.04

Hello,

Our Droplet has been running out of disk space and we've attached a volume, but it's not working. How do we make sure the droplet is using the extra disk we added?

The droplet is running MySQL only and is a dedicated database server.

Please let us know what we need to do.

Thank you.

Best,

Sunny

1 Answer

Simply mounting the droplet will not help you get rid of disk space issues. You need to actually use the volume.
When attaching a volume (https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean) you mount a certain folder to the block storage.
Only data inside this exact folder will be stored on the block storage. You are writing the server only runs a MySQL Database, here is what I would do:

  1. Make sure that the block storage is at least as big as the databases it should contain (use du for example)
  2. Stop the database
  3. Mount the storage somewhere (e.g. /mnt/storage)
  4. Copy your database storage to the mounted folder, make sure to preserve access rights, something like cp -rp /var/lib/mysql /mnt/storage should work
  5. unmount the storage and move the database storing location somewhere else (backup)
  6. mount the storage to your database data location (probably /var/lib/mysql) or change the datadir setting to point to the mounted volume.
  7. Start the database, check if everything is working
  8. make sure you added the volume to your /etc/fstab, especially if you changed the path to e.g. /var/lib/mysql
Have another answer? Share your knowledge.