First we'd like to thank Devrim of Command Prompt for working hard on making this new YUM repository available. In this article we will go over using the new PostgreSQL YUM repository for Redhat Fedora, Enterprise Linux and CentOS distros that is available at http://yum.pgsqlrpms.org/.
UPDATE - since Devrim's move from Command prompt - he has started a new yum repository. You may want to use
this one instead since it seems more up to date than the other. http://yum.pgrpms.org/.
We are gearing the content of this article to the described user profile
NOTE: We have a newer article on Installing PostgreSQL 8.4 with Yum and an even newer one for PostgreSQL 9.0 please refer to Installing PostgreSQL 9.0 via Yum. This old article is for PostgreSQL 8.3.
uname –a
vi /etc/redhat-release
If you are running a prior version of PostgreSQL, most likely it was installed in the /usr/local/pgsql/ folder. The first thing you want to do if you care about your data is to back it up with commands similar to the below.
mkdir dbbackup
cd dbbackup
/usr/local/pgsql/bin/pg_dumpall –U postgres postgresqlserverdbs.sql
You may also want to download the backup if its really important to you and in case you screw up the server
really badly.
su postgres
/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data
mv /usr/local/pgsql /usr/local/pgsqlold
wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-redhat-8.3-4.noarch.rpm
rpm -ivh pgdg-redhat-8.3-2.noarch.rpm
yum install postgresql
yum install postgresql-devel
yum install postgresql-server
yum install postgis
yum install pgadmin3
yum install postgresql-contrib
mkdir /usr/local/pgsql
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su postgres
initdb –D /usr/local/pgsql/data
cd /usr/local/pgsql/data
cp /usr/local/pgsqlold/data/pg_hba.conf /usr/local/pgsql/data
emacs /etc/rc.d/init.d/postgresql
service postgresql start
chkconfig --list (to see list of services)
chkconfig postgresql on
the chkconfig on thing automatically copies symlinks to those rc.1 , rc.n locations that linux looks for in bootup. If
you don't have chkconfig on your box for some reason, you have to manually copy those symlinks to the right locations - a pain.
The PgAdmin pack comes with PgAdmin3. This comes in handy if you use PgAdmin3 a lot as it gives you stats activity, and allows you to change pg_hba.conf and postgresql.conf files directly from PgAdmin3 even if accessing from a different computer
psql -U postgres -d postgres -f /usr/share/pgsql/contrib/adminpack.sql