hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Dedicated Server : How to symlink /var/lib/mysql if /var mount becomes full
Reply

Forum Jump

How to symlink /var/lib/mysql if /var mount becomes full

Reply Post New Thread In Dedicated Server Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-30-2011, 11:24 PM
SagoJonB SagoJonB is offline
Junior Guru Wannabe
 
Join Date: Jun 2010
Location: Clearwater, FL
Posts: 41

How to symlink /var/lib/mysql if /var mount becomes full


Most of you may already know how to do this, so forgive if this is too simple, but this may be helpful for some dedicated server owners whose /var mount (some hosts use separate partitions for /usr, /var, /home etc) has become full, which is usually do to large databases in /var/lib/mysql. There is usually plenty of room in /the /home partition. This will work on cPanel servers as well.

This simple tutorial lays out the steps involved to copy contents of /var/lib/mysql to /home and then symlink /var/lib/mysql to /home/mysql. Of course adjust accordingly if moving/symlinking to a different mount or directory.

1) Go to webpage that uses mysql to verify working pre-copy

2) Stop mysql service (I will usually also stop cpanel & http service just to be safe).

/etc/init.d/mysql stop
/etc/init.d/httpd stop
/etc/init.d/cpanel stop

3) Do the copy:

rsync -av /var/lib/mysql /home/

4) Verify copied folder same size as source with du:

du -sh /var/lib/mysql
du -sh /home/mysql

5) Move /var/lib/mysql to /home/mysql-bak (essentially removing /var/lib/mysql because the folder must not exist when symlink is created)

mkdir /home/mysql-bak
mv /var/lib/mysql /home/mysql-bak/

6) Create symlink:

ln -s /home/mysql /var/lib/mysql

7) Verify the symlink is correct when listing the contents of new symlinked /var/lib/mysql (you can refer to the rsync copy to make sure the paths are the same - they should be)

8) Restart mysql, httpd, cpanel

9) Verify mysql-reliant webpage is loading without issue

10) You should now have freed up space on /var. Verify with 'df -h'

__________________
Sago Networks-Internet Solutions Company
Servers|Colocation|VPS|Backup|Managed Services
See Our VPS DEALS Toll free 866-366-3640



Sponsored Links
  #2  
Old 11-22-2011, 06:32 AM
almanox almanox is offline
Temporarily Suspended
 
Join Date: Sep 2011
Location: UK
Posts: 161
Thank you. I guess you should place any future tutorials in tutorials section (e.g. Dedicated Server Tutorials).

  #3  
Old 11-22-2011, 09:16 AM
HostXNow_Chris HostXNow_Chris is offline
Web Hosting Master
 
Join Date: Oct 2009
Location: England, United Kingdom
Posts: 8,835
+1

Thanks for sharing.

__________________
HostXNow - http://www.hostxnow.com | Since 2009
Fast, Secure and Reliable [UK/USA] Web Hosting - Reseller Hosting - VPS Hosting
cPanel/WHM CloudLinux (Multi PHP) Offsite Backups LiteSpeed Website Builders Softaculous Domains SSL

Sponsored Links
  #4  
Old 11-22-2011, 01:55 PM
hhw hhw is offline
Web Hosting Master
 
Join Date: Oct 2002
Location: Vancouver, B.C.
Posts: 2,203
Quote:
Originally Posted by SagoJonB View Post
2) Stop mysql service (I will usually also stop cpanel & http service just to be safe).

/etc/init.d/mysql stop
/etc/init.d/httpd stop
/etc/init.d/cpanel stop
Stopping httpd and cpanel aren't necessary; so long as mysql is stopped, there wouldn't be any open writes happening.

Quote:
Originally Posted by SagoJonB View Post
3) Do the copy:

rsync -av /var/lib/mysql /home/
Using cp -a will probably be quicker. No point in doing a comparison of files when you know they won't exist in the new location.

__________________
Han Hwei Woo, ASTUTE HOSTING AS54527 *Advanced and customized solutions for the savvy customer!*
Dedicated Hosting and CDN out of Vancouver, Seattle, LA, Toronto, NY, Miami, and (soon) London
We include CDN, anycast DNS, onboard KVMoIP, firewall, local and global load-balancing, and privatenet with all servers.
sales@astutehosting.com

  #5  
Old 11-22-2011, 07:04 PM
SagoJonB SagoJonB is offline
Junior Guru Wannabe
 
Join Date: Jun 2010
Location: Clearwater, FL
Posts: 41
The reason I use rsync instead of cp is mostly to get the readout of what was copied for logging purposes.

__________________
Sago Networks-Internet Solutions Company
Servers|Colocation|VPS|Backup|Managed Services
See Our VPS DEALS Toll free 866-366-3640

Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Symlink: /var/lib/mysql -> /home/mysql... Is that OK? oaziz Hosting Security and Technology 3 09-02-2011 03:32 PM
symlink /var/lib/mysql to /home/mysqlvartmp ? sharmaine1111 Hosting Security and Technology 17 11-24-2009 12:25 PM
ERROR: The partition with /var/lib/mysql is too full! jjk2 Programming Discussion 6 06-19-2009 03:07 AM
What in /var/lib/mysql/ dunhill Hosting Security and Technology 11 12-11-2008 06:30 AM
What are these files in /var/lib/mysql ? linuxperts Hosting Security and Technology 5 09-12-2005 01:36 AM

Related posts from TheWhir.com
Title Type Date Posted
Host Color Listing 2014-04-23 04:31:08
Google Releases Hosted Database Service Cloud SQL to General Availability Web Hosting News 2014-02-12 13:46:02
Google Cloud Provides Support For Native MySQL Connections Web Hosting News 2013-11-01 14:36:06
RackHigh Launches On-Demand NAS and SAN Storage Solutions Web Hosting News 2013-08-28 15:14:39
PHP And MySQL Scaling: Preparing A Startup For Growth Blog 2013-08-19 12:25:00


Tags
cpanel, mysql, symlink

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?