From 88d8d4abd3859318a1037fd02f273df1f5babcdf Mon Sep 17 00:00:00 2001
From: Rikako Wu <496063163@qq.com>
Date: Mon, 27 Mar 2023 18:28:44 +0800
Subject: [PATCH] =?UTF-8?q?spring=20cloud=20=E6=96=87=E6=A1=A3=E9=98=85?=
=?UTF-8?q?=E8=AF=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
spring/Spring Cloud/Spring Cloud Netflix.md | 35 +++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/spring/Spring Cloud/Spring Cloud Netflix.md b/spring/Spring Cloud/Spring Cloud Netflix.md
index c484576..dd4376c 100644
--- a/spring/Spring Cloud/Spring Cloud Netflix.md
+++ b/spring/Spring Cloud/Spring Cloud Netflix.md
@@ -82,3 +82,38 @@ public String serviceUrl() {
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
```
+### Eureka Server的启动
+如下显示了要启动一个Eureka Server的最简代码:
+```java
+@SpringBootApplication
+@EnableEurekaServer
+public class Application {
+
+ public static void main(String[] args) {
+ new SpringApplicationBuilder(Application.class).web(true).run(args);
+ }
+
+}
+```
+在`/eureka/*`路径下,该eureka server拥有UI和http api endpoint。
+### 高可用
+Eureka Server并没有后端存储,但是注册到Eureka Server中的所有service实例都必须向eureka server发送心跳包来保证其注册状态是最新的,上述所有操作都是在eureka server的内存中完成的。
+client端也会在内存中对eureka server中的注册状态进行缓存,故而无需每次请求其他service时都要从eureka server中获取注册状态。
+> 默认情况下,每个eureka server都同时是一个client,并且需要至少一个URL来定位其他的service实例。
+
+### 单机模式
+单机模式下,可以通过如下配置来关闭客户端的行为:
+```yml
+server:
+ port: 8761
+
+eureka:
+ instance:
+ hostname: localhost
+ client:
+ registerWithEureka: false
+ fetchRegistry: false
+ serviceUrl:
+ defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
+```
+