[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] HOWTO: Rebuild PostgreSQL 'cobalt' database due to corrupt quota table



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Can you tell me what you have done (DETAILED) because I have the
> same problems with my RAQ3I and I have also the same error message
> with DiskUsage.

HOWTO: Rebuild the PostgreSQL database "cobalt" due to corrupt quota 
table

CAUTION: This procedure completely deletes and recreates the 'cobalt' 
database. Use with care, as this database holds all the info about 
every domain on your RaQ. If you mess it up, you might as well 
reformat the drive and start over...

NOTE: This procedure should work for RaQ3 and RaQ4.  RaQ3 is the model 
with this problem, but the database is the same between the 2 
systems.


*** START OF PROCEDURE ***

MAKE IT SO THAT WE CAN GET EASIER ACCESS TO THE DATABASE:

- -  Establish shell session as root
- -  cd /home/pgsql
- -  cp pg_hba.conf pg_hba.conf.safe
- -  Edit pg_hba.conf and change "local all crypt" to "local all trust"
- -  su - postgres
- -  psql cobalt

CONFIRM THE ERROR:

- -  At "cobalt=>" prompt type "SELECT * FROM quota;" and press Enter.

   If you see "ERROR:  cannot find attribute 1 of relation quota" then 
the quota table is corrupt

   If you do not get an error, STOP. The quota table is not the 
problem.

- -  \q (to exit psql tool)

SAVE THE DATABASE SCHEMA:

- -  pg_dump cobalt > cobalt-schema

REMOVE THE QUOTA STUFF (SINCE IT'S BROKEN ANYWAY):

- -  Edit 'cobalt-schema' and remove the 'CREATE TABLE "quota" ( );" 
section (spread over 2-3 lines)
- -  Remove the 'COPY "quota" FROM stdin;' line (end of schema file)
- -  Exit editor and save changes

TAKE DEEP BREATH AND DESTROY EXISTING (but corrupt) 'cobalt' DATABASE:

- -  destroydb cobalt
- -  createdb cobalt

REBUILD THE 'cobalt' DATABASE FROM THE SCHEMA FILE:

- -  psql cobalt < cobalt-schema
- -  exit (to become root again)

RUN SCRIPT TO REBUILD QUOTA TABLE:

- -  /usr/local/sbin/swatch

CHECK TO MAKE SURE IT WORKED:

- -  su - postgres
- -  psql cobalt
- -  SELECT * FROM quota;
        You should not get an error message this time...
- -  \q

- -  Go into the UI and try stuff to make sure UI works too

- -  exit (to become root)

CLEAN EVERYTHING UP:

- -  rm cobalt-schema
- -  mv pg_hba.conf.safe pg_hba.conf

*** END OF PROCEDURE ***

- -- 
Bruce Timberlake

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE985K5vLA2hUZ9kgwRAvCKAJ9VEeQ5o03ocvGFWbQQE71DNOaHxwCfQANE
JbfmngZPrFLt4IKAxxaH6AU=
=5Wag
-----END PGP SIGNATURE-----