۱۳۹۳ فروردین ۲۵, دوشنبه

روش VACUUM کردن PostgreSQL برای خطای Stop the postmaster and use a standalone backend to vacuum database "postgres"

پیغام خطا:
WARNING: database "postgres" must be vacuumed within 999999 transactions 
HINT: To avoid a database shutdown, execute a full-database VACUUM in "postgres". 
WARNING: database "postgres" must be vacuumed within 999998 transactions 
HINT: To avoid a database shutdown, execute a full-database VACUUM in "postgres". 
WARNING: database "postgres" must be vacuumed within 999997 transactions 
HINT: To avoid a database shutdown, execute a full-database VACUUM in "postgres". 
WARNING: database "postgres" must be vacuumed within 999996 transactions 
HINT: To avoid a database shutdown, execute a full-database VACUUM in "postgres". 
WARNING: database "postgres" must be vacuumed within 999995 transactions 
HINT: To avoid a database shutdown, execute a full-database VACUUM in "postgres". 

یا

createdb: could not connect to database postgres: FATAL:  database is not accepting commands to avoid wraparound data loss in database "postgres"
HINT:  Stop the postmaster and use a standalone backend to vacuum database "postgres".

روش حل:
[you@server ~]$ su root
Password:
[root@server ~]# /etc/init.d/postgresql stop                                     #stop database
[root@server ~]# su postgres                                                            # switch user to postgres
[postgres@server ~]$ touch /tmp/fix.sql                                          #create empty file
[postgres@server ~]$ echo "VACUUM FULL;" > /tmp/fix.sql               #write command to file
[postgres@server ~]$ postgres -D /var/lib/pgsql/data YOUR_DATABASE_NAME < /tmp/fix.sql       # execute command

و در نهایت

[root@server ~]# /etc/init.d/postgresql restart