Giter Site home page Giter Site logo

Comments (4)

eacdy avatar eacdy commented on July 17, 2024

@hurukawatinami 您好,将peer1注册到peer2,peer2注册到peer1即可。
您在两台机器无法成功注册,考虑是网络问题,例如A机器不知道B的主机名。可以去掉主机名(hostname)配置,直接用IP。

from spring-cloud-docker-microservice-book-code-docker.

hurukawatinami avatar hurukawatinami commented on July 17, 2024

@eacdy 我试过用ip地址,不行。

两个独立的eureka地址分别是:

http://192.168.159.211:7021
http://192.168.159.212:7022

下面是eureka的yml配置文件:

server:
  port: 7021
spring:
  profiles: test-211
eureka:
  instance:
    hostname: discovery-211        #Eureka实例的主机名
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
  client:
    serviceUrl:
      defaultZone: http://192.168.159.212:7022/eureka/  #Eureka节点相互注册
      register-with-eureka: true

---

server:
  port: 7022
spring:
  profiles: test-212
eureka:
  instance:
    hostname: discovery-212        #Eureka实例的主机名
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
  client:
    serviceUrl:
      defaultZone: http://192.168.159.211:7021/eureka/  #Eureka节点相互注册
      register-with-eureka: true

from spring-cloud-docker-microservice-book-code-docker.

eacdy avatar eacdy commented on July 17, 2024

我的意思是 你在192.168.159.211 机器上ping discovery-212 看能不能通;在192.168.159.212 上ping下ping discovery-211能不能通;如果不能通,要么配置主机名,让它能ping通,要么就直接改成:

# 公共部分
---
server:
  port: 7021
spring:
  profiles: test-211
eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
  client:
    serviceUrl:
      defaultZone: http://192.168.159.212:7022/eureka/  #Eureka节点相互注册
      register-with-eureka: true

---

server:
  port: 7022
spring:
  profiles: test-212
eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
  client:
    serviceUrl:
      defaultZone: http://192.168.159.211:7021/eureka/  #Eureka节点相互注册
      register-with-eureka: true

或者简写:

eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
  client:
    serviceUrl:
      defaultZone: http://192.168.159.212:7022/eureka/,http://192.168.159.211:7021/eureka/
---
server:
  port: 7021
spring:
  profiles: test-211
---
server:
  port: 7022
spring:
  profiles: test-212

from spring-cloud-docker-microservice-book-code-docker.

hurukawatinami avatar hurukawatinami commented on July 17, 2024

好的,谢谢老师。我先试试

from spring-cloud-docker-microservice-book-code-docker.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.