failed to req API:/api//nacos/v1/ns/instance
nacos
Nacos是由阿里巴巴开源的服务治理中间件,集成了动态服务发现、配置管理和服务元数据管理功能,广泛应用于微服务架构中,简化服务治理过程。
项目地址:https://gitcode.com/gh_mirrors/na/nacos
免费下载资源
·
com.alibaba.nacos.api.exception.NacosException: failed to req API:/api//nacos/v1/ns/instance after all servers([192.168.6.71:8848]) tried: java.net.SocketTimeoutException: Read timed out
启动nacos成功
当前ip地址确实为:192.168.6.71
通过地址http://192.168.56.1:8848/nacos/index.html
和地址http://192.168.6.71:8848/nacos/index.html
访问均可成功。
在需要注册的项目中的配置如下:
#################################### common config : ####################################
spring.application.name=spring-cloud-alibaba-nacos-provider
# 应用服务web访问端口
server.port=7082
# ActuatorWeb访问端口
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.cloud.nacos.discovery.server-addr=192.168.6.71:8848
很遗憾,启动失败,并报错:
com.alibaba.nacos.api.exception.NacosException: failed to req API:/api//nacos/v1/ns/instance after all servers([192.168.6.71:8848]) tried: java.net.SocketTimeoutException: Read timed out
在nacos启动时会读取配置文件来判断启动模式是cluster
还是standalone
,可以查看博客:
https://blog.csdn.net/m0_37607945/article/details/107339265
当前为cluster
模式,查看文件:
C:\Users\Administrator\nacos\conf\cluster.conf
#it is ip
#example
192.168.6.71
修改配置文件为
#it is ip
#example
192.168.56.1:8848
重新启动nacos,并配置客户端配置文件为
#################################### common config : ####################################
spring.application.name=spring-cloud-alibaba-nacos-provider
# 应用服务web访问端口
server.port=7082
# ActuatorWeb访问端口
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#spring.cloud.nacos.discovery.server-addr=192.168.6.71:8848
spring.cloud.nacos.discovery.server-addr=192.168.56.1:8848
再次启动客户端
"C:\Program Files\Java\jdk1.8.0_121\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\lib\idea_rt.jar=51844:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;D:\springcloud\spring-cloud-alibaba-provider\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\2.1.8.RELEASE\spring-boot-starter-web-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\2.1.8.RELEASE\spring-boot-starter-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\2.1.8.RELEASE\spring-boot-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\2.1.8.RELEASE\spring-boot-autoconfigure-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\2.1.8.RELEASE\spring-boot-starter-logging-2.1.8.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\maven\repo\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\maven\repo\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;D:\maven\repo\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;D:\maven\repo\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\maven\repo\org\springframework\spring-core\5.1.9.RELEASE\spring-core-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-jcl\5.1.9.RELEASE\spring-jcl-5.1.9.RELEASE.jar;D:\maven\repo\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-json\2.1.8.RELEASE\spring-boot-starter-json-2.1.8.RELEASE.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.9.9.3\jackson-databind-2.9.9.3.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.9\jackson-datatype-jdk8-2.9.9.jar;D:\maven\repo\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.9\jackson-datatype-jsr310-2.9.9.jar;D:\maven\repo\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.9\jackson-module-parameter-names-2.9.9.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\2.1.8.RELEASE\spring-boot-starter-tomcat-2.1.8.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\9.0.24\tomcat-embed-core-9.0.24.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\9.0.24\tomcat-embed-el-9.0.24.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.24\tomcat-embed-websocket-9.0.24.jar;D:\maven\repo\org\hibernate\validator\hibernate-validator\6.0.17.Final\hibernate-validator-6.0.17.Final.jar;D:\maven\repo\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.3.Final\jboss-logging-3.3.3.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;D:\maven\repo\org\springframework\spring-web\5.1.9.RELEASE\spring-web-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\5.1.9.RELEASE\spring-beans-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\5.1.9.RELEASE\spring-webmvc-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\5.1.9.RELEASE\spring-aop-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\5.1.9.RELEASE\spring-context-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\5.1.9.RELEASE\spring-expression-5.1.9.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-actuator\2.1.8.RELEASE\spring-boot-starter-actuator-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-actuator-autoconfigure\2.1.8.RELEASE\spring-boot-actuator-autoconfigure-2.1.8.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-actuator\2.1.8.RELEASE\spring-boot-actuator-2.1.8.RELEASE.jar;D:\maven\repo\io\micrometer\micrometer-core\1.1.6\micrometer-core-1.1.6.jar;D:\maven\repo\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;D:\maven\repo\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;D:\maven\repo\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2.1.2.RELEASE\spring-cloud-starter-alibaba-nacos-discovery-2.1.2.RELEASE.jar;D:\springcloud\nacos-1.2.1\client\target\classes;D:\springcloud\nacos-1.2.1\common\target\classes;D:\maven\repo\org\slf4j\slf4j-api\1.7.28\slf4j-api-1.7.28.jar;D:\maven\repo\commons-io\commons-io\2.2\commons-io-2.2.jar;D:\maven\repo\org\apache\commons\commons-lang3\3.8.1\commons-lang3-3.8.1.jar;D:\springcloud\nacos-1.2.1\api\target\classes;D:\maven\repo\com\alibaba\fastjson\1.2.58\fastjson-1.2.58.jar;D:\maven\repo\com\google\guava\guava\22.0\guava-22.0.jar;D:\maven\repo\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;D:\maven\repo\com\google\errorprone\error_prone_annotations\2.0.18\error_prone_annotations-2.0.18.jar;D:\maven\repo\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;D:\maven\repo\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;D:\maven\repo\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.9.9\jackson-core-2.9.9.jar;D:\maven\repo\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;D:\maven\repo\com\alibaba\spring\spring-context-support\1.0.6\spring-context-support-1.0.6.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\2.1.5.RELEASE\spring-cloud-commons-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\5.1.6.RELEASE\spring-security-crypto-5.1.6.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\2.1.5.RELEASE\spring-cloud-context-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.1.5.RELEASE\spring-cloud-starter-netflix-ribbon-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\2.1.5.RELEASE\spring-cloud-starter-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-ribbon\2.1.5.RELEASE\spring-cloud-netflix-ribbon-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-archaius\2.1.5.RELEASE\spring-cloud-netflix-archaius-2.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.1.5.RELEASE\spring-cloud-starter-netflix-archaius-2.1.5.RELEASE.jar;D:\maven\repo\com\netflix\archaius\archaius-core\0.7.6\archaius-core-0.7.6.jar;D:\maven\repo\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\maven\repo\com\netflix\ribbon\ribbon\2.3.0\ribbon-2.3.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-transport\2.3.0\ribbon-transport-2.3.0.jar;D:\maven\repo\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\maven\repo\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;D:\maven\repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\maven\repo\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\maven\repo\com\netflix\ribbon\ribbon-core\2.3.0\ribbon-core-2.3.0.jar;D:\maven\repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\maven\repo\com\netflix\ribbon\ribbon-httpclient\2.3.0\ribbon-httpclient-2.3.0.jar;D:\maven\repo\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.5.9\httpclient-4.5.9.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.4.12\httpcore-4.4.12.jar;D:\maven\repo\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\maven\repo\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\maven\repo\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\maven\repo\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-commons-util\0.3.0\netflix-commons-util-0.3.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-loadbalancer\2.3.0\ribbon-loadbalancer-2.3.0.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\maven\repo\io\reactivex\rxjava\1.3.8\rxjava-1.3.8.jar;D:\maven\repo\org\junit\jupiter\junit-jupiter\5.5.2\junit-jupiter-5.5.2.jar;D:\maven\repo\org\junit\jupiter\junit-jupiter-api\5.3.2\junit-jupiter-api-5.3.2.jar;D:\maven\repo\org\apiguardian\apiguardian-api\1.0.0\apiguardian-api-1.0.0.jar;D:\maven\repo\org\opentest4j\opentest4j\1.1.1\opentest4j-1.1.1.jar;D:\maven\repo\org\junit\platform\junit-platform-commons\1.3.2\junit-platform-commons-1.3.2.jar;D:\maven\repo\org\junit\jupiter\junit-jupiter-params\5.3.2\junit-jupiter-params-5.3.2.jar;D:\maven\repo\org\junit\jupiter\junit-jupiter-engine\5.3.2\junit-jupiter-engine-5.3.2.jar;D:\maven\repo\org\junit\platform\junit-platform-engine\1.3.2\junit-platform-engine-1.3.2.jar;D:\maven\repo\org\mockito\mockito-junit-jupiter\2.23.4\mockito-junit-jupiter-2.23.4.jar;D:\maven\repo\org\mockito\mockito-core\2.23.4\mockito-core-2.23.4.jar;D:\maven\repo\net\bytebuddy\byte-buddy\1.9.16\byte-buddy-1.9.16.jar;D:\maven\repo\net\bytebuddy\byte-buddy-agent\1.9.16\byte-buddy-agent-1.9.16.jar;D:\maven\repo\org\objenesis\objenesis\2.6\objenesis-2.6.jar" com.alibaba.nacos.example.AlibabaProviderApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.8.RELEASE)
2020-07-30 15:57:08.850 INFO 5580 --- [ main] c.a.n.e.AlibabaProviderApplication : No active profile set, falling back to default profiles: default
2020-07-30 15:57:09.445 WARN 5580 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'nacos-discovery' contains invalid characters, please migrate to a valid format.
2020-07-30 15:57:09.737 WARN 5580 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2020-07-30 15:57:09.922 INFO 5580 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=1f87ae10-5fb5-394f-9707-f2259679c91d
2020-07-30 15:57:10.251 INFO 5580 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 7082 (http)
2020-07-30 15:57:10.277 INFO 5580 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-07-30 15:57:10.278 INFO 5580 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
2020-07-30 15:57:10.499 INFO 5580 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-07-30 15:57:10.500 INFO 5580 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1632 ms
2020-07-30 15:57:12.072 WARN 5580 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-07-30 15:57:12.072 INFO 5580 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-07-30 15:57:12.080 WARN 5580 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2020-07-30 15:57:12.080 INFO 5580 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-07-30 15:57:12.295 INFO 5580 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-07-30 15:57:12.549 INFO 5580 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'Nacso-Watch-Task-Scheduler'
2020-07-30 15:57:13.779 INFO 5580 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 20 endpoint(s) beneath base path '/actuator'
2020-07-30 15:57:13.933 INFO 5580 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 7082 (http) with context path ''
2020-07-30 15:57:14.168 INFO 5580 --- [ main] c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP spring-cloud-alibaba-nacos-provider 192.168.56.1:7082 register finished
2020-07-30 15:57:15.203 INFO 5580 --- [ main] c.a.n.e.AlibabaProviderApplication : Started AlibabaProviderApplication in 9.947 seconds (JVM running for 13.219)
2020-07-30 15:57:16.324 INFO 5580 --- [-169.254.10.142] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-07-30 15:57:16.324 INFO 5580 --- [-169.254.10.142] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-07-30 15:57:16.357 INFO 5580 --- [-169.254.10.142] o.s.web.servlet.DispatcherServlet : Completed initialization in 33 ms
启动成功!
GitHub 加速计划 / na / nacos
29.83 K
12.75 K
下载
Nacos是由阿里巴巴开源的服务治理中间件,集成了动态服务发现、配置管理和服务元数据管理功能,广泛应用于微服务架构中,简化服务治理过程。
最近提交(Master分支:3 个月前 )
4334cd16
* Support custom client configuration timeout.(#12748)
* Add UT.(#12748) 15 天前
b04d2266
19 天前
更多推荐
已为社区贡献2条内容
所有评论(0)