How to Deploy Flink Services Independently
Flink is an extension module in the HAP system. Users can choose whether to enable it according to their needs. For quick deployment guidelines, refer to Deploy Flink Services.
Quick deployment involves deploying Flink services on the same server as HAP microservices, requiring high availability of hardware resources. If a single server cannot meet the requirements, you can follow this document to deploy Flink services independently on a new server. Refer to Standalone Flink Server Configuration for server configuration details.
Install Docker
To install Docker, refer to the official installation instructions for different Linux distributions or check the Docker installation section in the deployment examples.
Check if the Current HAP Service Includes an Independent MinIO Service
On the HAP server, execute the following command to check if the output contains a line with the keyword start minio:
docker logs $(docker ps | grep sc | awk '{print $1}') | grep minio
- If output exists, it indicates the presence of an independent MinIO service.
- If no output exists, it means no independent MinIO service is available.
Adjustments to HAP Microservices
- Independent MinIO Service Available
- No Independent MinIO Service
Flink Services require access to MinIO, Kafka, and MongoDB services. If operating under single-node mode, you need to map the ports of these three services from the storage component container. In cluster mode, no adjustments are necessary.
Please refer to the configuration example below to modify the docker-compose.yaml file:
-
Add port mappings for MinIO, Kafka, and MongoDB services.
Flink needs access to MongoDB services for the aggregation table functionality. If you do not use the aggregation table functionality, you can skip the MongoDB port mapping.
If you plan to expose the MongoDB port, note that the MongoDB service integrated in single-node mode does not have authentication enabled by default. Before taking any actions, review the Data Security documentation carefully.
-
Configure the environment variables for HAP to connect to the Flink service.
app:
environment:
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
sc:
ports:
- 9010:9010 # Newly added MinIO port mapping
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mappingExample docker-compose.yaml Configuration File
- AMD64
- ARM64
version: '3'
services:
app:
image: nocoly/hap:7.2.4
environment: &app-environment
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "7.2.4"
ENV_API_TOKEN: "******"
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
ports:
- 8880:8880
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
sc:
image: nocoly/sc:3.2.0
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9010:9010 # Newly added MinIO port mapping
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mappingversion: '3'
services:
app:
image: nocoly/hap-arm64:-
environment: &app-environment
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "-"
ENV_API_TOKEN: "******"
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
ports:
- 8880:8880
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
sc:
image: nocoly/sc-arm64:-
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9010:9010 # Newly added MinIO port mapping
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mapping
After modification, execute bash service.sh restartall in the Installation Manager directory to restart the microservices for changes to take effect.
Flink Services require access to MinIO, Kafka, and MongoDB services. However, if the deployed version is older and does not include a built-in MinIO service, only the ports for Kafka and MongoDB need to be mapped from the storage component container. In cluster mode, no adjustments are necessary.
Please refer to the configuration example below to modify the docker-compose.yaml file:
-
Add port mappings for Kafka and MongoDB services.
Flink needs access to MongoDB services for the aggregation table functionality. If you do not use the aggregation table functionality, you can skip the MongoDB port mapping.
If you plan to expose the MongoDB port, note that the MongoDB service integrated in single-node mode does not have authentication enabled by default. Before taking any actions, review the Data Security documentation carefully.
-
Configure the environment variables for HAP to connect to the Flink service.
app:
environment:
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
sc:
ports:
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mappingExample docker-compose.yaml Configuration File
- AMD64
- ARM64
version: '3'
services:
app:
image: nocoly/hap:7.2.4
environment: &app-environment
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "7.2.4"
ENV_API_TOKEN: "******"
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
ports:
- 8880:8880
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
sc:
image: nocoly/sc:3.2.0
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mappingversion: '3'
services:
app:
image: nocoly/hap-arm64:-
environment: &app-environment
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "-"
ENV_API_TOKEN: "******"
ENV_FLINK_URL: http://192.168.10.30:58081 # Newly added. Specify the Flink service URL. Update the IP address accordingly.
ports:
- 8880:8880
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
sc:
image: nocoly/sc-arm64:-
environment:
<<: *app-environment
volumes:
- ./volume/data/:/data/
ports:
- 9092:9092 # Newly added Kafka port mapping
- 27017:27017 # Newly added MongoDB port mapping
After modification, execute bash service.sh restartall in the Installation Manager directory to restart the microservices for changes to take effect.
Flink Service Deployment
- Standalone MinIO Service
- No Standalone MinIO Service
-
Initialize the swarm environment:
docker swarm init -
Create directories:
mkdir -p /data/hap/script/volume/data -
Download the Flink image (Offline package download):
- AMD64
- ARM64
docker pull nocoly/flink:1.19.720docker pull nocoly/flink-arm64:- -
Create the configuration file:
- AMD64
- ARM64
cat > /data/hap/script/flink.yaml <<EOF
version: '3'
services:
flink:
image: nocoly/flink:1.19.720
entrypoint: ["/bin/bash"]
command: ["/run.sh"]
environment:
ENV_FLINK_S3_ACCESSKEY: "mdstorage"
ENV_FLINK_S3_SECRETKEY: "eBxExGQJNhGosgv5FQJiVNqH"
ENV_FLINK_S3_SSL: "false"
ENV_FLINK_S3_PATH_STYLE_ACCESS: "true"
ENV_FLINK_S3_ENDPOINT: "sc:9010"
ENV_FLINK_S3_BUCKET: "mdoc"
ENV_FLINK_LOG_LEVEL: "INFO"
ENV_FLINK_JOBMANAGER_MEMORY: "4096m"
ENV_FLINK_TASKMANAGER_MEMORY: "16384m"
ENV_FLINK_TASKMANAGER_SLOTS: "50"
ENV_KAFKA_ENDPOINTS: "sc:9092"
ports:
- 58081:8081
volumes:
- ./volume/data/:/data/
extra_hosts:
- "sc:192.168.10.28" # Update this to the actual internal IP address of the HAP server
EOFcat > /data/hap/script/flink.yaml <<EOF
version: '3'
services:
flink:
image: nocoly/flink-arm64:-
entrypoint: ["/bin/bash"]
command: ["/run.sh"]
environment:
ENV_FLINK_S3_ACCESSKEY: "mdstorage"
ENV_FLINK_S3_SECRETKEY: "eBxExGQJNhGosgv5FQJiVNqH"
ENV_FLINK_S3_SSL: "false"
ENV_FLINK_S3_PATH_STYLE_ACCESS: "true"
ENV_FLINK_S3_ENDPOINT: "sc:9010"
ENV_FLINK_S3_BUCKET: "mdoc"
ENV_FLINK_LOG_LEVEL: "INFO"
ENV_FLINK_JOBMANAGER_MEMORY: "4096m"
ENV_FLINK_TASKMANAGER_MEMORY: "16384m"
ENV_FLINK_TASKMANAGER_SLOTS: "50"
ENV_KAFKA_ENDPOINTS: "sc:9092"
ports:
- 58081:8081
volumes:
- ./volume/data/:/data/
extra_hosts:
- "sc:192.168.10.28" # Update this to the actual internal IP address of the HAP server
EOF -
Configure the startup script:
cat > /data/hap/script/startflink.sh <<-EOF
docker stack deploy -c /data/hap/script/flink.yaml flink
EOF
chmod +x /data/hap/script/startflink.sh -
Launch the Flink service:
bash /data/hap/script/startflink.sh- Once the Flink container starts, it takes about 5 minutes for the process to complete initialization.
- To stop the Flink service, use the command:
docker stack rm flink.
-
Initialize the swarm environment:
docker swarm init -
Create directories:
mkdir -p /data/hap/script/volume/data -
Download the Flink image (Offline package download):
- AMD64
- ARM64
docker pull nocoly/flink:1.19.720docker pull nocoly/flink-arm64:- -
Create the configuration file:
- AMD64
- ARM64
cat > /data/hap/script/flink.yaml <<EOF
version: '3'
services:
flink:
image: nocoly/flink:1.19.720
entrypoint: ["/bin/bash"]
command: ["/run.sh"]
environment:
ENV_FLINK_S3_ACCESSKEY: "mdstorage"
ENV_FLINK_S3_SECRETKEY: "eBxExGQJNhGosgv5FQJiVNqH"
ENV_FLINK_S3_SSL: "false"
ENV_FLINK_S3_PATH_STYLE_ACCESS: "true"
ENV_FLINK_S3_ENDPOINT: "flink-minio:9000"
ENV_FLINK_S3_BUCKET: "mdoc"
ENV_FLINK_LOG_LEVEL: "INFO"
ENV_FLINK_JOBMANAGER_MEMORY: "4096m"
ENV_FLINK_TASKMANAGER_MEMORY: "16384m"
ENV_FLINK_TASKMANAGER_SLOTS: "50"
ENV_KAFKA_ENDPOINTS: "sc:9092"
ports:
- 58081:8081
volumes:
- ./volume/data/:/data/
extra_hosts:
- "sc:192.168.10.28" # Update this to the actual internal IP address of the HAP server
flink-minio:
container_name: flink-minio
image: nocoly/minio:RELEASE.2025-04-22T22-12-26Z
environment:
MINIO_ROOT_USER: "mdstorage"
MINIO_ROOT_PASSWORD: "eBxExGQJNhGosgv5FQJiVNqH"
volumes:
- ./volume/data/:/data/
command: minio server /data/flink-minio --console-address ":9001"
EOFcat > /data/hap/script/flink.yaml <<EOF
version: '3'
services:
flink:
image: nocoly/flink-arm64:-
entrypoint: ["/bin/bash"]
command: ["/run.sh"]
environment:
ENV_FLINK_S3_ACCESSKEY: "mdstorage"
ENV_FLINK_S3_SECRETKEY: "eBxExGQJNhGosgv5FQJiVNqH"
ENV_FLINK_S3_SSL: "false"
ENV_FLINK_S3_PATH_STYLE_ACCESS: "true"
ENV_FLINK_S3_ENDPOINT: "flink-minio:9000"
ENV_FLINK_S3_BUCKET: "mdoc"
ENV_FLINK_LOG_LEVEL: "INFO"
ENV_FLINK_JOBMANAGER_MEMORY: "4096m"
ENV_FLINK_TASKMANAGER_MEMORY: "16384m"
ENV_FLINK_TASKMANAGER_SLOTS: "50"
ENV_KAFKA_ENDPOINTS: "sc:9092"
ports:
- 58081:8081
volumes:
- ./volume/data/:/data/
extra_hosts:
- "sc:192.168.10.28" # Update this to the actual internal IP address of the HAP server
flink-minio:
container_name: flink-minio
image: nocoly/minio-arm64:RELEASE.2025-04-22T22-12-26Z
environment:
MINIO_ROOT_USER: "mdstorage"
MINIO_ROOT_PASSWORD: "eBxExGQJNhGosgv5FQJiVNqH"
volumes:
- ./volume/data/:/data/
command: minio server /data/flink-minio --console-address ":9001"
EOF -
Download the MinIO image:
- AMD64
- ARM64
docker pull nocoly/minio:RELEASE.2025-04-22T22-12-26ZIf unable to access the internet, download the offline image file, upload it to the server, and then import it. Offline image download link:
https://pdpublic.nocoly.com/offline/minio-linux-amd64-RELEASE.2025-04-22T22-12-26Z.tar.gzdocker pull nocoly/minio-arm64:RELEASE.2025-04-22T22-12-26ZIf unable to access the internet, download the offline image file, upload it to the server, and then import it. Offline image download link:
https://pdpublic.nocoly.com/offline/minio-linux-arm64-RELEASE.2025-04-22T22-12-26Z.tar.gz -
Configure the startup script:
cat > /data/hap/script/startflink.sh <<-EOF
docker stack deploy -c /data/hap/script/flink.yaml flink
EOF
chmod +x /data/hap/script/startflink.sh -
Launch the Flink service:
bash /data/hap/script/startflink.sh- Once the Flink container starts, it takes about 5 minutes for the process to complete initialization.
- To stop the Flink service, use the command:
docker stack rm flink.
-
Enter the MinIO container to create the bucket required for Flink:
docker exec -it flink-minio bash
mc alias set myminio http://127.0.0.1:9000 mdstorage eBxExGQJNhGosgv5FQJiVNqH
mc mb myminio/mdoc