当我开始这个项目时,我遇到的主要问题是将redis连接分配给side kiq,并在redis中使用ElastiCacheredis集群。这是我的Docker-Compose文件:
version: "3.3"
services:
db:
image: postgres:12.9-alpine
ports:
- "5432:5432"
volumes:
- db_data_postgres:/var/lib/postgresql/data
networks:
appnet:
ipv4_address: 172.20.0.3
redis:
image: redis:latest
restart: always
ports:
- '6379:6379'
command: bash -c "redis-server" # what should go here?
networks:
appnet:
ipv4_address: 172.20.0.4
app:
build:
context: .
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
depends_on:
- db
- worker_sidekiq
links:
- db
ports:
- "8000:8000"
env_file:
- .env
environment:
- REDIS_URL=redis://redis:6379
command: bash -c "rm -f tmp/pids/server.pid && RAILS_ENV=development bin/rails s -b '0.0.0.0' -p 8000"
networks:
appnet:
ipv4_address: 172.20.0.5
worker_sidekiq:
build: .
image: app
command: bash -c "bundle exec sidekiq"
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
depends_on:
- redis
environment:
- REDIS_URL=redis://redis:6379
networks:
appnet:
ipv4_address: 172.20.0.6
networks:
appnet:
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
gem_cache:
db_data_postgres:
node_modules:
我已尝试command: redis-cli -h *.*.use1.cache.amazonaws.com -p 6379
,但在启动时出错。我已经尝试了一段时间,但我不知道如何在我的docker-compose文件中链接AWS Redis集群。有什么想法吗?
1条答案
按热度按时间dtcbnfnu1#
默认情况下,ElastiCache无法从AWS外部连接。您可以通过堡垒主机或AWS客户端VPN连接到这些群集。
亚马逊官方文档:https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html#access-from-outside-aws