Skip to content

Files

128 lines (119 loc) · 3.42 KB

proc_installing-postgresql.adoc

File metadata and controls

128 lines (119 loc) · 3.42 KB

Installing PostgreSQL

You can install only the same version of PostgreSQL that is installed with the {foreman-installer} tool during an internal database installation. {Project} supports PostgreSQL version 12.

Procedure
  1. To install PostgreSQL, enter the following command:

    # dnf install postgresql-server
  2. To initialize PostgreSQL, enter the following command:

    # postgresql-setup initdb
  3. Edit the {postgresql-conf-dir}/postgresql.conf file:

    # vi {postgresql-conf-dir}/postgresql.conf

    Note that the default configuration of external PostgreSQL needs to be adjusted to work with {Project}. The base recommended external database configuration adjustments are as follows:

    • checkpoint_completion_target: 0.9

    • max_connections: 500

    • shared_buffers: 512MB

    • work_mem: 4MB

  4. Remove the # and edit to listen to inbound connections:

    listen_addresses = '*'
  5. Edit the {postgresql-conf-dir}/pg_hba.conf file:

    # vi {postgresql-conf-dir}/pg_hba.conf
  6. Add the following line to the file:

      host  all   all   {Project}_ip/32   md5
  7. To start, and enable PostgreSQL service, enter the following commands:

    # systemctl enable --now postgresql
  8. Open the postgresql port on the external PostgreSQL server:

    # firewall-cmd --add-service=postgresql
    # firewall-cmd --runtime-to-permanent
  9. Switch to the postgres user and start the PostgreSQL client:

    $ su - postgres -c psql
  10. Create three databases and dedicated roles: one for {Project}, one for Candlepin, and one for Pulp:

    CREATE USER "foreman" WITH PASSWORD 'Foreman_Password';
    CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password';
    CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password';
    CREATE DATABASE foreman OWNER foreman;
    CREATE DATABASE candlepin OWNER candlepin;
    CREATE DATABASE pulpcore OWNER pulp;
  11. Connect to the Pulp database:

    postgres=# \c pulpcore
    You are now connected to database "pulpcore" as user "postgres".
  12. Create the hstore extension:

    pulpcore=# CREATE EXTENSION IF NOT EXISTS "hstore";
    CREATE EXTENSION
  13. Exit the postgres user:

    # \q
  14. From {ProjectServer}, test that you can access the database. If the connection succeeds, the commands return 1.

    # PGPASSWORD='Foreman_Password' psql -h postgres.example.com  -p 5432 -U foreman -d foreman -c "SELECT 1 as ping"
    # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping"
    # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"