简体   繁体   English

在集群模式下访问 AWS elasticache redis 时出错)+ 从 django 服务启用 TLS

[英]Error accessing AWS elasticache redis in cluster mode) + TLS Enabled from django service

I'm trying to connect AWS elasticache(redis in cluster mode) with TLS enabled, the library versions and django cache settings as below我正在尝试在启用 TLS、库版本和 django 缓存设置的情况下连接 AWS elasticache(集群模式下的 redis),如下所示

====Dependencies======
redis==3.0.0
redis-py-cluster==2.0.0
django-redis==4.11.0

======settings=======
CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': "redis://xxxxxxx.mc-redis-cache-v2.zzzzz.usw2.cache.amazonaws.com:6379/0",
        'OPTIONS': {
            'PASSWORD': '<password>',
            'REDIS_CLIENT_CLASS': 'rediscluster.RedisCluster',
            'CONNECTION_POOL_CLASS': 'rediscluster.connection.ClusterConnectionPool',
            'CONNECTION_POOL_KWARGS': {
                'skip_full_coverage_check': True,
                "ssl_cert_reqs": False,
                "ssl": True
            }
        }
    }
}

It doesn't seem to be a problem with client-class(provided by redis-py-cluster) since I'm able to access客户端类(由redis-py-cluster提供)似乎没有问题,因为我可以访问

from rediscluster import RedisCluster
startup_nodes = [{"host": "redis://xxxxxxx.mc-redis-cache-v2.zzzzz.usw2.cache.amazonaws.com", "port": "6379"}]

rc = RedisCluster(startup_nodes=startup_nodes, ssl=True, ssl_cert_reqs=False, decode_responses=True, skip_full_coverage_check=True, password='<password>')

rc.set("foo", "bar")
rc.get('foo')
'bar'

but I'm seeing this error when django service is trying to access the cache, is there any configuration detail that I might be missing?但是当 django 服务尝试访问缓存时,我看到了这个错误,是否有任何我可能遗漏的配置细节?

File "/usr/lib/python3.6/site-packages/django_redis/cache.py", line 32, in _decorator
    return method(self, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/django_redis/cache.py", line 81, in get
    client=client)
  File "/usr/lib/python3.6/site-packages/django_redis/client/default.py", line 194, in get
    client = self.get_client(write=False)
  File "/usr/lib/python3.6/site-packages/django_redis/client/default.py", line 90, in get_client
    self._clients[index] = self.connect(index)
  File "/usr/lib/python3.6/site-packages/django_redis/client/default.py", line 103, in connect
    return self.connection_factory.connect(self._server[index])
  File "/usr/lib/python3.6/site-packages/django_redis/pool.py", line 64, in connect
    connection = self.get_connection(params)
  File "/usr/lib/python3.6/site-packages/django_redis/pool.py", line 75, in get_connection
    pool = self.get_or_create_connection_pool(params)
  File "/usr/lib/python3.6/site-packages/django_redis/pool.py", line 94, in get_or_create_connection_pool
    self._pools[key] = self.get_connection_pool(params)
  File "/usr/lib/python3.6/site-packages/django_redis/pool.py", line 107, in get_connection_pool
    pool = self.pool_cls.from_url(**cp_params)
  File "/usr/lib/python3.6/site-packages/redis/connection.py", line 916, in from_url
    return cls(**kwargs)
  File "/usr/lib/python3.6/site-packages/rediscluster/connection.py", line 146, in __init__
    self.nodes.initialize()
  File "/usr/lib/python3.6/site-packages/rediscluster/nodemanager.py", line 172, in initialize
    raise RedisClusterException("ERROR sending 'cluster slots' command to redis server: {0}".format(node))
rediscluster.exceptions.RedisClusterException: ERROR sending 'cluster slots' command to redis server: {'host': 'xxxxxxx.mc-redis-cache-v2.zzzzz.usw2.cache.amazonaws.com', 'port': '6379'}

I also tried passing "ssl_ca_certs": "/etc/ssl/certs/ca-certificates.crt" to CONNECTION_POOL_KWARGS and setting the location scheme to rediss still no luck我还尝试将"ssl_ca_certs": "/etc/ssl/certs/ca-certificates.crt"传递给CONNECTION_POOL_KWARGS并将位置方案设置为rediss仍然没有运气

you need to change ssl_cert_reqs=False to ssl_cert_reqs=None您需要将 ssl_cert_reqs=False 更改为 ssl_cert_reqs=None

Here's the link to the redis Python git repo that points to this: https://github.com/andymccurdy/redis-py#ssl-connections Here's the link to the redis Python git repo that points to this: https://github.com/andymccurdy/redis-py#ssl-connections

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在哪里可以找到 elasticache redis 集群的 TLS 证书 - Where can I find TLS certificates for elasticache redis cluster AWS ElastiCache SSL 安全集群 + Spring Data Redis + Lettuce “Redis 健康检查失败” - AWS ElastiCache SSL secured cluster + Spring Data Redis + Lettuce "Redis health check failed" 访问仅启用TLS 1.2的服务器上运行的WCF服务 - Accessing WCF service running on the server with TLS 1.2 only enabled 使用传输中加密 + 身份验证从 redis-cli+stunnel 以外的客户端连接到 AWS ElastiCache - Connect to AWS ElastiCache with In-Transit Encryption + Auth from client other than redis-cli+stunnel 启用 raft 模式时 TLS 握手失败 - TLS handshake fails when raft mode is enabled 使用 CName 从 Java 连接到加密的 ElastiCache Redis - Connection to Encrypted ElastiCache Redis from Java using a CName K3s 入口 TLS 启用访问启用 TLS 的后端,如何? - K3s ingress TLS enabled accessing TLS enabled backend, how to? 启用 TLS 的私有 VPC 访问上的 Amazon MSK 集群 - Amazon MSK cluster on private VPC access with TLS enabled 带有 TLS 的 Redis 6 - Redis 6 with TLS 如何在 AWS 上使用 PCA 将 TLS 设置为 EKS 中的服务? - How to set TLS to a service in EKS with PCA on AWS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM