12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 1. In the [SQL Shell](https://console.materialize.com/), or your preferred SQL
- client connected to Materialize, use the [`CREATE CONNECTION`](/sql/create-connection/#ssh-tunnel)
- command to create an SSH tunnel connection:
- ```mzsql
- CREATE CONNECTION ssh_connection TO SSH TUNNEL (
- HOST '<SSH_BASTION_HOST>',
- PORT <SSH_BASTION_PORT>,
- USER '<SSH_BASTION_USER>'
- );
- ```
- - Replace `<SSH_BASTION_HOST>` and `<SSH_BASTION_PORT`> with the public IP address and port of the SSH bastion host you created [earlier](#b-optional-configure-network-security).
- - Replace `<SSH_BASTION_USER>` with the username for the key pair you created for your SSH bastion host.
- 1. Get Materialize's public keys for the SSH tunnel connection:
- ```mzsql
- SELECT * FROM mz_ssh_tunnel_connections;
- ```
- 1. Log in to your SSH bastion host and add Materialize's public keys to the `authorized_keys` file, for example:
- ```sh
- # Command for Linux
- echo "ssh-ed25519 AAAA...76RH materialize" >> ~/.ssh/authorized_keys
- echo "ssh-ed25519 AAAA...hLYV materialize" >> ~/.ssh/authorized_keys
- ```
- 1. Back in the SQL client connected to Materialize, validate the SSH tunnel connection you created using the [`VALIDATE CONNECTION`](/sql/validate-connection) command:
- ```mzsql
- VALIDATE CONNECTION ssh_connection;
- ```
- If no validation error is returned, move to the next step.
- 1. Use the [`CREATE SECRET`](/sql/create-secret/) command to securely store the password for the `materialize` SQL Server user [you created](#1-create-a-materialize-user-in-sql-server):
- ```mzsql
- CREATE SECRET sql_server_pass AS '<PASSWORD>';
- ```
- For AWS IAM authentication, you must create a connection to AWS. See the [`CREATE CONNECTION`](/sql/create-connection/#aws) command for details.
- 1. Use the [`CREATE CONNECTION`](/sql/create-connection/) command to create another connection object, this time with database access and authentication details for Materialize to use:
- ```mzsql
- CREATE CONNECTION sql_server_connection TO SQL SERVER (
- HOST '<host>',
- SSH TUNNEL ssh_connection
- );
- ```
- - Replace `<host>` with your SQL Server endpoint.
- 1. Use the [`CREATE SOURCE`](/sql/create-source/) command to connect Materialize to your SQL Server instance and start ingesting data:
- ```mzsql
- CREATE SOURCE mz_source
- FROM SQL SERVER CONNECTION sql_server_connection
- FOR ALL TABLES;
- ```
- - By default, the source will be created in the active cluster; to use a
- different cluster, use the `IN CLUSTER` clause.
- - To ingest data from specific schemas or tables, use the `FOR SCHEMAS
- (<schema1>,<schema2>)` or `FOR TABLES (<table1>, <table2>)` options
- instead of `FOR ALL TABLES`.
- - To handle unsupported data types, use the `TEXT COLUMNS` or `IGNORE
- COLUMNS` options. Check out the [reference documentation](/sql/create-source/sql-server/#supported-types)
- for guidance.
|