Panel requires Postgresql 7.3.x or later. 7.2.x will not work.Step 1
Upgrade to cPanel 7.4.0 build 45 or later
Step 1a (If you do not have 7.2.x or earlier installed skip this step)
Login to a root shell via ssh or the console.
If you have Postgres 7.2.x installed, backup your databases using pg_dumpall or some other method.
Move the postgres data directory somewhere else. ie
mv /var/lib/pgsql /var/lib/pgsql.old
Step 2
Login to a root shell via ssh or the console and run
/scripts/installpostgres
>Step 2a (skip this step if you are not upgrading from postgres 7.2 or earlier
>Restore your sql dump created with pg_dumpall or by some other method using psql or some other method
Step 3
Login to Web Host Manager and choose “Postgres Config” under Server Setup.
Set a postgres password to anything of your choosing. You should avoid using any non-alpha numeric charaters as these cause problems.
Step 4
>Use the “Postgres Config” option in WHM to install a postgres pg_hba.conf file. You can skip this step if you would like to setup your pg_hba.conf file manually. cPanel should work fine with md5 passwords or plaintext passwords
Step 5
Login to cPanel and click on Postgres .. Enjoy!
Showing posts with label postgresql. Show all posts
Showing posts with label postgresql. Show all posts
Upgrading PostgreSQL
Posted by Unknown at 19:19 0 comments
To upgrade a PostgreSQL installation start by dumping all the existing databases. You should do this before stopping the current database server
$ PGUSER=postgres /usr/bin/pg_dumpall > dump.sql
$ sudo /etc/init/d/postgresql stop
$ sudo mv /usr/local/pgsql /usr/local/pgsql.old
Build and install your new version. Be sure to create a PGDATA directory that is owned by the postgres user. Initialize the PGDATA directory with initdb
$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
Once you have created your new database, start the new database server and populate the new database with the data you dumped from your old system:
$ sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/psql -d postgres -f dump.sql
$ PGUSER=postgres /usr/bin/pg_dumpall > dump.sql
$ sudo /etc/init/d/postgresql stop
$ sudo mv /usr/local/pgsql /usr/local/pgsql.old
Build and install your new version. Be sure to create a PGDATA directory that is owned by the postgres user. Initialize the PGDATA directory with initdb
$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
Once you have created your new database, start the new database server and populate the new database with the data you dumped from your old system:
$ sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/psql -d postgres -f dump.sql
Howto Install PostgreSQL 8.4 Database Server on CentOS, Fedora, Red Hat
Posted by Unknown at 16:00 0 comments
This is quick guide howto install PostgreSQL 8.4 (current stable 8.4.2) database server on CentOS, Fedora and Red Hat. Fedora 12 has PostgreSQL 8.4 database server as default so extra repositories is not needed on Fedora 12. The following commands run as root and postgres user, so “su -” or “sudo -i” first.
Install PostgreSQL 8.4 Database Server
Install PostgreSQL repository:
## CentOS
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-1.noarch.rpm
## Fedora (Not needed on Fedora 12)
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-fedora-8.4-1.noarch.rpm
## Red Hat
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-redhat-8.4-1.noarch.rpm
Install postgresql and postgresql-server packages:
yum install postgresql postgresql-server
Configure PostgreSQL 8.4 Database Server
Initialize the cluster first with initdb command:
service postgresql initdb
## OR ##
/etc/init.d/postgresql initdb
Edit /var/lib/pgsql/data/postgresql.conf file:
nano -w /var/lib/pgsql/data/postgresql.conf
Set PostgreSQL server to listen all addresses. Add/Uncomment/Edit following lines:
listen_addressses = '*'
port = 5432
Edit /var/lib/pgsql/data/pg_hba.conf file:
nano -w /var/lib/pgsql/data/pg_hba.conf
Add (example) your local network with md5 passwords:
# Local networks
host all all xx.xx.xx.xx/xx md5
# Example
host all all 10.20.4.0/24 md5
Start/Restart PostgreSQL Server:
service postgresql start
## OR ##
/etc/init.d/postgresql start
Change to postgres user:
su postgres
Create test database (as postgres user):
createdb test
Login test database (as postgres user):
psql test
Create New “testuser” Role with Superuser and Password:
CREATE ROLE testuser WITH SUPERUSER LOGIN PASSWORD='test';
Open PostgreSQL Port (5432) on Iptables Firewall (as root user again)
Edit /etc/sysconfig/iptables file:
nano -w /etc/sysconfig/iptables
Add following line before COMMIT:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
Restart Iptables Firewall:
service iptables restart
## OR ##
/etc/init.d/iptables restart
Test remote connection:
psql -h dbserver -U testuser test
Install PostgreSQL 8.4 Database Server
Install PostgreSQL repository:
## CentOS
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-1.noarch.rpm
## Fedora (Not needed on Fedora 12)
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-fedora-8.4-1.noarch.rpm
## Red Hat
rpm -Uvh http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-redhat-8.4-1.noarch.rpm
Install postgresql and postgresql-server packages:
yum install postgresql postgresql-server
Configure PostgreSQL 8.4 Database Server
Initialize the cluster first with initdb command:
service postgresql initdb
## OR ##
/etc/init.d/postgresql initdb
Edit /var/lib/pgsql/data/postgresql.conf file:
nano -w /var/lib/pgsql/data/postgresql.conf
Set PostgreSQL server to listen all addresses. Add/Uncomment/Edit following lines:
listen_addressses = '*'
port = 5432
Edit /var/lib/pgsql/data/pg_hba.conf file:
nano -w /var/lib/pgsql/data/pg_hba.conf
Add (example) your local network with md5 passwords:
# Local networks
host all all xx.xx.xx.xx/xx md5
# Example
host all all 10.20.4.0/24 md5
Start/Restart PostgreSQL Server:
service postgresql start
## OR ##
/etc/init.d/postgresql start
Change to postgres user:
su postgres
Create test database (as postgres user):
createdb test
Login test database (as postgres user):
psql test
Create New “testuser” Role with Superuser and Password:
CREATE ROLE testuser WITH SUPERUSER LOGIN PASSWORD='test';
Open PostgreSQL Port (5432) on Iptables Firewall (as root user again)
Edit /etc/sysconfig/iptables file:
nano -w /etc/sysconfig/iptables
Add following line before COMMIT:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
Restart Iptables Firewall:
service iptables restart
## OR ##
/etc/init.d/iptables restart
Test remote connection:
psql -h dbserver -U testuser test
How to find the PostgreSQL database size
Posted by Unknown at 20:20 0 commentsPostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
If you want to find the size of a database, in our example the sqview database, please tape:
sqview-# SELECT pg_database_size(’sqview’);
pg_database_size
——————
111415944
(1 ligne)
The result in octal, for a pretty print we will use the pg_size_pretty function which converts the size in bytes to human understandable format.
sqview-# SELECT pg_size_pretty(pg_database_size(’sqview’));
pg_size_pretty
—————-
106 MB
(1 ligne)
Well if we need to get the size of all databases
sqview-# SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;
datname | size
———–+———
postgres | 3537 kB
template1 | 3537 kB
template0 | 3480 kB
freedom | 25 MB
anakeen | 6081 kB
sqview | 106 MB
rt | 8201 kB
(7 lignes)
PostgreSQL can also give the size of a table ‘users’ like this
sqview-# SELECT pg_size_pretty(pg_relation_size(‘users’));
pg_size_pretty
—————-
64 kB
(1 ligne)
This value exclude indexes and some auxiliary data.
If you want to include them use pg_total_relation_size instead of pg_relation_size as shown below.
sqview-# SELECT pg_size_pretty(pg_total_relation_size(‘users’));
pg_size_pretty
—————-
152 kB
(1 ligne)
to find the largest table in the postgreSQL database.
sqview-# SELECT relname, relpages FROM pg_class ORDER BY relpages DESC limit 1;
relname | relpages
———+———-
sqview | 9666
(1 ligne)
Subscribe to:
Posts (Atom)