Generic PostgreSQL

PostgreSQL is a highly stable database management system, used as the primary data store or data warehouse for many web, mobile, geospatial, and analytics applications. Generic PostgreSQL represents a self-hosted PostgreSQL server.

You can ingest data from your PostgreSQL database using Hevo Pipelines and replicate it to a Destination of your choice.

Prerequisites


Perform the following steps to configure your Generic PostgreSQL Source:

Set up Log-based Incremental Replication

Hevo supports data ingestion replication from PostgreSQL servers via Write Ahead Logs (WALs) set at the logical level (available on PostgreSQL version 9.4 and above).

A WAL is a collection of log files that record information about data modifications and data object modifications made on a PostgreSQL server instance. Typically, WAL is used for data replication and data recovery.

To configure logical replication, enable WAL on the self-hosted (generic) PostgreSQL server:

1. Update the client authentication file

Modify the PostgreSQL configuration file, postgresql.conf, generally found in /etc/postgresql/\<version\>/main/ directory in the Linux system.

Parameter Value Description
max_replication_slots Any whole number between 1 and 10 The number of clients that can connect to the server. Default value: 10.
max_wal_senders 10 The number of processes that can simultaneously transmit the WAL log. Default value: 10.
wal_level logical The amount of information being written to the WAL log. For example, minimal, replica, or logical. Default value: replica. The value logical is required to enable log-based replication.
wal_sender_timeout 0 The time, in seconds, after which PostgreSQL terminates the replication connections due to inactivity. Default value: 60 seconds. You must set the value to 0 so that the connections are never terminated and your Pipeline does not fail.
You can use the following query to check the value configured for the parameter:
show wal_sender_timeout

2. Update the PostgreSQL database configuration file

In the postgresql.conf file, assign permission to the database user to connect from an external network to the PostgreSQL server:

  local replication <user> peer

  host replication <user> 127.0.0.1/0 md5

  host replication <user> ::1/0 md5

Note: Remember to replace <user> with your intended user.

3. Enable access to WALs

Once you have successfully completed the above steps, do the following:

  1. Restart the PostgreSQL server.

  2. Provide access to the WAL for the database user:

     alter role <user> with replication;
    
     alter role <user> with login;
    

    Note: Remember to replace <user> with your intended user.


Whitelist Hevo’s IP Addresses

You need to whitelist the Hevo IP addresses for your region to enable Hevo to connect to your PostgreSQL database. To do this:

  1. Log in to the PostgreSQL server as a Superuser.

  2. Navigate to the PostgreSQL configuration file, pg_hba.conf. This file is generally found in the path: /etc/postgresql/<version>/main/.

  3. Add the Hevo IP addresses for your region or 0.0.0.0 to allow all IPs to connect:

     host    all             user_name           0.0.0.0/0              md5
    

Grant Privileges to the User

Grant privileges to the database user connecting to the PostgreSQL database as follows:

  1. Connect to your PostgreSQL database instance.

  2. (Optional) View existing users and their privileges in your PostgreSQL instance:

     psql -U postgres
    
     \du
    

    User privileges

    If the privileges are not assigned, perform Step 3.

  3. Grant the required privileges to the user:

     GRANT CONNECT ON DATABASE <database_name> TO <database_username>;
     GRANT USAGE ON SCHEMA <schema_name> TO <database_username>;
     GRANT SELECT ON DATABASE <database_name> TO <database_username>;
    
  4. Alter the schema’s default privileges to grant SELECT privileges on tables to the database user:

     ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>;
     GRANT SELECT ON TABLES TO <database_username>;
    

Limitations

  • The data type Array in the Source is automatically mapped to Varchar at the Destination. No other mapping is currently supported.

See Also


Revision History

Refer to the following table for the list of key updates made to this page:

Date Release Description of Change
Jan-24-2022 1.80 Removed from Limitations that Hevo does not support UUID datatype as primary key.
Dec-20-2021 1.78 Updated section, Update the client authentication file.
Sep-09-2021 1.71 Updated the section, Limitations to include information about columns with the UUID data type not being supported as a primary key.
Jun-14-2021 1.65 Updated the Grant Privileges to the User section to include latest commands.
Last updated on 22 Mar 2022