3

I'm in the process of creating a postgres database for production in CentOS 7. So I already installed (yum install postgresql10-server postgresql10 after adding the repos of course) and configured postgres 10. However, in my scripts I need to install pgcrypto extension and I haven't successfully install it. This is what I've done so far:

  1. the first error I got was saying that the /usr/pgsql-10/share/extension/pgcrypto.control files does not exist. Googling I realized that I have to install postgres-contrib package, which I did and then restarted postgres service, but the error continues due to the fact that the extensions were installed into /usr/share/pgsql/extension, so I copied the extension files from they were installed to they were expected and then
  2. appears this message

    "ERROR: could not access file "$libdir/pgcrypto": No such file or directory"

    Googling again I found that maybe I need to give another option, so I ran CREATE EXTENSION pgcrypto FROM unpackaged; then

  3. the error message now is

    ERROR: function digest(text, text) does not exist

And I'm stuck and without any idea what to do next. Is anybody else using this extension in postgres 10 on Linux?, if so, how did you create the extension?

Version info: PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit

Paul White
  • 94,921
  • 30
  • 437
  • 687
George
  • 33
  • 1
  • 1
  • 5

4 Answers4

3

From the docs on CREATE EXTENSION

PostgreSQL will create the extension using details from the file SHAREDIR/extension/extension_name.control.

You need to check what SHAREDIR is set to with pg_config --sharedir. If that's not set to /usr/share/pgsql/extension then likely your postgresql-contrib was packaged by someone different than your copy of postgresql. These are compile time variables and they should be the same. Moving them in likely won't work either because if these are packaged by two separate entities they're likely built against different libraries.

CentOS

In your case I assume

  1. You're installing the PostgreSQL from the PostgreSQL repos.
  2. You're installing the -contrib from the CentOS repos.

What you probably want to do is install from the CentOS repos. Uninstall all things related to PostgreSQL, and delete those files you copied or linked and run this

# Adds the PostgreSQL repo
rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

# I think this should install them explicitly from the PostgreSQL repo
rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/postgresql10-10.1-1PGDG.rhel7.x86_64.rpm
rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/postgresql10-contrib-10.1-1PGDG.rhel7.x86_64.rpm
Evan Carroll
  • 65,432
  • 50
  • 254
  • 507
1

Since you already installed postgresql using yum, all you have to do is to install the -contrib. Keep in mind you still need to delete those files you copied or linked, then run this command.

yum install postgresql10-contrib

Terry
  • 11
  • 2
1

What worked for me is first this in bash shell:

sudo yum install postgresql10-contrib

Then in postgres:

CREATE EXTENSION pgcrypto;

scottlittle
  • 130
  • 4
1

This worked on our Centos 8 device.

[root~]$ sudo yum install postgresql-contrib

Last metadata expiration check: 0:02:07 ago on Wed 28 Oct 2020 02:37:38 UTC. Dependencies resolved. ============================================================================================================= Package Architecture Version Repository Size ============================================================================================================= Installing: postgresql-contrib x86_64 10.14-1.module_el8.2.0+487+53cc39ce AppStream 804 k Installing dependencies: uuid x86_64 1.6.2-42.el8 AppStream 63 k

Transaction Summary

Install 2 Packages

Total download size: 867 k Installed size: 2.7 M Is this ok [y/N]: y Downloading Packages: (1/2): uuid-1.6.2-42.el8.x86_64.rpm 81 kB/s | 63 kB 00:00
(2/2): postgresql-contrib-10.14-1.module_el8.2.0+487+53cc39ce.x86_64.rpm 361 kB/s | 804 kB 00:02


Total 325 kB/s | 867 kB 00:02
Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : uuid-1.6.2-42.el8.x86_64 1/2 Running scriptlet: uuid-1.6.2-42.el8.x86_64 1/2 Installing : postgresql-contrib-10.14-1.module_el8.2.0+487+53cc39ce.x86_64 2/2 Running scriptlet: postgresql-contrib-10.14-1.module_el8.2.0+487+53cc39ce.x86_64 2/2 Verifying : postgresql-contrib-10.14-1.module_el8.2.0+487+53cc39ce.x86_64 1/2 Verifying : uuid-1.6.2-42.el8.x86_64 2/2

Installed: postgresql-contrib-10.14-1.module_el8.2.0+487+53cc39ce.x86_64 uuid-1.6.2-42.el8.x86_64

Complete!

su - postgres Last login: Wed Oct 28 02:13:45 UTC 2020 on pts/0 [postgres~]$ psql psql (10.14) Type "help" for help.

postgres=# CREATE EXTENSION pgcrypto; CREATE EXTENSION