Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > contrib-testing > by-pkgid > 100a4405749023db77a1118ad0a038bd > files > 36

postgresql8.2-server-8.2.12-1mdv2009.0.x86_64.rpm

This file contains important information about PostgreSQL Mandriva's rpms.

This document is dedicated to postgres administrators and or system
administrators.
I assume you know:
  - what is postgres
  - what is database backup
  - what are and how to use pg_dump, pgdump_all and psql
  - how to backup and restore your database by hand.

If you have any doubt, please refer to postgresql documentation.

Olivier Thauvin <nanardon@mandriva.org>

* Database migration

Mandriva rpm normally automatically dump and restore your database if you are
updating postgres from a major version to another one: (eg X.a. to X.b.,
or a. to b.). The scripts normally works fine but there is too many unknown
cases that can make the update fail.

This section explain how it works since postgresql-8.1.0-1mdk, how to control
its behaviour and how to manage your data to give it a chance to work.

- functioning
  - backup: a %pretrans rpm scriptlet is run and check if the new major version
    is a different version than the one in /var/lib/pgsql/data/PG_VERSION. If 
    the major version differ, then a migration is needed.
    
    In the case migration is needed, mdk_pg script is run, see mdk_pg -h for
    more details about script itself. The script will:
    
    - backup your configuration into backups directory
    - override the pg_hba.conf to ensure local only access to the backup
    - dump all database with pg_dumpall (into a gzip compressed file)

    So after backup successfully end, all database files are moved into another
    directory to allow new database creation.

  - restoration: a %posttrans rpm scriptlet check if there is a backup from 
    %pretrans to restore, if yes, mdk_pg script is called again:

    - postgresql is started, the initscript create new database automatically
    - dump is restore with psql
    - configuration files are restored

  At this point you have finished. Notice neither backup files, neither your original
  data are deleted, only move.

- controling behaviour

The file /etc/sysconfig/pgmdk allow you to control some part of the process,
it is a shell script sourced by migration scripts.

    - deny automatic migration: set NORPMMIGRATION to 1 and the process is skipped
    leaving data untouched.
    - set BACKUPDIR to change the default backup directory (default location is
    /var/lib/pgsql/backups)

- how to configure tablespace:
    Tablespace as know by postgresql 8 and higher are supported, location on
    previous will not be moved. Anyway, postgresql 8 is unable to automatically
    translate pg location to tablespace.

    As all data directory, a directory with name suffixed by backup id is
    created, files are moved from old to the new directory:
    if your location is /foo/data, /foo/data.ID is created, files from
    /foo/data are moved into /foo/data.ID, leaving /foo/data empty and ready
    to store new database.

    A good practice is to respect the pgsql/data structure to allow data to be
    easilly moved, eg if you want a dedicated partition for your data, mount
    point should be pgsql/ and your data into subdirectory.

* Version 8.1

- pg_autovacuum
    pg_autovacuum is a daemon which monitor database and run vacuum and analyze
    when needed. Introduced as a postgresql contrib in version 8.0, mandriva rpm was
    providing an initscript to start the daemon at boot.
    This feature is now included into the backend itself, it is disabled by
    default. Set autovacuum parameter to true into postgresql.conf