Skip to content

Instantly share code, notes, and snippets.

@posulliv
Last active October 16, 2024 12:45
Show Gist options
  • Save posulliv/6c6550b8e51a5f1715bfbd9a01841d97 to your computer and use it in GitHub Desktop.
Save posulliv/6c6550b8e51a5f1715bfbd9a01841d97 to your computer and use it in GitHub Desktop.
Simple demo of Trino HA using Nginx reverse proxy.
version: '3.3'
services:
trino_a:
image: trinodb/trino
container_name: trino_a
ports:
- 8080:8080
volumes:
- ./trino_a.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
trino_b:
image: trinodb/trino
container_name: trino_b
ports:
- 8081:8081
volumes:
- ./trino_b.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
trino_worker:
image: trinodb/trino
container_name: trino_worker
volumes:
- ./trino_worker.config.properties:/etc/trino/config.properties
- ./jvm.config:/etc/trino/jvm.config
nginx:
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
-server
-Xmx2G
-XX:+UseG1GC
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-XX:ReservedCodeCacheSize=150M
-Duser.timezone=UTC
-Djdk.attach.allowAttachSelf=true
upstream trino {
server trino_a:8080 fail_timeout=3s max_fails=1;
server trino_b:8081 backup;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://trino;
proxy_redirect http://trino/ /;
proxy_connect_timeout 3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://localhost:8080
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8081
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://localhost:8081
coordinator=false
query.max-memory=1.4GB
query.max-memory-per-node=1.4GB
query.max-total-memory-per-node=1.4GB
discovery.uri=http://nginx:80
@guyskk
Copy link

guyskk commented Nov 10, 2022

If expose nginx with ports (not 80 443), should use proxy_set_header Host $http_host; to make trinodb build correct urls in response. $http_host includes port and $host not includes port.

My Nginx config:

server {
    listen 8180;
    server_name _;
    chunked_transfer_encoding off;
    location / {
        allow 127.0.0.1;
        deny all;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8080;
    }
}

@samer1977
Copy link

Is it possible to try to the above on multi host using windows docker desktop? I have been trying to set it up but Im unable to get the worker to establish connection with the coordinator . I keep getting the following error:

ERROR Announcer-0 io.airlift.discovery.client.Announcer Cannot connect to discovery server for announce
2024-10-16 07:43:07 io.airlift.discovery.client.DiscoveryException: Announcement failed with status code 406:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment