Spring Cloud Eureka的集群配置(六)

1、再次创建2个Eureka工程

工程名:microservicecloud-eureka-7002

工程名:microservicecloud-eureka-7003

2、pom.xml文件

<dependencies>
        <!--eureka-server服务端 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
</dependencies>

3、域名映射

找到 "C:\Windows\System32\drivers\etc\hosts" 文件,并在hosts文件中增加如下内容:

127.0.0.1 eureka7001.com
127.0.0.1 eureka7002.com
127.0.0.1 eureka7003.com

4、配置文件的修改

(1)工程 microservicecloud-eureka-7001 的 application.yml文件做如下修改:

server:
  port: 7001
eureka:
  instance:
    hostname: eureka7001.com #eureka服务端的实例名称
  client:
    register-with-eureka: false #false表示不向注册中心注册自己。Eureka不响自己注册
    fetch-registry: false       #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
    service-url:
      defaultZone: http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/

(2)工程 microservicecloud-eureka-7002 的 application.yml文件做如下修改:

server:
  port: 7002
eureka:
  instance:
    hostname: euraka7002.com #eureka服务端的实例名称
  client:
    register-with-eureka: false #false表示不向注册中心注册自己。Eureka不响自己注册
    fetch-registry: false       #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
    service-url:
      defaultZone: http://euraka7001.com:7001/eureka/,http://euraka7003.com:7003/eureka/

(3)工程 microservicecloud-eureka-7003 的 application.yml文件做如下修改:

server:
  port: 7003
eureka:
  instance:
    hostname: eureka7003.com #eureka服务端的实例名称
  client:
    register-with-eureka: false #false表示不向注册中心注册自己。Eureka不响自己注册
    fetch-registry: false       #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/

猜你喜欢

转载自www.cnblogs.com/yufeng218/p/10787752.html