集群配置文檔說明:http://www.wtbis.cn/doc/webman/db/redis.html
環(huán)境: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
我們在用webman redis集群,沒有任何問題。
illuminate/redis 是laravel的組件,這個組件全世界都在用,怎么可能有問題 ...
Couldn't map cluster keyspace using any provided seed
,一般是redis集群搭建不正確,例如
1、連不上,例如鏈接拒絕,集群沒啟動,跨服務(wù)器安全組沒開放端口,客戶端配置的ip 端口是錯的
2、搭建的redis就是個單機,根本不是 redis cluster集群
先運行 redis-cli --cluster check ip:port
看下集群狀態(tài)是否正確,確定是集群沒搭建好,還是客戶端配錯
發(fā)下你的 redis-cli --cluster check ip:port 結(jié)果看下
另外剛寫了個教程 http://www.wtbis.cn/a/1587 你看下
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 的結(jié)果,這是我目前的配置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: