PostgreSQL Admininistration

PostgreSQL Admininistration

install

$ su root $ yum install postgresql postgresql-server

install pgadmin somewhere, probably on your desktop

this command downloads and installs some components that make pgadmin more useful

$ yum install postgresql-contrib.i386

after that install you still need to run some SQL against your particluar DB:

psql -U postgres -d sfmaps -h localhost < /usr/share/pgsql/contrib/adminpack.sql

Set up the data directory

$ su root $ mkdir /usr/local/pgsql/data $ chown postgres /usr/local/pgsql/data

Initialize the database

$ su postgres $ initdb -D /usr/local/pgsql/data

important file system locations include

/usr/share/pgsql /usr/share/pgadmin (home of pgadmin?) /var/lib/pgsql/data/ /usr/local/pgsql/data/pg_hba.conf (configuration) /usr/local/pgsql/data (data) /usr/local/pgsql/data/pg_log (logs) /usr/local/pgsql/data/postmaster.pid (process id)

restart database server

$ /usr/bin/pg_ctl restart -l /var/lib/pgsql/logfile -D /usr/local/pgsql/data $ /usr/bin/pg_ctl --help

start database server

$ su postgres $ /usr/bin/pg_ctl start -l /var/lib/pgsql/logfile -D /usr/local/pgsql/data

stop database server

$ /usr/bin/pg_ctl stop -D /usr/local/pgsql/data

This will not stop the DB server processes if there are connections. To force the issue use something like this:

$ pg_ctl stop -m f

To reload changes made to config files:

/usr/bin/pg_ctl reload -D /usr/local/pgsql/data

running database server as a daemon process (not tested) This line

su -c '/usr/bin/pg_ctl start -l /var/lib/pgsql/serverlog -D /u01/pgsql/data' postgres

should be in this file

/etc/rc.d/rc.local

security

Once you start making non-local request to the database,
you need to tell Postgres that its OK to talk talk to stranger.
You do this by making changes to

\WindowsPath\pg_hba.conf file \LinuxPath\pg_hba.conf file

Additionally, you may need to make changes to the firewall of the OS that is hosting PostgresQL.

And in postgresql.conf, you may need to edit these lines:

listen_addresses = '*' port = 5432