9

We have a CentOS machine and the MySQL is not starting due to disk space being full.

Below is the df -h results.

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       47G   45G     0 100% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/xvda1            485M   33M  428M   7% /boot
/dev/mapper/VolGroup-lv_home
                       44G  180M   42G   1% /home

What can be done in this situation? Add more hard disk?

kenlukas
  • 3,101
  • 2
  • 16
  • 26
user132638
  • 151
  • 1
  • 2
  • 9
  • u use lvm so check vgs if there is anyunalloated space. chance is that you dont have to migrate anything. u can attach a second disk, add that on eto the volume group and then grow the filesystem too, or resize the disk in the pool already. – Petter H Jul 14 '20 at 13:50

4 Answers4

5

The easiest and fastest option is to create a directory in /home and move all data of /var to that directory and create soft link of /var to /home/var. The steps will be as follows.

  1. mkdir /home/var

  2. stop all the services. For example /etc/init.d/mysqld stop

  3. cp -pr /var/* /home/var

  4. rm -rf /var

  5. ln -s /home/var /var

  6. start the services again.

Note: May you can only move mysql data which is on /var/lib/mysql and create softlink to that.

Toqeer
  • 1,241
  • 3
  • 14
  • 20
  • is it fine to expand the root partition will it have impact on the /boot and /dev/shm partition? – user132638 Sep 22 '12 at 06:12
  • /var is under '/' so no need to unmount and You already copied the data to /home/var in case of any problem you can move it back to /var with -p option. – Toqeer Sep 22 '12 at 06:15
  • @dear all so what is the right n best option is it best when we do a new installation to give var a separate partition? – user132638 Sep 22 '12 at 06:19
  • 3
    It is best practice to give /var and /home separate partition. – Toqeer Sep 22 '12 at 06:21
  • How big should var I guess should be much bigger then /home right? – user132638 Sep 22 '12 at 07:13
  • yes it should be bigger then /home, a default installation of mysql and httpd store all data in /var, also the logs store on /var so its better to keep it big – Toqeer Sep 22 '12 at 07:38
  • In case we have a 200gb hd what do you recommend for var is 150gb ok ? – user132638 Sep 23 '12 at 08:08
  • Yes 150GB is fine, if you are not going have special data for /home then keep that also under the / partition – Toqeer Sep 23 '12 at 10:41
1

You can :

  1. Add hard disk

  2. Move mysql DB files to other FS (in your case you have just /home FS left )

  3. You can resize your LVM volume to make /home smaller and / bigger (be sure to have backup of course :) )

This option is most straight forward, but LVM strongly recommend to backup your data before resizing

http://www.ibm.com/developerworks/linux/library/l-resizing-partitions-2/index.html

UPDATE (based on comment)

if I add hard disk what must I adjust on my mysql setting to expand the data to the hard disk? If option to mean I have to move mysql over what steps need to be taken for that?

Quite easy:

  1. Stop mysql
  2. Open /etc/my.cnf and find datadir= - here are your mysql datafiles
  3. Copy/Move them over to your new desired location
  4. Update datadir= with your new path
  5. Start Mysql
  6. Take a beer or whatever you want, cause you are done

How tough to expand the /root?

Read the link above which I already posted.Step by step guide is included there with comprehensive explanation.

Normally what the home partition is to store? Any important files?

It contain user files and setting.Eg your desktop etc.

For system healt /home is not important and can be remounted anytime.

  • if I add hard disk what must I adjust on my mysql setting to expand the data to the hard disk? If option to mean I have to move mysql over what steps need to be taken for that? How tough to expand the /root? Normally what the home partition is to store? Any important files? – user132638 Sep 22 '12 at 05:46
  • by adding a brand new hard disk what partition label it will show in the partition list and where to move then ? Thank you. – user132638 Sep 22 '12 at 06:13
  • @rkosegi - Vote it back if you removed your comment. – Toqeer Sep 22 '12 at 06:27
1

I would suggest, as the first first, to check the size of /var/log. Possibly archive older logs. They can clog up you root partition without you noticing, and most older logs might not be necessary.

Martin
  • 131
  • 4
0

mysql skip log bin, worked for me, must be placed in the my.cnf file when it boots up, still suggest you run your backups frequently. bin logs can be removed from the var/lib/mysql directory. Lastly your access logs, php and ssl logs can be investigated especially if you run plugins on your site, then logs can be kept for just a few days