Hey guys,
I’m facing a problem with my redis that from time to time, it restarts, so the n8n executions get this read only replica error, what can I do to stop this from happening in production?
Do I need to change something in my redis stack? Or is there some n8n variable that I need to add?
I’m using ubuntu 20.04 and docker swarm
Stack redis
version: "3.7"
services:
redis:
image: redis:latest
networks:
- MyNetWork
ports:
- 6379:6379
volumes:
- redis_data:/data
deploy:
placement:
constraints: [node.role == manager]
command: ["redis-server", "--appendonly", "yes"]
volumes:
redis_data:
external: true
name: redis_data
networks:
MyNetWork:
external: true
name: MyNetWork
Stack N8N:
version: "3.7"
services:
n8n_editor:
image: n8nio/n8n:1.91.0
command: start
networks:
- MyNetWork
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=MyDB
- DB_POSTGRESDB_HOST=MyHostDB
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=MyUserDB
- DB_POSTGRESDB_PASSWORD=MyPasswordDB
- N8N_ENCRYPTION_KEY=MyN8NENCRYPTIONKEY
- N8N_HOST=myexample.com
- N8N_EDITOR_BASE_URL=https://myexample.com/
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://webhook.myexample.com/
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=MyHostRedis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=2
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales,node-fetch
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=720
- EXECUTIONS_DATA_PRUNE_MAX_COUNT=0
- GENERIC_TIMEZONE=America/Sao_Paulo
- TZ=America/Sao_Paulo
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
volumes:
- /root/n8n-data/backup:/data/backup
- /usr/share/fonts/truetype:/usr/share/fonts/truetype/host/
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=true
- traefik.http.routers.n8n_editor.rule=Host(`myexample.com`)
- traefik.http.routers.n8n_editor.entrypoints=websecure
- traefik.http.routers.n8n_editor.priority=1
- traefik.http.routers.n8n_editor.tls.certresolver=letsencryptresolver
- traefik.http.routers.n8n_editor.service=n8n_editor
- traefik.http.services.n8n_editor.loadbalancer.server.port=5678
- traefik.http.services.n8n_editor.loadbalancer.passHostHeader=1
n8n_webhook:
image: n8nio/n8n:1.91.0
command: webhook
networks:
- MyNetWork
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=MyDB
- DB_POSTGRESDB_HOST=MyHostDB
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=MyUserDB
- DB_POSTGRESDB_PASSWORD=MyPasswordDB
- N8N_ENCRYPTION_KEY=MyN8NENCRYPTIONKEY
- N8N_HOST=myexample.com
- N8N_EDITOR_BASE_URL=https://myexample.com/
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://webhook.myexample.com/
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=MyHostRedis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=2
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales,node-fetch
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=720
- EXECUTIONS_DATA_PRUNE_MAX_COUNT=0
- GENERIC_TIMEZONE=America/Sao_Paulo
- TZ=America/Sao_Paulo
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
volumes:
- /root/n8n-data/backup:/data/backup
- /usr/share/fonts/truetype:/usr/share/fonts/truetype/host/
deploy:
mode: replicated
replicas: 5
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=true
- traefik.http.routers.n8n_webhook.rule=(Host(`whk.myexample.com`))
- traefik.http.routers.n8n_webhook.entrypoints=websecure
- traefik.http.routers.n8n_webhook.priority=1
- traefik.http.routers.n8n_webhook.tls.certresolver=letsencryptresolver
- traefik.http.routers.n8n_webhook.service=n8n_webhook
- traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
- traefik.http.services.n8n_webhook.loadbalancer.passHostHeader=1
n8n_worker:
image: n8nio/n8n:1.91.0
command: worker --concurrency=20
networks:
- MyNetWork
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_DATABASE=MyDB
- DB_POSTGRESDB_HOST=MyHostDB
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_USER=MyUserDB
- DB_POSTGRESDB_PASSWORD=MyPasswordDB
- N8N_ENCRYPTION_KEY=MyN8NENCRYPTIONKEY
- N8N_HOST=myexample.com
- N8N_EDITOR_BASE_URL=https://myexample.com/
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://webhook.myexample.com/
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=MyHostRedis
- QUEUE_BULL_REDIS_PORT=6379
- QUEUE_BULL_REDIS_DB=2
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales,node-fetch
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=720
- EXECUTIONS_DATA_PRUNE_MAX_COUNT=0
- GENERIC_TIMEZONE=America/Sao_Paulo
- TZ=America/Sao_Paulo
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
volumes:
- /root/n8n-data/backup:/data/backup
- /usr/share/fonts/truetype:/usr/share/fonts/truetype/host/
deploy:
mode: replicated
replicas: 2
placement:
constraints:
- node.role == manager
networks:
MyNetWork:
name: MyNetWork
external: true