使用 Predis 将 AWS ElasticCache redis Cluster-3.2.4 与 Laravel-5



>我正在尝试在 Laravel-5.4.32 上使用 ElasticCache Redis 集群(已启用集群模式而不是哨兵(,但出现以下错误:

1/1( 服务器异常 移动 13491 10.0.1.199:6379

我的数据库.php如下所示:


'redis' => [
'client' => 'predis',
'cluster' => true,
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],

REDIS_HOST值是使用 .env 文件提供的。 我的应用程序在单个 redis 实例上工作正常。

以下配置对我有用:

'redis' => [
'client' => 'predis',
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
],
],

实际上,这在 laravel 文档中清楚地提到: https://laravel.com/docs/5.4/redis#configuration

最新更新