springCloud eureka 注册中心集群中各个服务注册中心不能相互跳转问题


如下图,配置好服务注册中心集群后

 

 

注: 服务名是之前配的,配了ip就是显示ip,如下配置文件中设置了ip,上图只做参考 

 

配置文件如下

第一个注册中心配置

#配置服务端口
server:
  port: 5121

#关闭eureka的自我注册与发现
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.53:5121/eureka,http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.54:5121/eureka
  instance:
    hostname: 120.25.209.52   #主机名可以设置成服务器ip


#开启eureka安全认证
security:
  basic:
    enabled: true

#设置安全认证的凭证
spring:
  security:
    user:
      name: root
      password: root

 

第二个注册中心配置

#配置服务端口
server:
  port: 5121

#关闭eureka的自我注册与发现
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.52:5121/eureka,http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.54:5121/eureka
  instance:
    hostname: 120.25.209.53   #主机名可以设置成服务器ip


#开启eureka安全认证
security:
  basic:
    enabled: true

#设置安全认证的凭证
spring:
  security:
    user:
      name: root
      password: root

第三个就不放了,同理

以上配置下无法跳转至另外两个服务注册中心

 

解决方法

经过多次测试得出

120.25.209.52:5121/eureka 中的/eureka去掉就可以实现相互的访问


即!改为如下,三个都需要改

#配置服务端口
server:
  port: 5121

#关闭eureka的自我注册与发现
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.52:5121,http://${spring.security.user.name}:${spring.security.user.password}@120.25.209.54:5121
  instance:
    hostname: 120.25.209.53   #主机名可以设置成服务器ip


#开启eureka安全认证
security:
  basic:
    enabled: true

#设置安全认证的凭证
spring:
  security:
    user:
      name: root
      password: root


具体的原因还不是很清楚,后续知晓后更新,欢迎大佬解答


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM