Wednesday, 26 February 2025

Setting Up Apache Flink with SQL Gateway Using Podman

 

Setting Up Apache Flink with SQL Gateway Using Podman

This document outlines the steps to configure Apache Flink with SQL Gateway running in Podman containers.

Prerequisites

  • Podman installed on your machine.
  • Apache Flink image available from the Docker Hub.

Step 1: Start the JobManager Container

Run the Flink JobManager container and enable the SQL Gateway by passing environment variables:


podman run -d \ --name flink-jobmanager \ -p 8081:8081 \ # Port for the Flink Web UI -p 8082:8082 \ # Port for the SQL Gateway -e FLINK_SQL_GATEWAY_ENABLED=true \ # Enable the SQL Gateway -e FLINK_SQL_GATEWAY_PORT=8082 \ # Set the SQL Gateway port apache/flink:latest jobmanager

Step 2: Start the TaskManager Container

Run the Flink TaskManager container, linking it to the JobManager:


podman run -d \ --name flink-taskmanager \ --link flink-jobmanager:jobmanager \ # Link to the JobManager -e JOBMANAGER_HOST=jobmanager \ # Specify the JobManager host -e JOBMANAGER_PORT=8081 \ # Specify the JobManager port apache/flink:latest taskmanager

Step 3: Verify the SQL Gateway

  1. Open your web browser.
  2. Navigate to http://localhost:8082 to access the SQL Gateway web interface.

Step 4: Connect to the SQL Gateway

You can connect to the Flink SQL Gateway using a SQL client (e.g., Aqua Studio) that supports JDBC.

  • JDBC URL:


    jdbc:flink://localhost:8082
  • Username and Password: Leave these fields blank if you haven't set authentication.

Step 5: Write and Execute SQL Queries

Once connected, you can write and execute SQL queries against your Flink tables and data streams.

Example Query

You can start with a simple query like:

sql

SELECT * FROM your_table_name;

Additional Configuration (Optional)

  • Persistent Storage: To persist data, consider mounting volumes for the Flink containers.
  • Environment Variables: You can set additional environment variables for specific configurations as needed.

No comments:

Post a Comment