support connect to sentinel instance with password

This commit is contained in:
袁韬 2020-06-12 00:31:59 +08:00
parent 393ff81e69
commit bc0bc42625
2 changed files with 3 additions and 2 deletions

View File

@ -253,6 +253,7 @@ predixy支持Redis Sentinel和Redis Cluster来使用redis一个配置里这
+ ServerRetryTimeout: 一个redis实例失效后多久后去检查其是否恢复正常不指定的话为1秒 + ServerRetryTimeout: 一个redis实例失效后多久后去检查其是否恢复正常不指定的话为1秒
+ KeepAlive: predixy与redis的连接tcp keepalive时间为0则禁止此功能不指定的话为0 + KeepAlive: predixy与redis的连接tcp keepalive时间为0则禁止此功能不指定的话为0
+ Sentinels: 里面定义redis sentinel实例的地址 + Sentinels: 里面定义redis sentinel实例的地址
+ 从redis 5.0开始sentinel进程支持配置连接密码通过在sentinel的配置文件里不是predixy的配置文件设置requirepass anypwd这样的配置项实现, 在这种情况下需要在Sentinels里以 + {anypwd}@{address}:{port}的形式配置sentinel的连接地址
+ Group: 定义一个redis组Group的名字应该和redis sentinel里面的名字一致Group里可以显示列出redis的地址列出的话就是上面提到的静态节点 + Group: 定义一个redis组Group的名字应该和redis sentinel里面的名字一致Group里可以显示列出redis的地址列出的话就是上面提到的静态节点
一个例子: 一个例子:

View File

@ -331,8 +331,8 @@ void Conf::setStandaloneServerPool(const ConfParser::Node* node)
} else { } else {
Throw(InvalidValue, "%s:%d HashTag invalid", p->file, p->line); Throw(InvalidValue, "%s:%d HashTag invalid", p->file, p->line);
} }
} else if (setServers(mStandaloneServerPool.sentinels, "Sentinels", p)) { } else if (strcasecmp(p->key.c_str(), "Sentinels") == 0) {
mStandaloneServerPool.sentinelPassword = p->val; setServers(mStandaloneServerPool.sentinels, "Sentinels", p);
} else if (strcasecmp(p->key.c_str(), "Group") == 0) { } else if (strcasecmp(p->key.c_str(), "Group") == 0) {
mStandaloneServerPool.groups.push_back(ServerGroupConf{p->val}); mStandaloneServerPool.groups.push_back(ServerGroupConf{p->val});
if (p->sub) { if (p->sub) {