rancher上config不能正常注册eureka集群

来源:12-4 构建eureka高可用服务

网络时空

2020-03-25

师兄,下午好!

如下问题已经折腾我一天了,还是未能解决,急盼师兄指点下!
你的对应章节代码和配置文件,我都比较了,基本一致,版本也是一致的。
(最开始我是完全按照你视频的做法来操作的,还是不行,针对网上介绍的办法 ,如下有些配置文件做了少量修改,还是仍未能解决)
------------------------
我本地
相关运行环境说明如下
rancher-server 192.168.16.35
rancer-agent 192.168.16.42
---------------------------
我本地hosts文件如做了eureka1和eureka2的主机名映射如下
192.168.16.42 eureka1 eureka2
---------------------------
applicaiont-eureka1.yml文件内容如下
eureka:
client:
service-url:
defaultZone: http://eureka2:8762/eureka/
# register-with-eureka: false
server:
enable-self-preservation: false
instance:
# prefer-ip-address: false
hostname: eureka1
spring:
application:
name: eureka
server:
port: 8761
---------------------------
applicaiont-eureka2.yml文件内容如下
eureka:
client:
service-url:
defaultZone: http://eureka1:8761/eureka/
# register-with-eureka: false
server:
enable-self-preservation: false
instance:
prefer-ip-address: false
hostname: eureka2
spring:
application:
name: eureka
server:
port: 8762
---------------------------
config工程对应的 application.yml文件内容如下
eureka:
client:
service-url:
defualtZone: http://eureka1:8761/eureka/,http://eureka2:8762/eureka/

spring:
application:
name: config
cloud:
config:
server:
git:
uri: https://gitee.com/heyitang123/config-repo.git
username: 18617xxxxxx
password: xxxxxx
basedir: /home/yml/
force-pull: true

management:
endpoints:
web:
exposure:
include: “*”
---------------------------
其它配置及代码与示例代码基本相同
---------------------------
********************************
现在出现的问题如下
********************************
不发布到rancher中,就在本地通过docker运行,eureka1和eureka2能够相互注册,相互复制,config能正常注册到eurek1和eureka2中
通过 http://eureka1:8761http://eureka2:8762, 访问一切正常。

如上代码通过bash build.sh 推送到阿里云后,再通过rancher-server,安装eureka1,eureka2,config 服务后,ureka1和eureka2能够相互注册,相互复制,但是config始终不能正常注册到eurek1和eureka2中
通过 http://192.168.16.42:8761 , http://192.168.16.42:8762,http://eureka1:8761, http://eureka2:8762 都能正常看到 ureka1和eureka2能够相互注册,相互复制,但就是看不到 config注册上去, 通过config工程的端口能够正常访问到 gitee中的配置文件。

写回答

4回答

廖师兄

2020-03-25

注册不上去,基本上可以确定是网络问题。

defualtZone: http://eureka1:8761/eureka/,http://eureka2:8762/eureka/

你可以在config所在的docker容器里,ping一下eureka1

你的rancher搭建在外网服务器吗?在外网可以发出来,我登录进去看看

0
3
廖师兄
回复
网络时空
从错误日志上来看就是网络问题,config和eureka使用的SpringCloud版本一样吗?你把它部署在公网上,地址发出来,我去看看。
2020-03-28
共3条回复

网络时空

提问者

2020-03-26

感谢师兄,问题终于解决了。原来是部署 config服务时,网络类型默认是 托管,它会从当前的网络段中请求一个指定的IP地址,如果此IP地址已经被使用则会分配一个随机IP,这样实际上是注册不到eureka的。要选择 网络类型为主机就马上正常了!

其实,也可以说是师兄提到的网络问题!感谢了!


正常图示如下,折腾了我两天的问题终于解决了!


//img.mukewang.com/szimg/5e7c30e30909a2f308340611.jpg

//img.mukewang.com/szimg/5e7c30e309a7f0b909360715.jpg


0
0

网络时空

提问者

2020-03-25

师兄好,我目前的 rancher是搭建我本地虚拟机中。

网络问题,我觉得可以排除,因为,我在config进入命令行后,进行如下操作均是通的
ping eureka1 和 telnet eureka1
ping eureka2 和 telnet eureka2

