apache / dubbo-admin

The ops and reference implementation for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
4k stars 2.17k forks source link

0.4.0里面的sh脚本,无法运行 #851

Open zhiguangliu opened 2 years ago

zhiguangliu commented 2 years ago

Environment

Steps to reproduce this issue

执行bin/startup.sh启动时报错:

startup.sh: line 2: $'\r': command not found
startup.sh: line 17: $'\r': command not found
startup.sh: line 21: syntax error near unexpected token `$'in\r''
'tartup.sh: line 21: `case "`uname`" in

经查是shell脚本中的换行有问题,请下一版本替换一下 参考: https://blog.csdn.net/bird3014/article/details/93122974

https://blog.csdn.net/heihaozi/article/details/113602205

haoyann commented 2 years ago

@zhiguangliu Hi,可以提一个 PR 解决它吗?

lovcomputer commented 2 years ago

我用0.4.0的时候,找不到服务,0.3.0可以,你有遇到过么?0.4.0的配置又和0.3.0有啥区别么?我两个配置的是一样的

KeRan213539 commented 2 years ago

我用0.4.0的时候,找不到服务,0.3.0可以,你有遇到过么?0.4.0的配置又和0.3.0有啥区别么?我两个配置的是一样的

0.4.0 增加了一些新的配制项,请参考: https://github.com/apache/dubbo-admin/blob/develop/dubbo-admin-server/src/main/resources/application.properties

zhiguangliu commented 2 years ago

@zhiguangliu Hi,可以提一个 PR 解决它吗?

这个似乎不是用PR解决的问题。是最后的打发布包的时候在windows环境下打的包吧。感觉是clone出来的时候转换成了windows的换行符。

我查了下git 在windows下有个选项:Checkout Windows-style, commit Unix-style line endings

zhiguangliu commented 2 years ago

我用0.4.0的时候,找不到服务,0.3.0可以,你有遇到过么?0.4.0的配置又和0.3.0有啥区别么?我两个配置的是一样的

这个我倒是没有遇到过。我也是配置一样的。服务也是一样的。

lovcomputer commented 2 years ago

我用0.4.0的时候,找不到服务,0.3.0可以,你有遇到过么?0.4.0的配置又和0.3.0有啥区别么?我两个配置的是一样的

0.4.0 增加了一些新的配制项,请参考: https://github.com/apache/dubbo-admin/blob/develop/dubbo-admin-server/src/main/resources/application.properties

新增的配置主要是

#token timeout, default is one hour
admin.check.tokenTimeoutMilli=3600000
#Jwt signingKey
admin.check.signSecret=86295dd0c4ef69a1036b0b0c15158d77

#dubbo config
dubbo.application.name=dubbo-admin
dubbo.registry.address=${admin.registry.address}

# mysql
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:mysql://localhost:3306/dubbo-admin?characterEncoding=utf8&connectTimeout=1000&socketTimeout=10000&autoReconnect=true
#spring.datasource.username=root
#spring.datasource.password=mysql
# h2
spring.datasource.url=jdbc:h2:mem:~/dubbo-admin;
spring.datasource.username=sa
spring.datasource.password=
# id generate type
mybatis-plus.global-config.db-config.id-type=none

如果我数据库依然使用h2的话,按理说其它的应该和0.3.0配置没有区别吧?然后同样的连接nacos注册中心,0.3.0可以发现相关的服务,0.4.0就一直没有服务显示

haoyann commented 2 years ago

@lovcomputer 你 nacos 和 dubbo 的版本是多少,还有看一下配置 group 和 namespace 有没有对应上。

lovcomputer commented 2 years ago

@haoyann dubbo服务引用的版本依赖,nacos server是1.4.2的:

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>3.0.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
            <version>2.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            <version>2.2.5.RELEASE</version>
        </dependency>

dubbo服务的配置:

dubbo.provider.filter=metrics
dubbo.metrics.port=20880
dubbo.metrics.protocol=dubbo
# 配置注册中心
dubbo.registry.address=nacos://192.168.1.1:8848?namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e
dubbo.config-center.address=nacos://192.168.1.1:8848?group=dubbo&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e
dubbo.metadata-report.address=nacos://192.168.1.1:8848?group=dubbo&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e

dubbo-admin修改的配置:

admin.registry.address=nacos://192.168.1.1:8848?group=DEFAULT_GROUP&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e
admin.config-center=nacos://192.168.1.1:8848?group=dubbo&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e
admin.metadata-report.address=nacos://192.168.1.1:8848?group=dubbo&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1

以上的配置,用0.3.0的时候可以,0.4.0的时候有问题,报错:

java.lang.IllegalStateException: Failed to register dubbo://2.0.1.54:20881/org.apache.dubbo.mock.api.MockService?anyhost=true&application=dubbo-admin&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.mock.api.MockService&metadata-type=remote&methods=mock&pid=15028&release=3.0.2.1&revision=3.0.0&service-name-mapping=true&side=provider&timestamp=1637742358113 to registry 192.168.1.1:8848, cause: Failed to register dubbo://2.0.1.54:20881/org.apache.dubbo.mock.api.MockService?anyhost=true&application=dubbo-admin&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.mock.api.MockService&metadata-type=remote&methods=mock&pid=15028&release=3.0.2.1&revision=3.0.0&service-name-mapping=true&side=provider&timestamp=1637742358113 to nacos nacos://192.168.1.1:8848/org.apache.dubbo.registry.RegistryService?group=DEFAULT_GROUP&interface=org.apache.dubbo.registry.RegistryService&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e, cause: Request nacos server failed: 

