Author Topic: Ran out of space, /var/lib/postgresql == 15GB!  (Read 13709 times)

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Ran out of space, /var/lib/postgresql == 15GB!
« on: June 03, 2010, 03:22:09 pm »
Hi,

Our ebox has run out of disk space

An 18GB disk:
Code: [Select]
root@router-internal:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              18G   16G  1.8G  90% /
varrun                505M   56K  505M   1% /var/run
varlock               505M     0  505M   0% /var/lock
udev                  505M   44K  505M   1% /dev
devshm                505M     0  505M   0% /dev/shm

15GB in the postgresql database folder:
Code: [Select]
root@router-internal:/# du -h / | grep '[0-9]G\>'
du: cannot access `/proc/15946/task/15946/fd/3': No such file or directory
du: cannot access `/proc/15946/task/15946/fdinfo/3': No such file or directory
du: cannot access `/proc/15946/fd/3': No such file or directory
du: cannot access `/proc/15946/fdinfo/3': No such file or directory
14G     /var/lib/postgresql/8.3/main/base/16384
14G     /var/lib/postgresql/8.3/main/base
15G     /var/lib/postgresql/8.3/main
15G     /var/lib/postgresql/8.3
15G     /var/lib/postgresql
15G     /var/lib
15G     /var
15G     /

Some sort of clean up I can run?
Sadly we're still on ebox 1.0 :(

J.

J. A. Calvo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1986
  • Karma: +67/-3
    • View Profile
    • http://blogs.zentyal.org/jacalvo
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #1 on: June 03, 2010, 04:29:11 pm »
Have you tried to purge the logs?
Zentyal Server Lead Developer

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #2 on: June 03, 2010, 06:29:47 pm »
eBox Logs? No, just the /var/logs
I need to reboot it first but I'll try that next.

J. A. Calvo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1986
  • Karma: +67/-3
    • View Profile
    • http://blogs.zentyal.org/jacalvo
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #3 on: June 04, 2010, 01:48:57 pm »
Yes, eBox logs are stored in PostgreSQL, you should purge them if you need space.
Zentyal Server Lead Developer

AlninlA

  • Zen Apprentice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #4 on: June 07, 2010, 02:06:48 am »
never mentioned before. thanks calvo.

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #5 on: July 05, 2010, 07:11:22 pm »
Hi,

Purging the logs didn't free up any space.

Will a VACUUM do the trick?
http://www.postgresql.org/docs/7.4/interactive/sql-vacuum.html

Not sure how I can do it though!

J.

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #6 on: July 05, 2010, 07:39:11 pm »
trying:

Code: [Select]
sudo su postgres
vacuumdb --dbname eboxlogs --full --analyze

It's, er, running.
I guess this may take some time.

J.

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #7 on: July 06, 2010, 10:35:07 am »
df shows that the disk went from 99% full to 79% full after the vacuumdb.
/var/lib/postgresql/8.3/main/base/16384 contains 12GB.

from psql:

Code: [Select]
eboxlogs=# select count(*) from firewall;
   count
-----------
 103298239
(1 row)

100 million rows! Looks like purge didn't do much :(

I'm going to do DELETE FROM firewall.

For next time, is TRUNCATE safe?

J1M.

RoboJ1M

  • Zen Monk
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #8 on: July 06, 2010, 03:40:42 pm »
Solved, needed to do:

Code: [Select]
$ sudo su postgres
$ psql

\c eboxlogs
delete from firewall;
vacuum full analyse;

12GB of space freed up.

Regards,

J1M.

naelq

  • Zen Monk
  • **
  • Posts: 65
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #9 on: July 06, 2010, 05:35:26 pm »
Yes, eBox logs are stored in PostgreSQL, you should purge them if you need space.

don't you think a 12GB of logs is too much?! shouldn't the system delete them automatically after a given period? or maybe have the option to archive/compress old logs?
with such massive growth of logs, any system is potentially unstable due to possible lack of free space!

nael

J. A. Calvo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1986
  • Karma: +67/-3
    • View Profile
    • http://blogs.zentyal.org/jacalvo
Zentyal Server Lead Developer

naelq

  • Zen Monk
  • **
  • Posts: 65
  • Karma: +0/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #11 on: July 07, 2010, 08:03:56 am »
great, but still, i don't see any size limit, which should be considered a failsafe.


nael

Saturn2888

  • Zen Hero
  • *****
  • Posts: 707
  • Karma: +1/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #12 on: July 26, 2010, 01:21:32 pm »
I was just going to note that myself. Size-limits are very important if logs are going to get that big. I've always thought my 8GB logs were huge.

cheesyking

  • Zen Warrior
  • ***
  • Posts: 148
  • Karma: +1/-0
    • View Profile
Re: Ran out of space, /var/lib/postgresql == 15GB!
« Reply #13 on: July 28, 2010, 12:16:11 am »
8GB is nothing.

I had a server set to keep proxy logs for a couple of months and noticed the free space on the drive was a lot less than I thought should be so I set the logs to purge after a week and thought nothing more of it.

a few more months later and bam, 100GB db file!

I assume there's some kind of problem where the purge command times out if the db is too big so it never purges and the problem just snowballs.

I'd agree with some way of limiting the maximum size of the logs stored in the database, ideally with some method of archiving out the old logs to a compressed file.

Postgesql's ability to keep on working until it ran out of disc space was pretty impressive though.