//img.mukewang.com/szimg/5e7b62a00983c05f07860653.jpg

//img1.sycdn.imooc.com/szimg/5e7b62a009d92d5a07250598.jpg


我感觉是不是哪里要做什么配置? 比如说只能通过域名访问,不能通过主机名访问?

0
0

网络时空

提问者

2020-03-25

config在 rancher的错误日志部分主要信息如下,大概意思好象是找不到eureka服务器,针对如下信息,我在网上也搜索了下,使用各种方法,还是未能解决这个问题,真是郁闷了!


-------------------------------------------------------

2com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:07:52    ... 29 common frames omitted
2020/3/25 下午6:07:52
2020/3/25 下午6:07:522020-03-25 10:07:52.551  WARN 1 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:07:522020-03-25 10:07:52.551  WARN 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG/4fe7b70ad689:config - registration failed Cannot execute request on any known server
2020/3/25 下午6:07:52
2020/3/25 下午6:07:52com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
2020/3/25 下午6:07:52    at
2020/3/25 下午6:07:522020-03-25 10:07:52.551  WARN 1 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator     : There was a problem with the instance info replicator
2020/3/25 下午6:07:52
2020/3/25 下午6:07:52com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

2020/3/25 下午6:09:22    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22
2020/3/25 下午6:09:222020-03-25 10:09:22.289  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2020/3/25 下午6:09:222020-03-25 10:09:22.289  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2020/3/25 下午6:09:222020-03-25 10:09:22.290  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2020/3/25 下午6:09:222020-03-25 10:09:22.290  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Application is null : false
2020/3/25 下午6:09:222020-03-25 10:09:22.290  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2020/3/25 下午6:09:222020-03-25 10:09:22.290  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2020/3/25 下午6:09:222020-03-25 10:09:22.290  INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2020/3/25 下午6:09:222020-03-25 10:09:22.295 ERROR 1 --- [freshExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error
2020/3/25 下午6:09:22
2020/3/25 下午6:09:22com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:09:22    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:194) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplications(AbstractJerseyEurekaHttpClient.java:165) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79) ~[eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1022) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:936) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1460) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1427) [eureka-client-1.7.0.jar!/:1.7.0]
2020/3/25 下午6:09:22    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22Caused by: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:09:22    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_111-internal]
2020/3/25 下午6:09:22    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar!/:4.5.3]
2020/3/25 下午6:09:22    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    ... 30 common frames omitted
2020/3/25 下午6:09:22
2020/3/25 下午6:09:222020-03-25 10:09:22.296  WARN 1 --- [freshExecutor-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:09:222020-03-25 10:09:22.297 ERROR 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG/4fe7b70ad689:config - was unable to refresh its cache! status = Cannot execute request on any known server
2020/3/25 下午6:09:22
2020/3/25 下午6:09:22com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG/4fe7b70ad689:config: registering service...
2020/3/25 下午6:09:222020-03-25 10:09:22.583 ERROR 1 --- [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error

2020/3/25 下午6:09:22
2020/3/25 下午6:09:22com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:09:22    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.7.0.jar!/:1.7.0]
com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
2020/3/25 下午6:09:22    ... 29 common frames omitted
2020/3/25 下午6:09:22
2020/3/25 下午6:09:222020-03-25 10:09:22.583  WARN 1 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused (Connection refused)
2020/3/25 下午6:09:222020-03-25 10:09:22.584  WARN 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CONFIG/4fe7b70ad689:config - registration failed Cannot execute request on any known server
2020/3/25 下午6:09:22
2020/3/25 下午6:09:22com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
2020/3/25 下午6:09:22    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111-internal]
2020/3/25 下午6:09:22
2020/3/25 下午6:09:222020-03-25 10:09:22.584  WARN 1 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator     : There was a problem with the instance info replicator
2020/3/25 下午6:09:22
2020/3/25 下午6:09:22com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

0
0

SpringCloud Finchley(M2+RELEASE+SR2)微服务实战

SpringCloud组件实现微服务,【已升级Finchley.Release】

5668 学习 · 2489 问题

查看课程