然后我把这个MockServiceProvider服务注释了,启动可以了,就是无法获取服务。

还有在用0.3.0的时候,服务统计那个是不是有问题?生产者和消费者在一台服务器上,只有生产者的信息,生产者的调用信息,还感觉怪怪的

brotherlu-xcq commented 2 years ago

0.4.0版本回去向注册中心注册MockService用于服务mock功能,你这里的错误日志是向Nacos注册服务时失败了,你这里日志没截全,你检查一下具体失败的原因什么呢?

lovcomputer commented 2 years ago

@brotherlu-xcq 感觉是nacos的问题,具体的日志:

java.lang.IllegalStateException: Failed to register dubbo://2.0.1.54:20881/org.apache.dubbo.mock.api.MockService?anyhost=true&application=dubbo-admin&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.mock.api.MockService&metadata-type=remote&methods=mock&pid=16820&release=3.0.2.1&revision=3.0.0&service-name-mapping=true&side=provider&timestamp=1637742775151 to registry 192.168.1.1:8848, cause: Failed to register dubbo://2.0.1.54:20881/org.apache.dubbo.mock.api.MockService?anyhost=true&application=dubbo-admin&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.mock.api.MockService&metadata-type=remote&methods=mock&pid=16820&release=3.0.2.1&revision=3.0.0&service-name-mapping=true&side=provider&timestamp=1637742775151 to nacos nacos://192.168.1.1:8848/org.apache.dubbo.registry.RegistryService?group=DEFAULT_GROUP&interface=org.apache.dubbo.registry.RegistryService&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e, cause: Request nacos server failed: 
    at org.apache.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:218) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.registry.ListenerRegistryWrapper.register(ListenerRegistryWrapper.java:58) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.registry.integration.RegistryProtocol.register(RegistryProtocol.java:184) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:220) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:64) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:60) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:46) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:64) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.doExportUrl(ServiceConfig.java:612) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.exportRemote(ServiceConfig.java:586) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.exportUrl(ServiceConfig.java:546) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:379) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:366) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:342) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:233) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1411) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.doStart(DubboBootstrap.java:1143) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:1119) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:109) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:101) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationEvent(DubboBootstrapApplicationListener.java:78) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.apache.dubbo.admin.DubboAdminApplication.main(DubboAdminApplication.java:34) [classes/:na]
Caused by: org.apache.dubbo.rpc.RpcException: Failed to register dubbo://2.0.1.54:20881/org.apache.dubbo.mock.api.MockService?anyhost=true&application=dubbo-admin&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=org.apache.dubbo.mock.api.MockService&metadata-type=remote&methods=mock&pid=16820&release=3.0.2.1&revision=3.0.0&service-name-mapping=true&side=provider&timestamp=1637742775151 to nacos nacos://192.168.1.1:8848/org.apache.dubbo.registry.RegistryService?group=DEFAULT_GROUP&interface=org.apache.dubbo.registry.RegistryService&namespace=54rf4ceb-f0fr-46b0-83e5-fa04521aa59e, cause: Request nacos server failed: 
    at org.apache.dubbo.registry.nacos.NacosRegistry.doRegister(NacosRegistry.java:173) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:205) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    ... 36 common frames omitted
Caused by: com.alibaba.nacos.api.exception.NacosException: Request nacos server failed: 
    at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:227) ~[nacos-client-2.0.2.jar:na]
    at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.registerService(NamingGrpcClientProxy.java:116) ~[nacos-client-2.0.2.jar:na]
    at com.alibaba.nacos.client.naming.remote.NamingClientProxyDelegate.registerService(NamingClientProxyDelegate.java:95) ~[nacos-client-2.0.2.jar:na]
    at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:145) ~[nacos-client-2.0.2.jar:na]
    at org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper.registerInstance(NacosNamingServiceWrapper.java:57) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    at org.apache.dubbo.registry.nacos.NacosRegistry.doRegister(NacosRegistry.java:170) ~[dubbo-3.0.2.1.jar:3.0.2.1]
    ... 37 common frames omitted
Caused by: com.alibaba.nacos.api.exception.NacosException: Client not connected,current status:STARTING
    at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:656) ~[nacos-client-2.0.2.jar:na]
    at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:636) ~[nacos-client-2.0.2.jar:na]
    at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:217) ~[nacos-client-2.0.2.jar:na]
    ... 42 common frames omitted
haoyann commented 2 years ago

Nacos 服务端版本太低了,dubbo 3.0 最好使用 nacos 2.0 的版本。

zhiguangliu commented 2 years ago

@zhiguangliu Hi,可以提一个 PR 解决它吗?

您好,可以将问题转交给负责发布的同学看一下不?手里事情比较多,没时间仔细研究。但是原因就是sh脚本的换行是\r\n导致的。

haoyann commented 2 years ago

您好,可以将问题转交给负责发布的同学看一下不?手里事情比较多,没时间仔细研究。但是原因就是sh脚本的换行是\r\n导致的。

好的,感谢你反馈的问题。

haoyann commented 2 years ago

@lovcomputer 你可以把 nacos-client 改为 1.4.2 版本试试。 https://github.com/apache/dubbo-admin/blob/efb7a8d92f5e3c38e7f29c25d3793b00583a113e/dubbo-admin-server/pom.xml#L90

dengyumin commented 2 years ago

刚刚也发现了这个问题,刚想上来提issue。用的解决方法是sed -i "s/\r//" startup.sh