PDA

View Full Version : /var partition is full. help please


Remi
Tue 1st Oct '02, 6:01pm
Hi every body

My /var partition is full, I need some help to move my DB directory to /home partition.

Can I just move the hall directory or just creat another (empty) directory and then link it to existed one in the full partition.

My database path is: /var/lib/mysql/VB-forum

I want to move it to: /home/mysql/vb-forum

Please elaborate as much as you can.

Thank you very much in advance

eva2000
Tue 1st Oct '02, 7:42pm
Originally posted by Remi
Hi every body

My /var partition is full, I need some help to move my DB directory to /home partition.

Can I just move the hall directory or just creat another (empty) directory and then link it to existed one in the full partition.

My database path is: /var/lib/mysql/VB-forum

I want to move it to: /home/mysql/vb-forum

Please elaborate as much as you can.

Thank you very much in advance

you'll need root server access and log into telnet/ssh

1. type

mysqladmin -u root -p flush-tables

this tells mysql to write to disk any data in memory

2. shutdown mysql by typing

/etc/rc.d/init.d/mysql stop

now find out your current mysql data directory owner and group settings by typing

ls -al /var/lib/mysql

you may have something like

drwx------ 2 mysql mysql 8192 Sep 18 18:14

means group = mysql
owner = mysql

3. then you need to move all mysql data directorys to new location (i do not recommend you sym link only 1 database, it's better to symlink the entire mysql data directory /var/lib/mysql to /home/mysql )

to create /home/mysql directory type

mkdir /home/mysql

now to move all databases type:

mv /var/lib/mysql/* /home/mysql

then type below to symlink

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

4. now type

ls -al /home/mysql

notice user and group for directories has changed to maybe

root and root

you need to change it back to what you had before in step 2

type this
chown -R mysql:mysql /home/mysql/*

5. finally restart mysql


/etc/rc.d/init.d/mysql start

nsr81
Tue 1st Oct '02, 9:39pm
You can also try flushing the logs from /var/log if you dont need them, logs such as "messages", "xferlog", maillog ( I believe created by sendmail program), exim_*log (if you are running exim mail server), and SSL logs which are usually "domain.com".

Of course if you need the logs, then you don't have a choice.

Even though eva2000's solution is more elegant, I'd probably just move the VB-forum to some place else and put a symlink in /var/lib/mysql with the same name.

Also if eva doesn't mind, I'd like to ask why moving just one database directory is a bad idea? I have done it before without anything bad happening to the database or the server :)

eva2000
Tue 1st Oct '02, 9:59pm
Originally posted by TNasir
You can also try flushing the logs from /var/log if you dont need them, logs such as "messages", "xferlog", maillog ( I believe created by sendmail program), exim_*log (if you are running exim mail server), and SSL logs which are usually "domain.com".

Of course if you need the logs, then you don't have a choice.

Even though eva2000's solution is more elegant, I'd probably just move the VB-forum to some place else and put a symlink in /var/lib/mysql with the same name.

Also if eva doesn't mind, I'd like to ask why moving just one database directory is a bad idea? I have done it before without anything bad happening to the database or the server :) i read somewhere on mysql.com it's for performance reasons... i could be wrong also http://www.mysql.com/doc/en/Symbolic_links_to_databases.html

http://www.mysql.com/doc/en/Disk_issues.html

Remi
Wed 2nd Oct '02, 3:26am
Thank you very much George , you are great (as usual) :D
I will tray it and let you know.

Many thanks TNasir, your solution has reduced the size from 94% to 88% :D

This will give me some space until applying the solution from George later on today.

I am very grateful

Remi
Wed 2nd Oct '02, 6:36am
Hi George

A small problem caused by me trying to be smart :o

I have moved only one database using the same steps, this is what I have right now.

I have moved my DB "vb" frome /var/lib/mysql/vb

to /home/mysql/vb

I have changed the ownership to mysql to the directory 'VB' and I have chicked both the directory and the files insid it by using "ls -al" Command, every thing is OK.

I think I am missing somthing with the link command, this is what I have used:

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

I have restarted the Mysql but saadly it is not working

Any ideas please

Thanks

eva2000
Wed 2nd Oct '02, 10:37am
what do you mean by not working ? any error messages ?

Remi
Wed 2nd Oct '02, 11:14am
Hi George

Every thing is fine now.

I was creating the link in the wrong place :o .

Thank you so much for you help :)

eva2000
Wed 2nd Oct '02, 11:32am
Originally posted by Remi
Hi George

Every thing is fine now.

I was creating the link in the wrong place :o .

Thank you so much for you help :) no probs :D

Trommsdorff
Tue 22nd Jul '03, 11:29pm
I too have this exact problem. I moved /var/lib/mysql to /home/mysql, and made a symlink using

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

Now, I try to start mysql, get this error when I restart it through WHM:

mysql has failed, please contact the sysadmin (result was "/usr/bin/mysqlshow: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"). Jul 22 16:28:31 poe mysql: Killing mysqld with pid 13886 Jul 22 16:28:32 poe rc: Stopping mysql: succeeded Jul 22 20:56:09 poe mysql: No mysqld pid file found. Looked for /var/lib/mysql/poe.sherdog.net.pid. Jul 22 20:56:09 poe rc: Stopping mysql: succeeded

I made sure all the ownerships are set for the dir and group.

*pulls hair* - any help?

nsr81
Tue 22nd Jul '03, 11:36pm
Put this in your /etc/my.cnf file and restart mysql. See if it helps:


[client]
socket=/tmp/mysql.sock
[mysqld]
socket=/tmp/mysql.sock

Trommsdorff
Tue 22nd Jul '03, 11:39pm
Thanks for the fast response. here's the new error message:

mysql has failed, please contact the sysadmin (result was "/usr/bin/mysqlshow: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)"). Jul 22 16:28:31 poe mysql: Killing mysqld with pid 13886 Jul 22 16:28:32 poe rc: Stopping mysql: succeeded Jul 22 20:56:09 poe mysql: No mysqld pid file found. Looked for /var/lib/mysql/poe.sherdog.net.pid. Jul 22 20:56:09 poe rc: Stopping mysql: succeeded


The thing is, if you cd to /var/lib/mysql there's the mysql.sock= file in there...

eva2000
Wed 23rd Jul '03, 1:29am
try changing

socket=/tmp/mysql.sock

to

socket=/home/mysql/mysql.sock

in my.cnf