博客
关于我
spring cloud Eureka 的HA 高可用的实现
阅读量:389 次
发布时间:2019-03-05

本文共 1508 字,大约阅读时间需要 5 分钟。

新建一个项目:ms-eureka-ha-center

1.pom文件:

org.springframework.cloud
spring-cloud-starter-eureka-server

2.启动类:

package com.ljf.weifuwu.springcloud.ha.eureka;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;/** * Hello world! * */@SpringBootApplication@EnableEurekaServerpublic class EurekaHaApp{    public static void main( String[] args )    {        SpringApplication.run(EurekaHaApp.class,args);        System.out.println( "EurekaHaApp 高可用启动成功了!!!" );    }}

3.resources配置文件:

 

1.application.yml做为一个公共文件:

spring:  application:    name: ms-eureka-ha-center  profiles:    active: node1

2.application-node1.yml文件:

server:  port: 2001eureka:  instance:    hostname: node1  client:    serviceUrl:      defaultZone: http://node2:2002/eureka/,http://node3:2003/eureka/

3.application-node2.yml文件:

server:  port: 2002eureka:  instance:    hostname: node2  client:    serviceUrl:      defaultZone: http://node1:2001/eureka/,http://node3:2003/eureka/

4.application-node3.yml文件:

server:  port: 2003eureka:  instance:    hostname: node3  client:    serviceUrl:      defaultZone: http://node1:2001/eureka/,http://node2:2002/eureka/

3.不同端口的启动:

5.ip和节点名的映射:C:\Windows\System32\drivers\etc  修改host文件

6.启动访问:EurekaHaApp-node1、EurekaHaApp-node2、EurekaHaApp-node3 逐个启动,前面两个启动过程中可能会报错,可以忽略。

访问node1:

访问node2:

node3:

转载地址:http://pouzz.baihongyu.com/

你可能感兴趣的文章
mysql中出现Incorrect DECIMAL value: '0' for column '' at row -1错误解决方案
查看>>
mysql中出现Unit mysql.service could not be found 的解决方法
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
Mysql中各类锁的机制图文详细解析(全)
查看>>
MySQL中地理位置数据扩展geometry的使用心得
查看>>
Mysql中存储引擎简介、修改、查询、选择
查看>>
Mysql中存储过程、存储函数、自定义函数、变量、流程控制语句、光标/游标、定义条件和处理程序的使用示例
查看>>
mysql中实现rownum,对结果进行排序
查看>>
mysql中对于数据库的基本操作
查看>>
Mysql中常用函数的使用示例
查看>>
MySql中怎样使用case-when实现判断查询结果返回
查看>>
Mysql中怎样使用update更新某列的数据减去指定值
查看>>
Mysql中怎样设置指定ip远程访问连接
查看>>
mysql中数据表的基本操作很难嘛,由这个实验来带你从头走一遍
查看>>
Mysql中文乱码问题完美解决方案
查看>>
mysql中的 +号 和 CONCAT(str1,str2,...)
查看>>
Mysql中的 IFNULL 函数的详解
查看>>
mysql中的collate关键字是什么意思?
查看>>
MySql中的concat()相关函数
查看>>
mysql中的concat函数,concat_ws函数,concat_group函数之间的区别
查看>>