laravel 连接 redis sentinel 配置的坑
项目中需要用到 redis 哨兵模式,所以遇到了这个坑,在此记录一下
当redis所有的端口设置了auth后,安装官方给配置信息不生效,redis 连接信息一直报错noauth
谷歌百度了很久都说的是按照配置文件就ok,但是目前确实出现了noauth的问题,实在没办法了,看了一下源码,发现了一个很大的坑
// 在vendor/predis/predis/src/Connection/Aggregate/SentinelReplication.php
if (is_array($parameters)) {
// We explicitly set "database" and "password" to null,
// so that no AUTH and SELECT command is send to the sentinels.
$parameters['database'] = null;
$parameters['password'] = null;
if (!isset($parameters['timeout'])) {
$parameters['timeout'] = $this->sentinelTimeout;
}
}
强制把密码给设置为空,最后导致redis连接报错noauth
本作品采用《CC 协议》,转载必须注明作者和本文链接