Having installed PostgreSQL 9.1 on my ec2 instance (Amazon Linux) following these instructions, I wanted to experiment with a few contrib modules. However, this process was not trivial, mainly because the installed postgres distribution did not have the contrib modules by default. Here's what I did :
- Checking if the modules exist :
- cd /usr/pgsql-9.1/share/extension
- Only plpgsql seems to be there.
- Extensions don't exist, preparing to install contrib. Check the specific postgres version first :
- sudo su -
- su - postgres
- /usr/pgsql-9.1/bin/psql -p 5432
- postgres=# select version();version---------------------------------------------------------------------------------------------------------------PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54), 64-bit(1 row)
- Installing contrib :
- sudo yum install postgresql91-contrib
Error: Package: postgresql91-contrib-9.1.10-1PGDG.rhel5.x86_64 (pgdg91)
Requires: libossp-uuid.so.15()(64bit) - Whoops! Fixing errors and try installing again :
- Downloaded the required rpm file from the following link.
- wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/nick_at_seakr:/epel/RedHat_RHEL-5/x86_64/uuid-1.5.1-5.1.x86_64.rpm
- rpm -Uvh libossp-uuid.so.15 (instructions found here)
- Success! Checking "/usr/pgsql-9.1/share/extension" indeed shows that the modules were installed. What extensions are installed on my current database?
- sudo su -
- su - postgres
- /usr/pgsql-9.1/bin/psql -p 5432
- postgres=# select * from pg_extension;extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition---------+----------+--------------+----------------+------------+-----------+--------------plpgsql | 10 | 11 | f | 1.0 | |(1 row)
- You can use "postgres=# \dx" instead of the select statement if you want. Anyway, it looks like only plpgsql is installed.
- Let us install some other extensions. These are installed on the current database by default.
- postgres=# create extension pg_trgm;CREATE EXTENSION
- postgres=# create extension hstore;CREATE EXTENSION
- postgres=# \dxList of installed extensionsName | Version | Schema | Description---------+---------+------------+-------------------------------------------------------------------hstore | 1.0 | public | data type for storing sets of (key, value) pairspg_trgm | 1.0 | public | text similarity measurement and index searching based on trigramsplpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language(3 rows)
Extra information :
- How to change the current database :
- postgres=# \connect foobarpsql (9.1.10, server 9.1.9)You are now connected to database "foobar" as user "postgres".
- How to check the current database :
- postgres=# select current_database();current_database------------------postgres(1 row)
- But I don't know why you'd need that in this case since you can check the database name in the prompt itself.
- Here's a list of modules to explore.
- What I ended up installing :
- foobar=# \dxList of installed extensionsName | Version | Schema | Description--------------------+---------+------------+-------------------------------------------------------------------hstore | 1.0 | public | data type for storing sets of (key, value) pairspg_stat_statements | 1.0 | public | track execution statistics of all SQL statements executedpg_trgm | 1.0 | public | text similarity measurement and index searching based on trigramspgstattuple | 1.0 | public | show tuple-level statisticsplpgsql | 1.0 | pg_catalog | PL/pgSQL procedural languageuuid-ossp | 1.0 | public | generate universally unique identifiers (UUIDs)(6 rows)
No comments:
Post a Comment