zoukankan      html  css  js  c++  java
  • SpringCloud集群(三)

    一、构造步骤

    1、进行其他的服务中心的域名映射

    127.0.0.1 eureka7001.com

    127.0.0.1 eureka7002.com

    127.0.0.1 eureka7003.com

    2、修改microservicecloud-eureka-7001 yml文件

    server:
      port: 7001
      ###eureka 基本信息配置
    eureka:
      instance:
            ###注册到eurekaip地址
        hostname: eureka7001.com #eureka服务端的实例名称
      client:
        service-url:
          defaultZone:  http://localhost:7002/eureka/,http://localhost:7003/eureka/
            ###因为自己是为注册中心,不需要自己注册自己
        register-with-eureka: false #表示不像注册中心注册自己
        ###因为自己是为注册中心,不需要检索服务
        fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务

    3、microservicecloud-eureka-7002 eureka服务注册中心Module 

    新建工程microservicecloud-eureka-7002,创建完成后请回到父工程查看pom文件变化

    pom文件

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

    yml文件

    server:
      port: 7002
      ###eureka 基本信息配置
    eureka:
      instance:
            ###注册到eurekaip地址
        hostname: eureka7002.com #eureka服务端的实例名称
      client:
        service-url:
          defaultZone:  http://localhost:7001/eureka/,http://localhost:7003/eureka/  #单机  设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址(单机)。
            ###因为自己是为注册中心,不需要自己注册自己
        register-with-eureka: false #表示不像注册中心注册自己
        ###因为自己是为注册中心,不需要检索服务
        fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务

    主启动类

    @SpringBootApplication
    @EnableEurekaServer // EurekaServer服务器端启动类,接受其它微服务注册进来
    public class SpringCloudService7002_APP {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringCloudService7002_APP.class);
        }
    }

    4、microservicecloud-eureka-7003 eureka服务注册中心Module 

    新建工程microservicecloud-eureka-7003,创建完成后请回到父工程查看pom文件变化

     pom文件

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

    yml文件

    server:
      port: 7003
      ###eureka 基本信息配置
    eureka:
      instance:
            ###注册到eurekaip地址
        hostname: eureka7003.com #eureka服务端的实例名称
      client:
        service-url:
          defaultZone:  http://localhost:7002/eureka/,http://localhost:7003/eureka/
            ###因为自己是为注册中心,不需要自己注册自己
        register-with-eureka: false #表示不像注册中心注册自己
        ###因为自己是为注册中心,不需要检索服务
        fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务

     启动主启动类

    @SpringBootApplication
    @EnableEurekaServer // EurekaServer服务器端启动类,接受其它微服务注册进来
    public class SpringCloudService7003_APP {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringCloudService7003_APP.class);
        }
    }

     5、启动测试

    http://eureka7002.com:7002/,

    http://eureka7001.com:7001/,

    http://eureka7003.com:7003/

    效果:

  • 相关阅读:
    叉积与点积
    Vector3 *2 ,ToString()自动四舍五入
    "无法删除数据库,因为该数据库当前正在使用"问题解决
    感谢信
    实变函数一窥
    北京大学2015年数学分析考研试题
    象棋是门残忍的艺术---续篇
    象棋是门残忍的艺术
    赣南师范学院教师高级专业技术资格评审委员会评审通过人员公示名单
    [再寄小读者之数学篇](2014-12-24 乘积型不等式)
  • 原文地址:https://www.cnblogs.com/cxyyh/p/10645663.html
Copyright © 2011-2022 走看看