查看“Eureka 高可用集群搭建”的源代码
←
Eureka 高可用集群搭建
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看和复制此页面的源代码。
https://www.bilibili.com/video/BV1eU4y187zE/?p=13 最终效果: 编写一个项目通过不同的配置文件加载不同参数。 最后把集群部署到服务器上。集群设定有两个 Eureka Server,每个 Eureka Server 安装到不同的服务器上。 === 添加依赖 === 在集群中依赖和单机版是完全相同的。 为了后面打包发布到服务器中,所以同时也导入了 Spring Boot 打包插件。 === pom.xml === <syntaxhighlight lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>io.github.jihch</groupId> <artifactId>eureka-ha</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.3.RELEASE</version> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Hoxton.SR8</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 由于已经依赖的 web 所以不需要单独再导入一次 web --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> </syntaxhighlight> === application-eurekaserver1.yml === <syntaxhighlight lang="yaml"> spring: application: # 名字不要是下划线,要中划线 name: eureka-server server: port: 8761 eureka: instance: # 和配置文件的 application-xxx.yml 相同 hostname: eurekaserver1 client: service-url: defaultZone: http://eurekaserver2:8761/eureka/ </syntaxhighlight> === application-eurekaserver2.yml === <syntaxhighlight lang="yaml"> spring: application: # 名字不要是下划线,要中划线 name: eureka-server server: port: 8761 eureka: instance: # 和配置文件的 application-xxx.yml 相同 hostname: eurekaserver2 client: service-url: defaultZone: http://eurekaserver1:8761/eureka/ </syntaxhighlight> === hosts === <syntaxhighlight lang="console"> 192.168.0.120 eurekaserver1 192.168.0.100 eurekaserver2 </syntaxhighlight> === server.sh === [[Spring Boot 启动脚本]] === 注册 Eureka client 到 Eureka Server 中 === eureka-client<syntaxhighlight lang="yaml"> server: port: 8081 eureka: client: service-url: # 下面信息也是默认值 defaultZone: http://eurekaserver1:8761/eureka/,http://eurekaserver2:8761/eureka/ </syntaxhighlight> === 项目 === https://github.com/jihch/eureka-ha
返回至
Eureka 高可用集群搭建
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
Spring Boot 2 零基础入门
Spring Cloud
Spring Boot
设计模式之禅
VUE
Vuex
Maven
算法
技能树
Wireshark
IntelliJ IDEA
ElasticSearch
VirtualBox
软考
正则表达式
程序员精讲
软件设计师精讲
初级程序员 历年真题
C
SQL
Java
FFmpeg
Redis
Kafka
MySQL
Spring
Docker
JMeter
Apache
Linux
Windows
Git
ZooKeeper
设计模式
Python
MyBatis
软件
数学
PHP
IntelliJ IDEA
CS基础知识
网络
项目
未分类
MediaWiki
镜像
问题
健身
国债
英语
烹饪
常见术语
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息