ityouknow / blog-comments

15 stars 0 forks source link

springcloud(十三):Eureka 虽然闭源了,但注册中心还有更多选择:Consul 使用详解 - 纯洁的微笑博客 #172

Open ityouknow opened 6 years ago

ityouknow commented 6 years ago

http://www.ityouknow.com/springcloud/2018/07/20/spring-cloud-consul.html

Spring Cloud Consul 使用详解

gistmap commented 6 years ago

感觉作者有精力的话可以开个consul的专栏,期待

yijian0645 commented 6 years ago

你好,下载了你的例子,但发现在“我们发现页面多了 service-producer 服务,点击进去后页面显示有两个服务提供者:”这块我启动了spring-cloud-consul-producer也启动了consul服务,但是在http://localhost:8500中刷新还是看不到service-producer 服务,有可能是什么原因呢?

我用的spring boot是2.0.4的,先谢谢了

soulmz commented 6 years ago

问一下,consul server 和 client 对于 SpringCloud 来说应该接入那个?

说下我理解方式,不知道对不对。

consul server 模式 在服务器内网集群。

consul client 模式(加入consul server集群) 对 SpringCloud 多个微服务

是否这样运作?

hduhans commented 6 years ago

请教一下大神,consul部署了集群的情况下,spring boot需要连接集群,其中 spring.cloud.consul.host 如何配置到集群中呢?默认只支持配置一个 agent 的话不是存在单点故障问题吗? 请了解的帮解答下,3k

rofemen commented 6 years ago

按你的配置中spring cloud包里面是有引用到RelaxedDataBinder但是在sping-boot 2.0中该类所在的包已经被删除,请问这边怎么处理的哈

tlxlggg commented 5 years ago

consul到底是属于ca呢还是cp呢?

SauchinWu commented 5 years ago

“添加完 ServiceController 之后我们启动项目,访问地址:http://localhost:8505/services,返回:[]”,服务信息返回为空请问是什么原因呢

GreedyPirate commented 5 years ago

麻烦改下consul的cap类型,应该是cp,我看到好多人被误导了

guojinlong commented 5 years ago

@tlxlggg consul到底是属于ca呢还是cp呢?

CP

bobobo1114 commented 5 years ago

@tlxlggg consul到底是属于ca呢还是cp呢? cp,c表示一致性,p表示容错性,p是服务发现组件必须要实现的,作者有误。

@hduhans 请教一下大神,consul部署了集群的情况下,spring boot需要连接集群,其中 spring.cloud.consul.host 如何配置到集群中呢?默认只支持配置一个 agent 的话不是存在单点故障问题吗? 请了解的帮解答下,3k

consul集群,spring.cloud.consul.host目前还不能配置集群,所以consul我觉得不是一个好的服务注册中心,并且consul还有个严重的问题,就是不能自动剔除掉已经失效的服务,4年前就有人在讨论这个问题了(https://github.com/hashicorp/consul/issues/1188)。

TodayIsSunShine commented 5 years ago

获取service-producer报空指针异常了,有没有大佬和我一样的?注册中心可以看到已经注册了

wucao commented 5 years ago

Consul是CP不是CA,文中有误

官方文档: https://www.consul.io/intro/vs/serf.html

In CAP terms, Consul uses a CP architecture, favoring consistency over availability.

ityouknow commented 5 years ago

@wucao Consul是CP不是CA,文中有误

官方文档: https://www.consul.io/intro/vs/serf.html

In CAP terms, Consul uses a CP architecture, favoring consistency over availability.

已经修改,谢谢提醒。

zuoshoudao commented 5 years ago

下载了代码启动producer 控制台报: Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/Assert at org.springframework.boot.SpringApplication.(SpringApplication.java:263) at org.springframework.boot.SpringApplication.(SpringApplication.java:247) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.neo.consul.ConsulProducerApplication.main(ConsulProducerApplication.java:12) Caused by: java.lang.ClassNotFoundException: org.springframework.util.Assert at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

这个问题有人遇到过么

FuXiangxin commented 5 years ago

@TodayIsSunShine 获取service-producer报空指针异常了,有没有大佬和我一样的?注册中心可以看到已经注册了

直接用博主的源码没问题。 我自个弄的一个项目也遇到跟你一样的问题了...

lisir123456 commented 5 years ago

@TodayIsSunShine 获取service-producer报空指针异常了,有没有大佬和我一样的?注册中心可以看到已经注册了

服务名出现了问题 我把ServiceController中的service-producer改成spring-cloud-consul-producer就好使了

lmfxuegit commented 5 years ago

学习了

qq1012405911 commented 5 years ago

赞一个

sc2885112 commented 4 years ago

请问作者,前端如果要直接访问消费者,url如何拼写

QingwenL commented 4 years ago

666

cyx441984694 commented 3 years ago

Error: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.netflix.hystrix.HystrixAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2437c6dc] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:726) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:667) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:635) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:420) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:390) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:511) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1198) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:889) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:875) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:861) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:810) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at com.neo.consul.ConsulProducerApplication.main(ConsulProducerApplication.java:11) ~[classes/:na] Caused by: java.lang.NoClassDefFoundError: io/micrometer/core/instrument/binder/hystrix/HystrixMetricsBinder at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na] at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na] at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 20 common frames omitted Caused by: java.lang.ClassNotFoundException: io.micrometer.core.instrument.binder.hystrix.HystrixMetricsBinder at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na] ... 24 common frames omitted

cyx441984694 commented 3 years ago

解决了。。。。依赖包问题。。