【问题标题】:Configuring AWS ElasticCache redis Cluster-3.2.4 with Laravel-5.4.32 using Predis使用 Predis 使用 Laravel-5.4.32 配置 AWS Elasticache redis Cluster-3.2.4
【发布时间】:2018-01-21 20:27:04
【问题描述】:

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

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

我的 database.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 实例。

【问题讨论】:

标签: php amazon-web-services laravel-5 redis amazon-elastic-beanstalk


【解决方案1】:

以下配置对我有用:

'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

【讨论】:

    猜你喜欢
    • 2018-07-11
    • 2014-11-03
    • 2018-12-04
    • 2015-10-18
    • 1970-01-01
    • 2015-04-05
    • 2020-11-01
    • 2015-10-05
    • 2018-12-29
    相关资源
    最近更新 更多