在使用stackexchange redis客户端库通过sentinel连接受密码保护的Redis服务器爆出这样的问题:This operation has been disabled in the command-map and cannot be used: AUTH
代码是这样写:
var options = new ConfigurationOptions()
{
CommandMap = CommandMap.Sentinel,
EndPoints = { { "10.88.5.146", 26379 },{ "10.88.5.147", 26379 }},
AllowAdmin = true,
TieBreaker = "",
Password = "12345641",
ServiceName = "mymaster",
SyncTimeout = 5000,
AbortOnConnectFail = true,
DefaultVersion = new Version(3, 0),
Ssl = false
};
var connection = ConnectionMultiplexer.Connect(options);
代码没有问题,是redis配置改一下:redis.conf 中的改成这样 rename-command CONFIG ""
https://redis.io/topics/security#disabling-of-specific-commands
设置了,还是不行,报同样的错误提示 This operation has been disabled in the command-map and cannot be used: AUTH。
@miss星舞: 加个值试试,反正问题是出在这个地方
@miss星舞:
启用上面有知道的试试
@抽象ID: 好的好的 我试试先
@miss星舞: 或者都禁用了,再试试
@miss星舞:
从库只能读的,你不要说你往从库里面写缓存
@抽象ID: 现在报 This operation has been disabled in the command-map and cannot be used: Get
This operation has been disabled in the command-map and cannot be used: SETEX
这样的错误
@miss星舞:
从库只能读的,你这是写操作啊,只能对master库写缓存
你看我上面的截图
@抽象ID: 读写都一样,读出 This operation has been disabled in the command-map and cannot be used: Get 写出 This operation has been disabled in the command-map and cannot be used: SETEX
@miss星舞: 你非要在从库中写的话,就把
slave-read-only yes 改成 slave-read-only no
@抽象ID: 好的好的 我先试试,谢谢大神解答。
@miss星舞:
https://dotblogs.com.tw/supershowwei/2017/02/27/163018
ConfigurationOptions config = new ConfigurationOptions { EndPoints = { { "redis0", 6379 }, { "redis1", 6380 } }, CommandMap = CommandMap.Create(new HashSet<string> { // EXCLUDE a few commands "INFO", "CONFIG", "CLUSTER", "PING", "ECHO", "CLIENT" }, available: false), KeepAlive = 180, DefaultVersion = new Version(2, 8, 8), Password = "changeme" };
CommandMap 替换成上面这个试试,再不行,我也没有办法了
@抽象ID: 好的好多 我试试 谢谢,我现在不知道怎么弄的,哨兵都启动不起来了 。
大侠们,我也遇到这个问题,这个问题解决了吗???
StackExchange.Redis.RedisCommandException: This operation has been disabled in the command-map and cannot be used: AUTH
解决了没?大侠