池中没有可用的连接Laravel和Redis

时间:2019-04-09 20:07:40

标签: laravel-5 redis

我在ubuntu 18.04上设置了一个本地有6个节点的redis集群,从127.0.0.1:7000到127.0.0.1:7006,带有redis二进制文件附带的默认'utils / create-cluster'脚本。

我在laravel 5.7应用程序上设置redis时遇到问题,我正在尝试向端点发出请求,并且出现以下错误

No connections available in the pool at line 337
myApp/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php

这与这里的错误完全相同-> Predis with laravel 5.5 "No connections available in the pool in Aggregate/RedisCluster.php:337 " 但是该答案并不能解决我的问题,也无法解决所指向的链接-> https://github.com/nrk/predis/issues/480

我的.env文件具有以下值

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=redis
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null   
REDIS_PORT=7000

我的app / database.php如下

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

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

经过大量的搜索和反复试验后,我设法通过在以下几行更改文件config/cache.php来解决了问题

错误:

'redis' => [
    'driver' => 'redis'
    'connection' => 'cache'
]

工作:

'redis' => [
    'driver' => 'redis'
    'connection' => 'default'
]