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
wal_level logical The level of theinformation being written to the WAL. The value logical is required to enable log-based replication.
max_wal_senders 5 (at least) The number of processes that can simultaneously transmit the WAL log. The default value is 0.
max_replication_slots Any whole number between 1 and 10 The number of replication slots that can connect to the server.

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
Jun-14-2021 1.65 Updated the Grant Privileges to the User section to include latest commands.
Last updated on 13 Jun 2021