При использовании Dubbo при весенней загрузке обнаружен "поставщик не доступен при регистрации"
Эта проблема возникает, когда потребители хотят получить значение zookeeper для локальной виртуальной машины Linux
Я использовал Springboot 2.1,Zookeeper находится на локальной виртуальной машине Linux. Я видел очень близкий ответ, но я не знаю, как его настроить. Адрес: https://blog.csdn.net/chenxiaochan/article/details/78776304. Он имеет в виду, что IP-адрес сервера, публикуемого службой Dubbo, использует DHCP, а не статический. И через его метод я запросил свой собственный ip, который действительно отличается от IP, зарегистрированного в реестре. Я также пытался отключить виртуальные сетевые карты, но это означает, что я не могу подключиться к локальной виртуальной машине Linux.
Мой провайдер application.properties
dubbo.application.name=provider-ticket
dubbo.registry.address=zookeeper://192.168.248.132:2181
dubbo.scan.base-packages=com.cq.providerticket.service
Мое потребительское приложение. Свойства
dubbo.application.name=consumer-user
dubbo.registry.address=zookeeper://192.168.248.132:2181
dubbo.consumer.check=false
dubbo.registry.check=false
server.port=8081
dubbo.protocol.host=192.168.248.132
dubbo.provider.host=192.168.248.132
команда Linux Dokcer
docker run --name zk01 -p 2181:2181 -p 20880:20880 --restart always -d zookeeperID
Это исключение, о котором сообщалось.
Caused by: com.alibaba.dubbo.rpc.RpcException: No provider available from registry 192.168.248.132:2181 for service com.cq.consumeruser.ticket.service.TicketService on consumer 10.12.78.96 use dubbo version 2.6.5, please check status of providers(disabled, not registered or in blacklist).
at com.alibaba.dubbo.registry.integration.RegistryDirectory.doList(RegistryDirectory.java:577)
at com.alibaba.dubbo.rpc.cluster.directory.AbstractDirectory.list(AbstractDirectory.java:74)
at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.list(AbstractClusterInvoker.java:277)
at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:238)
at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:75)
at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
at com.alibaba.dubbo.common.bytecode.proxy0.getTicket(proxy0.java)
... 38 more
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy61.getTicket(Unknown Source)
at com.cq.consumeruser.service.UserService.buyTicket(UserService.java:17)
at com.cq.consumeruser.ConsumerUserApplicationTests.contextLoads(ConsumerUserApplicationTests.java:21)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
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 com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.invoke(ReferenceAnnotationBeanPostProcessor.java:159)
... 33 more
1 ответ
Если вы используете docker в виртуальной машине Linux, система Linux запускается в виртуальной коробке или на VMware Workstation
- SSH в Linux
- vim / etc / sysconfig / network-scripts / ifcfg-eth0 или ifcfg-eth33
- измените BOOTPROTO=dhcp на BOOTPROTO = статический и установите IPADDR=192.168.248.132
- убедитесь, что порт 20880 и 2181 открыт через брандмауэр
Если вы используете Docker для Windows, Linux Virtual находится в Hyper-V, 192.168.248.132 IP-адрес вашего компьютера Windows
- установить dubbo.registry.address=zookeeper://localhost:2181
- установить dubbo.protocol.host = localhost и dubbo.provider.host = localhost