allow-materialize-ips.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 1. In a SQL client connected to Materialize, use the [`CREATE SECRET`](/sql/create-secret/)
  2. command to securely store the password for the `materialize` PostgreSQL user you
  3. created [earlier](#2-create-a-publication-and-a-replication-user):
  4. ```mzsql
  5. CREATE SECRET pgpass AS '<PASSWORD>';
  6. ```
  7. 1. Use the [`CREATE CONNECTION`](/sql/create-connection/) command to create a
  8. connection object with access and authentication details for Materialize to
  9. use:
  10. ```mzsql
  11. CREATE CONNECTION pg_connection TO POSTGRES (
  12. HOST '<host>',
  13. PORT 5432,
  14. USER 'materialize',
  15. PASSWORD SECRET pgpass,
  16. SSL MODE 'require',
  17. DATABASE '<database>'
  18. );
  19. ```
  20. - Replace `<host>` with your PostgreSQL endpoint.
  21. - Replace `<database>` with the name of the database containing the tables
  22. you want to replicate to Materialize.
  23. 1. Use the [`CREATE SOURCE`](/sql/create-source/) command to connect Materialize
  24. to your PostgreSQL instance and start ingesting data from the publication you
  25. created [earlier](#2-create-a-publication-and-a-replication-user):
  26. ```mzsql
  27. CREATE SOURCE mz_source
  28. IN CLUSTER ingest_postgres
  29. FROM POSTGRES CONNECTION pg_connection (PUBLICATION 'mz_source')
  30. FOR ALL TABLES;
  31. ```
  32. By default, the source will be created in the active cluster; to use a
  33. different cluster, use the `IN CLUSTER` clause. To ingest data from
  34. specific schemas or tables in your publication, use `FOR SCHEMAS
  35. (<schema1>,<schema2>)` or `FOR TABLES (<table1>, <table2>)` instead of `FOR
  36. ALL TABLES`.
  37. 1. After source creation, you can handle upstream [schema changes](/sql/create-source/postgres/#schema-changes)
  38. for specific replicated tables using the [`ALTER SOURCE...ADD SUBSOURCE`](/sql/alter-source/#context)
  39. and [`DROP SOURCE`](/sql/alter-source/#dropping-subsources) syntax.