prontera / spring-cloud-rest-tcc

以Spring Cloud Netflix作为服务治理基础, 展示基于tcc思想所实现的分布式事务解决方案
2.58k stars 1.21k forks source link

docker-compose启动项目时遇到的问题 #13

Closed jiulingchen closed 7 years ago

jiulingchen commented 7 years ago

按照文档的约定分别启动了 1.basic-ms-compose.yml 2.business-ms-compose.yml

当启动[2]的时候就会抛出异常

2017-06-27 11 29 30

在[1]中,则直接显示docker state:Exit 137 具体日志没有任何提示信息

2017-06-27 11 36 27
prontera commented 7 years ago

@jiulingchen 在启动business-ms-compose.yml之前是否留有充分的预热时间给basic-ms-compose.yml

jiulingchen commented 7 years ago

@prontera 当给予足够的预热时间,同时启动了infrastructure-compose.yml、basic-ms-compose.yml、monitor-ms-compose.yml三个compose的时候,还是会出现config-server-ms docker state Exit: 137

2017-06-27 7 09 52

个人认为:是否这个地方的git.url并不能取到相应的yml文件

prontera commented 7 years ago

每个compose之间启动的相隔时间我们称之为预热时间,你同时启动infrastructure, basic和monitor是肯定不行的。infrastructure作为mysql和mq的基础组件需要先启动,如果你是首次启动那么这个时间将会更长。确认infrastructure完全配置完成后再启动basic compose,这个compose是注册中心和config配置中心,如果这两个核心组件并未完全配置就启动下一个compose的话,那么势必会造成异常。

注意,这里的启动可以理解成docker-compose up命令,而完全配置则理解为业务上的完全startup,如spring boot控制台告知你started in xx sec的时候,此时才称之为完全配置。

jiulingchen commented 7 years ago

在单独启动eureka-registry-ms的时候,是否会出现以下异常信息: com.netflix.discovery.DiscoveryClient : DiscoveryClient_REGISTRY/192.168.8.195:registry:8762 - was unable to refresh its cache! status = Cannot execute request on any known server

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

prontera commented 7 years ago

会,这是正常的。

jiulingchen commented 7 years ago

@prontera 在启动business-ms-compose.yml的时候会,会强制性的关闭掉config-server服务,以及gateway和boot_admin的服务,不知道是什么原因造成的呢?

prontera commented 7 years ago

抱歉这个问题我目前还没遇过,不过我对你提出的这个情况很感兴趣,希望能在解决该问题之后也能继续反馈,让我也学习一下。

jiulingchen commented 7 years ago

执行account-ms时提示异常: java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:130) at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$FastClassBySpringCGLIB$$fa44b2a.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:74) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:276) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:157) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:101) at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656) at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator$$EnhancerBySpringCGLIB$$54c8441c.locate(<generated>) at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:89) at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:636) at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:350) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176) at com.github.prontera.AccountMsApplication.main(AccountMsApplication.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/account/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:666) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:170) at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:91) ... 27 common frames omitted 请问这个怎么解决呢!

prontera commented 7 years ago

请先确认config-ms是否已经启动。

jiulingchen commented 7 years ago

在启动account-ms成功的时候,当启动order-ms、product-ms或membership-ms其中任意一个服务会自动停止account-ms服务,开启当前启动的服务。这个是什么情况?

jiulingchen commented 7 years ago

@prontera 我已找到原因了,请问你的电脑是什么配置 内存 及CPU

prontera commented 7 years ago

哈哈真的是缘分啊,我刚也测试完毕。 我启动用docker compose启动各个服务,在spring boot admin的监控版有如下服务被注册:

ACCOUNT (bfbaf1b5) CONFIG-SERVER (3cfc27e3) GATEWAY (b9d0761b) HYSTRIX (09671a09) MEMBERSHIP (8e59484a) ORDER (cb8d109e) REGISTRY (45163ced) REGISTRY (2cfea436) SPRING-BOOT-ADMIN (11e288aa) TCC (f0e2aea0)

共计10个ms被启动,其中zipkin没有注册到eureka所以没有被显示出来,在完成启动后鄙人也下了几笔订单,皆为正常,并未发现有任何服务挂掉。 本人开发用机的CPU为2.9 GHz Intel Core i5,内存为16 GB 2133 MHz LPDDR3。 感觉服务挂掉的情况有可能是物理内存不足,只是个人感觉,并无任何的实际论据作为支撑。

jiulingchen commented 7 years ago

@prontera 是的,就是物理内存的问题造成的,会自动kill掉已启动的服务。本人正在寻找怎么使用cgroups来治理服务资源问题。

prontera commented 7 years ago

好的,如有其他问题欢迎新开issue。