|
| 1 | +--- |
| 2 | +title: DB2 Reverse ETL Setup |
| 3 | +--- |
| 4 | + |
| 5 | +Set up DB2 as your Reverse ETL source. |
| 6 | + |
| 7 | +At a high level, when you set up DB2 for Reverse ETL, the configured database user must have read permissions on any tables involved in the query, and write permissions on a managed schema (`SEGMENT_REVERSE_ETL`) that Segment uses to track sync progress. Authentication is handled through username and password credentials configured in the Segment app. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Required permissions |
| 12 | + |
| 13 | +In order to run a Reverse-ETL sync in a DB2 warehouse, Segment needs the following permissions: |
| 14 | + |
| 15 | +1. **Permission to read from all tables used in the model** (i.e., the tables included in your SELECT query). |
| 16 | +2. **Permission to create and manage a schema** for tracking sync metadata. |
| 17 | + |
| 18 | + |
| 19 | +> info "Use a dedicated user for Segment" |
| 20 | +> It's recommended to create a dedicated DB2 user for Segment with access limited to only the relevant schemas and tables. |
| 21 | +
|
| 22 | +1. Open the Db2 warehouse and navigate to **Administration > User management**. |
| 23 | +2. Click **Add**. |
| 24 | +3. Create a new user account with *user* privileges. Make sure you save the username and password, as these are required to set up the Segment configuration in a later step. |
| 25 | + |
| 26 | + |
| 27 | +> info "" |
| 28 | +> The `SEGMENT_REVERSE_ETL` schema will be created and managed by Segment to track the status of each sync. |
| 29 | +> You can also choose to create this schema yourself by running: |
| 30 | +> `CREATE SCHEMA SEGMENT_REVERSE_ETL` |
| 31 | +> and explicitly grant Segment privileges on it. |
| 32 | +
|
| 33 | + |
| 34 | + |
| 35 | +Run the below SQL commands to grant Segment the required permissions: |
| 36 | + |
| 37 | +```sql |
| 38 | +-- Grant permissions to create manage objects within the SEGMENT_REVERSE_ETL schema |
| 39 | +GRANT CREATEIN, DROPIN ON SCHEMA SEGMENT_REVERSE_ETL TO USER <username>; |
| 40 | +GRANT CREATETAB ON DATABASE TO USER <username>; |
| 41 | + |
| 42 | +-- Grant read access on each table used in the model |
| 43 | +GRANT SELECT ON TABLE <schema_name>.<table_name> TO USER <username>; |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +## Set up guide |
| 48 | + |
| 49 | +To set up DB2 as your Reverse ETL source: |
| 50 | + |
| 51 | +1. Make sure your DB2 database is network-accessible from [Segment's IPs](/docs/connections/storage/warehouses/faq/#which-ips-should-i-allowlist). |
| 52 | +2. Open [your Segment workspace](https://app.segment.com/workspaces){:target="_blank"}. |
| 53 | +3. Navigate to **Connections > Sources** and select the **Reverse ETL** tab. |
| 54 | +4. Click **+ Add Reverse ETL source**. |
| 55 | +5. Select **DB2** and click **Add Source**. |
| 56 | +6. Enter the configuration settings for your DB2 source: |
| 57 | + * Hostname: `<hostname>` |
| 58 | + * Port: `<port>` (default) |
| 59 | + * Database: `<db_name>` |
| 60 | + * Username: `<segment_db2_user>` |
| 61 | + * Password: `<password>` |
| 62 | + * Schema [optional]: If not specified, Segment will use the user’s default schema |
| 63 | +7. Click **Test Connection** to validate the setup. |
| 64 | +8. If the connection is successful, click **Add source**. |
| 65 | + |
| 66 | +> warning "" |
| 67 | +> Segment only supports user/password authentication for DB2. |
| 68 | +> Ensure that your DB2 instance is configured to allow remote connections and the user has the necessary permissions. |
| 69 | +
|
| 70 | +After you've successfully added your DB2 source, [add a model](/docs/connections/reverse-etl/setup/#step-2-add-a-model) and follow the rest of the steps in the Reverse ETL setup guide. |
0 commit comments