dubbo-go
dubbo-go copied to clipboard
nacos 配置中心加载配置启动 dubbo 报 error
加载配置的代码
rootConfig := dubbo_config.NewRootConfigBuilder().
SetConfigCenter(dubbo_config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").
SetAddress(ip). // 根据配置结构,设置配置中心
SetDataID(DataID). // 设置配置ID
SetGroup(Group).
Build()).
SetLogger(LoggerConfig).
Build()
if err := rootConfig.Init(); err != nil { // 框架启动
panic(err)
}
配置内容
dubbo:
registries:
my_nacos:
protocol: nacos
address: mse-31a78442-nacos-ans.mse.aliyuncs.com:8848
group: myGroup
params:
nacos.logDir: ./log
nacos.logLevel: error
metrics:
enable: true # default is true
path: /metrics
port: 9090 # default is 9090
namespace: public # default is dubbo 作为数据上报 metrics 的前缀
protocols:
triple:
name: tri
port: 20000
provider:
services:
Provider:
interface: dubbo.model # must be compatible with grpc or dubbo-java
shutdown:
internal-signal: true
报错信息
2022-12-08T17:26:32.867+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.869+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.870+0800 INFO config_client/config_proxy.go:180 [client.ListenConfig] request params:map[Listening-Configs:featuresdubbo9a050876b1eb3e07efaa73fd473e6885publictablesdubbo1604b55f395046d91e3ad6c9bcf833c8publicmodelsdubboe63c4f961630fabb73c6e22d61b9599fpublicrootdubbo5a7a2382126da03de55b3c9c32f0ef06public tenant:public] header:map[Content-Type:application/x-www-form-urlencoded;charset=utf-8 Long-Pulling-Timeout:30000 Long-Pulling-Timeout-No-Hangup:true accessKey: secretKey:]
2022-12-08T17:26:32.871+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.871+0800 ERROR config_client/config_client.go:191 get config from server error:[404] config data not exist
2022-12-08T17:26:32.871+0800 WARN config_client/config_client.go:196 [client.GetConfig] config not found, dataId: dubbo.io.configurators, group: dubbo, namespaceId: .
2022-12-08T17:26:32.873+0800 INFO config_client/config_client.go:423 [client.ListenConfig] config changed:models%02dubbo%02public%01root%02dubbo%02public%01features%02dubbo%02public%01tables%02dubbo%02public%01
2022-12-08T17:26:32.874+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.876+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.878+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.878+0800 ERROR config_client/config_client.go:191 get config from server error:[404] config data not exist
2022-12-08T17:26:32.878+0800 WARN config_client/config_client.go:196 [client.GetConfig] config not found, dataId: dubbo.model.configurators, group: dubbo, namespaceId: .
服务并不需要这两个配置,为什么要去加载它们?
自查定位到这行: https://github.com/apache/dubbo-go/blob/7bba076bc260950998dc0b320b20e48bcda2f296/registry/directory/directory.go#L485
https://github.com/apache/dubbo-go/blob/7bba076bc260950998dc0b320b20e48bcda2f296/registry/directory/directory.go#L509
https://github.com/apache/dubbo-go/blob/7bba076bc260950998dc0b320b20e48bcda2f296/registry/base_configuration_listener.go#L59
为什么这里设置监听用的 key 是 url.EncodedServiceKey()+constant.ConfiguratorSuffix
?不能在配置里设置吗?我没建立叫这个名的配置。
为什么 listener.InitWith
里默认用constant.Dubbo
? 不能在配置里设置吗? 我没这个group。
为什么这里一定要设置listener
?我配置不会变动,不需要监听。
如果是我这样使用不对,请问建议的使用方式是怎样的?
@binbin0325
当使用了动态配置中心后,会在程序启动时从配置中心读取配置文件。 你代码里的SetConfigCenter
就是开启了配置中心
dubbo.io.configurators 是默认的Application name+固定的后缀configurators, 可以按照如下方式修改
dubbo:
application:
name: myApp
关于配置中心相关内容的参考链接:https://cn.dubbo.apache.org/zh/docs3-v2/golang-sdk/samples/config-center-dynamic/
如果你不需要配置中心,那么参考samples中的helloworld 启动方式就足够了:https://github.com/apache/dubbo-go-samples/tree/master/helloworld
意思是我的配置文件名要改成 myApp.configurators 吗?那读这个默认配置 dubbo.model.configurators ,怎么避免?
意思是我的配置文件名要改成 myApp.configurators 吗?那读这个默认配置 dubbo.model.configurators ,怎么避免?
是的,dubbo.model
是你的配置文件中设置的。主要是当provider的参数发生变化时consumer可以感知,暂时可以忽略。
rovider:
services:
Provider:
interface: dubbo.model # must be compatible with grpc or dubbo-java
我的配置文件名改成 myApp.configurators 加了application 仍然会报这两个error!为什么要去读这两个默认配置,group 还固定为dubbo?可不同应用的 group 不可能都是 dubbo 吧
上面解释过了,读这两个默认配置的原因,group 也是可以配置的,你仔细看下上面说的配置中心文档:https://github.com/apache/dubbo-go-samples/tree/master/helloworld。
这段代码逻辑目前看没有用,后续将考虑删掉
志信:监听了配置文件,但是没有后续处理。目前删掉相关逻辑代码。
我的配置文件名改成 myApp.configurators 加了application 仍然会报这两个error!为什么要去读这两个默认配置,group 还固定为dubbo?可不同应用的 group 不可能都是 dubbo 吧
这部分是 Dubbo 内置的服务治理流程。
2022-12-08T17:26:32.867+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.869+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.870+0800 INFO config_client/config_proxy.go:180 [client.ListenConfig] request params:map[Listening-Configs:featuresdubbo9a050876b1eb3e07efaa73fd473e6885publictablesdubbo1604b55f395046d91e3ad6c9bcf833c8publicmodelsdubboe63c4f961630fabb73c6e22d61b9599fpublicrootdubbo5a7a2382126da03de55b3c9c32f0ef06public tenant:public] header:map[Content-Type:application/x-www-form-urlencoded;charset=utf-8 Long-Pulling-Timeout:30000 Long-Pulling-Timeout-No-Hangup:true accessKey: secretKey:]
2022-12-08T17:26:32.871+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.io.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.871+0800 ERROR config_client/config_client.go:191 get config from server error:[404] config data not exist
2022-12-08T17:26:32.871+0800 WARN config_client/config_client.go:196 [client.GetConfig] config not found, dataId: dubbo.io.configurators, group: dubbo, namespaceId: .
2022-12-08T17:26:32.873+0800 INFO config_client/config_client.go:423 [client.ListenConfig] config changed:models%02dubbo%02public%01root%02dubbo%02public%01features%02dubbo%02public%01tables%02dubbo%02public%01
2022-12-08T17:26:32.874+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.876+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.878+0800 ERROR nacos_server/nacos_server.go:194 api</v1/cs/configs>,method:<GET>, params:<{"dataId":"dubbo.model.configurators","group":"dubbo"}>, call domain error:<[404] config data not exist
> , result:<config data not exist
>
2022-12-08T17:26:32.878+0800 ERROR config_client/config_client.go:191 get config from server error:[404] config data not exist
2022-12-08T17:26:32.878+0800 WARN config_client/config_client.go:196 [client.GetConfig] config not found, dataId: dubbo.model.configurators, group: dubbo, namespaceId: .
这个是哪里的报错?理论上 Dubbo 框架应该能屏蔽这个读取报错,不影响正常的启动过程,甚至不应该打印 Error 级别日志。