博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Eureka-单节和集群的搭建
阅读量:2055 次
发布时间:2019-04-28

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

单节点搭建

1,pom依赖

org.springframework.cloud spring-cloud-starter-netflix-eureka-server 2,SpringBoot启动类
package com.wwl.eureka_server;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication@EnableEurekaServerpublic class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args); }}

3,yaml配置文件,application.yaml

spring:  application:    name: eureka-serverserver:  port: 7901# eureka配置eureka:  client:    fetch-registry: false    register-with-eureka: false    service-url:      defaultZone: http://eureka1:7901/eureka  instance:    hostname: eureka1

集群搭建

1,依赖

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

2,启动类开启Eureka

package com.wwl.eureka_server;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication@EnableEurekaServer // 开启Eurekapublic class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args); }}

3,Eureka注册中心配置(Eureka集群模式)

spring:  application:    name: eureka-server---spring:  profiles: eureka1server:  port: 7901eureka:  client:    service-url:      defaultZone: http://eureka1:7901/eureka,http://eureka2:7902/eureka,http://eureka3:7903/eureka  instance:    hostname: eureka1---spring:  profiles: eureka2server:  port: 7902eureka:  client:    service-url:      defaultZone: http://eureka2:7902/eureka,http://eureka1:7901/eureka,http://eureka3:7903/eureka  instance:    hostname: eureka2---spring:  profiles: eureka3server:  port: 7903eureka:  client:    service-url:      defaultZone: http://eureka3:7903/eureka,http://eureka1:7901/eureka,http://eureka2:7902/eureka  instance:    hostname: eureka3

注意问题:

Eureka集群模式在本地玩的时候,每个节点要配置hostname,并配置本地host文件

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

你可能感兴趣的文章
K-近邻算法:KNN
查看>>
solver及其配置
查看>>
图说C++对象模型:对象内存布局详解
查看>>
【Java基础】Java类的加载和对象创建流程的详细分析
查看>>
JAVA多线程之volatile 与 synchronized 的比较
查看>>
Java多线程知识点总结
查看>>
Java集合框架知识梳理
查看>>
java中IO流知识梳理
查看>>
word2010如何保持在公式后面键入空格后或添加文字不变小?
查看>>
笔试题(一)—— java基础
查看>>
笔试题(二)—— sql语句
查看>>
Redis学习笔记(二)— 在linux下搭建redis服务器
查看>>
Redis学习笔记(三)—— 使用redis客户端连接windows和linux下的redis并解决无法连接redis的问题
查看>>
Eclipse配置错误——An internal error occurred during: "Building workspace".GC overhead limit exceeded
查看>>
Intellij IDEA使用(一)—— 安装Intellij IDEA(ideaIU-2017.2.3)并完成Intellij IDEA的简单配置
查看>>
Intellij IDEA使用(二)—— 在Intellij IDEA中配置JDK(SDK)
查看>>
Intellij IDEA使用(三)——在Intellij IDEA中配置Tomcat服务器
查看>>
Intellij IDEA使用(四)—— 使用Intellij IDEA创建静态的web(HTML)项目
查看>>
Intellij IDEA使用(五)—— Intellij IDEA在使用中的一些其他常用功能或常用配置收集
查看>>
Intellij IDEA使用(六)—— 使用Intellij IDEA创建Java项目并配置jar包
查看>>