Sentinel
Sentinel copied to clipboard
Sentinel规则持久化到Nacos配置中心报错
版本
- sentinel 1.8.6
- nacos 2.24
发生的时机
在使用Sentinel的后台管理时候,将配置的限流规则,持久化到nacos时,报错
失败:com.alibaba.nacos.api.exception.NacosException, <html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Wed Mar 20 17:35:49 CST 2024</div><div>There was an unexpected error (type=Forbidden, status=403).</div><div>user not found!</div></body></html>
发生的原因
我知道这是nacos的权限功能的问题,在普通SpringBoot服务连接nacos的依赖是:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
通过spring.cloud.nacos.username和spring.cloud.nacos.password 配置项来连接nacos
但是sentinel没有这个配置,要怎么解决呢
https://gitee.com/sirius19/sentinel-nacos 可以参考一下我改造的代码,dashboard把规则保存到nacos,以及规则反显
MARK