redis的集群配置

ysian

问题描述

集群配置文档说明:https://www.workerman.net/doc/webman/db/redis.html
环境:php8.2 centos7.9 redis7.2.2

按照文档配置

return [
    'clusters' => [
        'default' => [
            [
                'host'     => getenv('REDIS_HOST'),
                'password' => getenv('REDIS_PWD'),
                'port'     => 7000,
                'database' => 0,
            ],
        ],
    ],
];

代码

$key = 'test_key';
        Redis::set($key, rand());
        return response(Redis::get($key));

错误
截图

为此你搜索到了哪些方案及不适用的原因

这里写搜到的方案及不适用原因
搜到的解决方案也不适用
https://blog.csdn.net/qiling_70/article/details/117135627

549 4 1
4个回答

ysian

真的就没用过webman的redis集群吗?

  • 暂无评论
gddd

现在都用云redis,自己搭建集群,不敢上正式服

  • ysian 2023-10-26

    自己也得玩玩,根据webman的文档根本用不了redis集群。以前论坛也有类似的问题,没人给出解决方案。后面应该还有人遇到

nitron

一般是phpredis扩展的问题..

  • ysian 2023-10-28

    这个是illuminate/redis ,和phpredis扩展没有任何关系.

six

我们在用webman redis集群,没有任何问题。
illuminate/redis 是laravel的组件,这个组件全世界都在用,怎么可能有问题 ...

Couldn't map cluster keyspace using any provided seed,一般是redis集群搭建不正确,例如
1、连不上,例如链接拒绝,集群没启动,跨服务器安全组没开放端口,客户端配置的ip 端口是错的
2、搭建的redis就是个单机,根本不是 redis cluster集群

先运行 redis-cli --cluster check ip:port 看下集群状态是否正确,确定是集群没搭建好,还是客户端配错

  • ysian 2023-10-28

    你是怎样写的配置,按文档上来的吗?我能确定集群状态肯定没错的

  • ysian 2023-10-28

    你的配置能发个示例吗?

  • six 2023-10-28

    发下你的 redis-cli --cluster check ip:port 结果看下
    另外刚写了个教程 https://www.workerman.net/a/1587 你看下

  • ysian 2023-11-01

    我是伪分布式,就是一个服务器使用6个不同的端口搭建的集群。这种也能正常使用吧

  • steven_wang1990 2023-11-01

    请问workman或者GatewayWorker可以用这个illuminate/redis组件吗?我们也想搞redis集群

  • ysian 2023-11-01

    1.116.128.127:7000 (4102b5ed...) -> 0 keys | 5461 slots | 1 slaves.
    1.116.128.127:7001 (2988a75e...) -> 0 keys | 5462 slots | 1 slaves.
    1.116.128.127:7002 (b7fee37b...) -> 0 keys | 5461 slots | 1 slaves.
    [OK] 0 keys in 3 masters.
    0.00 keys per slot on average.

    Performing Cluster Check (using node 1.116.128.127:7000)
    M: 4102b5edb6d89d57d173ec42c11246cdf2938d72 1.116.128.127:7000
    slots:[0-5460] (5461 slots) master
    1 additional replica(s)
    S: 29de9e3a8b0e91363337c4657e01f26af25e8da5 1.116.128.127:7006
    slots: (0 slots) slave
    replicates 2988a75e49222ca40c2dba4ee8942cdb69c214ea
    M: 2988a75e49222ca40c2dba4ee8942cdb69c214ea 1.116.128.127:7001
    slots:[5461-10922] (5462 slots) master
    1 additional replica(s)
    M: b7fee37b9675983d85a5785e2318bb58e27cb776 1.116.128.127:7002
    slots:[10923-16383] (5461 slots) master
    1 additional replica(s)
    S: 8d440ab698555cb1deb1f81eded84e015da2e757 1.116.128.127:7003
    slots: (0 slots) slave
    replicates 4102b5edb6d89d57d173ec42c11246cdf2938d72
    S: c8bd2352875f1a4634ff5f24531bcb35b135bf68 1.116.128.127:7005
    slots: (0 slots) slave
    replicates b7fee37b9675983d85a5785e2318bb58e27cb776
    [OK] All nodes agree about slots configuration.
    Check for open slots...
    Check slots coverage...
    [OK] All 16384 slots covered. 这是redis-cli --cluster check ip:port 的结果,这是我目前的配置return [
    'clusters' => [
    'default' => [
    [
    'host' => '1.116.128.127',
    'password' => '',
    'port' => 7000,
    'database' => 0,
    ],
    ],
    ],
    / 'default' => [
    'host' => '127.0.0.1',
    'password' => null,
    'port' => 6379,
    'database' => 0,
    ]
    /
    ];; 还是会报RedisClusterException: Couldn't map cluster keyspace using any provided seed in /www/wwwroot/ysian_api/vendor/illuminate/redis/Connectors/PhpRedisConnector.php:189
    Stack trace:

🔝