【问题标题】:Cannot use 'EVAL' with redis-cluster不能将“EVAL”与 redis-cluster 一起使用
【发布时间】:2020-02-03 09:07:06
【问题描述】:

Redis 在本地机器上工作正常,但在生产中却抛出错误。 在本地机器上,我使用了相同的配置。

尝试了几个小时,但仍然无法解决问题。

生产环境:

Ubuntu
Stack : Laravel, Redis, Laravel echo server

config/database.php

 'redis' => [

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

    ],

.env 文件

BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
SESSION_DRIVER=file

错误:

Cannot use 'EVAL' with redis-cluster. {"exception":"[object] (Predis\\NotSupportedException(code: 0): Cannot use 'EVAL' with redis-cluster. at /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:380)
[stacktrace]
#0 /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(550): Predis\\Connection\\Aggregate\\RedisCluster->getConnection(Object(Predis\\Command\\ServerEval))
#1 /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(593): Predis\\Connection\\Aggregate\\RedisCluster->retryCommandOnFailure(Object(Predis\\Command\\ServerEval), 'executeCommand')
#2 /var/www/html/mayaapi/vendor/predis/predis/src/Client.php(331): Predis\\Connection\\Aggregate\\RedisCluster->executeCommand(Object(Predis\\Command\\ServerEval))
#3 /var/www/html/mayaapi/vendor/predis/predis/src/Client.php(314): Predis\\Client->executeCommand(Object(Predis\\Command\\ServerEval))
#4 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(96): Predis\\Client->__call('eval', Array)
#5 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(108): Illuminate\\Redis\\Connections\\Connection->command('eval', Array)
#6 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(204): Illuminate\\Redis\\Connections\\Connection->__call('eval', Array)
#7 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(187): Illuminate\\Queue\\RedisQueue->migrateExpiredJobs('queues:default:...', 'queues:default')
#8 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(163): Illuminate\\Queue\\RedisQueue->migrate('queues:default')
#9 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(246): Illuminate\\Queue\\RedisQueue->pop('default')
#10 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(107): Illuminate\\Queue\\Worker->getNextJob(Object(Illuminate\\Queue\\RedisQueue), 'default')
#11 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\\Queue\\Worker->daemon('redis', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#12 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'default')
#13 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#14 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#15 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#16 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#17 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#18 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\\Container\\Container->call(Array)
#19 /var/www/html/mayaapi/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#20 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#21 /var/www/html/mayaapi/vendor/symfony/console/Application.php(1012): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /var/www/html/mayaapi/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /var/www/html/mayaapi/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /var/www/html/mayaapi/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 {main}
"} 

【问题讨论】:

  • 你想在 LUA 中计算什么?
  • @GuyKorland Lua 脚本,在这种情况下,是 Laravel 框架的内部
  • redis服务器的版本是多少?

标签: laravel redis predis


【解决方案1】:

尝试在config/queue.php 文件中将hash-tags(用{} 包装一个常量字符串)添加到您的队列名称中。

'queue.connections.redis.queue' => '{default}'

如果您使用除默认队列之外的其他队列,请将其更改为 OnQueue('{myQueue}'),而不是 OnQueue('myQueue')

即使您没有使用集群,predis 也可能会检查传递给 Lua 脚本的所有键是否在同一节点上。

【讨论】:

  • 在更改为 'queue.connections.redis.queue' => '{default}' 现在它抛出不同的错误,即“无法在连接集群上使用 'PUBLISH'。”
  • 用新错误更新问题。只需执行Edit,然后输入 Update: new error after fix with hash tags the previous error 和 post then error details
猜你喜欢
  • 2019-11-25
  • 2020-01-03
  • 2019-12-30
  • 1970-01-01
  • 2014-07-04
  • 2011-06-02
  • 1970-01-01
  • 2016-07-09
  • 2015-08-17
相关资源
最近更新 更多