Installing the psycopg2 Python package for PostgreSQL database on a FIPS cluster (RHEL 8)

If you use PostgreSQL as a backend database for Hue on a FIPS cluster, you must install a version of the psycopg2 package from the source to be at least 2.9.5 on all Hue hosts because the psycopg2-binary package uses its version of the libssl library file which does not support FIPS.

  1. Uninstall the preinstalled psycopg2 or psycopg2-binary packages.
  2. Download and install the PostgreSQL database using the following commands:
    dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    dnf install -y postgresql[***DATABASE-VERSION***]-server  // if you omit the db_version it defaults to 12
    yum install -y postgresql[***DATABASE-VERSION***]-devel

    Replace [***DATABASE-VERSION***] with the actual database version you are want to insta;;. For example, 16.

  1. SSH into the Hue host as a root user.
  2. Download the psycopg2 package as follows:
    wget https://files.pythonhosted.org/packages/d1/1e/b450599a27b1809bccbd4e369f397cb18dc56b875778d961f9ae180b54b7/psycopg2-2.9.3.tar.gz
  3. Extract the tarball as follows:
    tar -xzvf psycopg2-2.9.3.tar.gz
  4. Locate the pg_config executable file as follows:
    find / -name pg_config
  5. Add the directory containing the pg_config file to the $PATH variable:
    export PATH="/usr/pgsql-[***DATABASE-VERSION***]/bin:$PATH"
  6. Build and install the psycopg2 package as follows:
    /usr/bin/python3.8 setup.py build_ext --pg-config=/usr/pgsql-[***DATABASE-VERSION***]/bin/pg_config install