我将Redis客户端设置如下:
redisClient := redisclient.NewClient(&redisclient.Options{
Addr: <sentinel-pod-IP>:<sentinel-pod-port>,
Password: "",
DB: 0,
})
我通过以下方式运行SENTINEL slaves <master-name>
命令:
import redisclient "github.com/go-redis/redis"
......
cmd := redisclient.NewStringSliceCmd("SENTINEL", "slaves", "master-name")
redisClient.Process(cmd)
slaveInfos, err := cmd.Result()
但是,我在运行redis: can't parse string reply: \"*40\"
时遇到错误。
SENTINEL get-master-addr-by-name <master-name>
适用于同一客户端设置。
答案 0 :(得分:0)
我遇到了同样的问题,并在github上找到了解决方案: https://github.com/go-redis/redis/issues/788
您需要使用NewSliceCmd
,例如
cmd := redis.NewSliceCmd("sentinel", "slaves", "clusterName-master")
client.Process(cmd)
_, err := cmd.Result()
if err != nil {
fmt.Printf("Unable to issue `sentinel slaves %s-master ` cmd on (%s): %s", clusterName, err.Error())
}