Laravel + Predis + Redis集群-已移动/未连接到127.0.0.1:6379 [英] Laravel + predis + Redis cluster - MOVED / no connection to 127.0.0.1:6379

查看:156
本文介绍了Laravel + Predis + Redis集群-已移动/未连接到127.0.0.1:6379的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个laravel(5.3)应用,其中redis用于会话(使用predis).只要我使用单个redis节点(使用 config/database.php 中的默认方法),一切都可以正常工作.虽然我刚开始切换到Redis集群,但50%的时间都出现MOVED错误(基于谷歌搜索,我知道这应该由predis管理,但不是这样).

I have a laravel (5.3) app with redis used for sessions (using predis). Everything works as long as I use a single redis node (using default approach from config/database.php). As soon as I switch to a Redis cluster though I am starting to get MOVED error like 50% of the time (based on googling I understand that this should be managed by predis, but somehow isn't).

我尝试将cluster参数更改为true,但随后出现一个奇怪的错误

I tried changing the cluster parameter to true, but then I get a weird error

No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379] 

尽管我使用的redis群集已部署在Azure中(并通过.env文件配置),并且在使用单个节点时可以毫无问题地接受参数.

Although the redis cluster that I use is deployed in Azure (and is configured via .env file) and the parameters are accepted without any problem when a single node is used.

配置

这是我拥有的laravel配置(如前所述,它是标准默认设置)

Here is the laravel configuration that I have (as mentioned earlier, it's the standard default)

'redis' => [

        'client' => 'predis',
        'cluster' => false,

        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

对于Redis,我使用Azure Redis Cache Cluster Premium P1,2个分片(如

For Redis, I use Azure Redis Cache Cluster Premium P1, 2 shards (as described here).

更新2

到目前为止,我还尝试了以下配置变化:

So far I also tried the following variations of the config:

  1. 将集群设置为true
  2. 将集群设置为redis
  3. 添加默认->将集群设置为redis
  4. 添加默认->选项设置为array('cluster','redis')

我一直遇到MOVED错误...

All the time I am getting MOVED error...

我的Redis版本是3.2,predis/predis软件包1.1.1

My Redis version is 3.2, predis/predis package 1.1.1

predis 1.1+的工作配置

'redis' => [
        'cluster' => true,

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

非常感谢您的帮助:)

推荐答案

TL; DR:

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