Zes*_*han 6 php redis amazon-elasticache laravel laravel-5
我已使用 Laravel 5.5 和 Predis 包在 Amazon ElastiCache 上设置 redis-cluster 进行缓存,但出现以下错误。
Predis\ClientException: No connections available in the pool in vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:337
Run Code Online (Sandbox Code Playgroud)
跟踪:Predis\ClientException:vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:337 中的池中没有可用的连接
堆栈跟踪:
0 供应商/predis/predis/src/Connection/Aggregate/RedisCluster.php(411): Predis\Connection\Aggregate\RedisCluster->guessNode(153)
1供应商/predis/predis/src/Connection/Aggregate/RedisCluster.php(388):Predis\Connection\Aggregate\RedisCluster->getConnectionBySlot(153)
2供应商/predis/predis/src/Connection/Aggregate/RedisCluster.php(550):Predis\Connection\Aggregate\RedisCluster->getConnection(对象(Predis\Command\StringSetExpire))
3 供应商/predis/predis/src/Connection/Aggregate/RedisCluster.php(593): Predis\Connection\Aggregate\RedisCluster->retryCommandOnFailure(Object(Predis\Command\StringSetExpire), 'executeCommand')
4 供应商/predis/predis/src/Client.php(331): Predis\Connection\Aggregate\RedisCluster->executeCommand(对象(Predis\Command\StringSetExpire))
5 供应商/predis/predis/src/Client.php(314): Predis\Client->executeCommand(对象(Predis\Command\StringSetExpire))
6 供应商/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(96): Predis\Client->__call('setex', Array)
7vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(108): Illuminate\Redis\Connections\Connection->command('setex', Array)
8vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(93): Illuminate\Redis\Connections\Connection->__call('setex', Array)
9vendor/laravel/framework/src/Illuminate/Cache/Repository.php(195): Illuminate\Cache\RedisStore->put('5rr44TBjIPEgJSx...', 'a:1:{s:6:"_flas.. .', 480)
10vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php(66): Illuminate\Cache\Repository->put('5rr44TBjIPEgJSx...', 'a:1:{s:6:"_flas.. .', 480)
11vendor/laravel/framework/src/Illuminate/Session/Store.php(128): Illuminate\Session\CacheBasedSessionHandler->write('5rr44TBjIPEgJSx...', 'a:1:{s:6:"_flas.. .')
12vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(87): Illuminate\Session\Store->save()
13vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): Illuminate\Session\Middleware\StartSession->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response) )
14vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\Foundation\Http\Kernel->terminateMiddleware(对象(Illuminate\Http\Request), 对象(Illuminate\Http\Response) )
15 public/index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
16 {主要}
我使用的技术栈:
我在 config/database.php 中尝试了以下配置:
redis=> [
'client' => 'predis',
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_CLUSTER_HOST', 'localhost'),
'password' => env('REDIS_CLUSTER_PASSWORD', null),
'port' => env('REDIS_CLUSTER_PORT', 6379),
'database' => 0,
],
],
'cache' => [
[
'host' => env('REDIS_CLUSTER_HOST', 'localhost'),
'password' => env('REDIS_CLUSTER_PASSWORD', null),
'port' => env('REDIS_CLUSTER_PORT', 6379),
'database' => 0,
],
],
]
]
Run Code Online (Sandbox Code Playgroud)
我也尝试过 timeout => 0|5|60 但每次我都会遇到同样的错误。
任何帮助将不胜感激!
小智 1
这在我们的环境中工作:
'redis' => [
'cluster' => true,
'client' => 'predis',
'options' => [
'cluster' => 'redis',
'parameters' => [
'scheme' => env('REDIS_SCHEME', 'tcp'),
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'timeout' => 15,
],
],
'clusters' => [
'default' => [
'scheme' => env('REDIS_SCHEME', 'tcp'),
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'timeout' => 15,
],
],
],
Run Code Online (Sandbox Code Playgroud)
基于此处找到的信息: https: //github.com/nrk/predis/issues/480 - 但还需要复制选项 -> 参数组中的所有“默认”配置值
REDIS_HOST,指向AWS elasticache的redis集群中的配置端点。
| 归档时间: |
|
| 查看次数: |
7923 次 |
| 最近记录: |