快捷搜索: 长连接 前端 源码 pan

Eureka - 服务手动剔除,恢复与不注册到Eureka

Eureka 注册中心 - 如果服务不想注册到Eureka Server ,可设置

spring.cloud.service-registry.auto-registration.enabled=false 
或
@EnableDiscoveryClient(autoRegister = false)

Eureka 注册中心 - 服务的手动剔除与恢复

最近在 SpringCloud 项目中发现 Eureka 注册中心的微服务会被异常的 DOWN 掉,但是微服务其实并没有宕机,如果想强行重新上线要如何操作呢?

返回状态:

HTTPCode: 200 为成功

HTTPCode: 404 续约失败,重新注册

接口说明:调用该接口进行心跳续约 调用说明:: http://{ip}:{port}/eureke/apps/{spring.application.name}/{eureka.instance.instance-id}

http://server1:8010/eureka/apps/{spring.application.name}/{eureka.instance.instance-id}

例如:

1. 强制恢复服务:UP

PUT 请求: http://server1:8010/eureka/apps/BOOK-SERVICE/book-service-01/status?value=UP

2. 强制下线服务:DOWN

PUT 请求: http://server1:8010/eureka/apps/BOOK-SERVICE/book-service-01/status?value=DOWN

3. 强制剔除服务:OUT_OF_SERVICE

PUT 请求: http://server1:8010/eureka/apps/BOOK-SERVICE/book-service-01/status?value=OUT_OF_SERVICE

警告:强制设置后状态将会覆盖真实状态,谨慎操作!!如果需要取消强制设置,将 PUT 请求改为 DELETE 请求即可!!!

注意:对于json/xml,提供的内容类型必须是application/xml或application/json。

Operation HTTP action Description 注册新应用程序实例 POST /eureka/v2/apps/appID Input: JSON/XMLpayload HTTPCode: 204 on success 取消注册应用程序实例 DELETE /eureka/v2/apps/appID/instanceID HTTP Code: 200 on success 发送应用程序实例检测信号 PUT /eureka/v2/apps/appID/instanceID HTTP Code: * 200 on success * 404 if instanceID doesn’t exist 查询所有实例 GET /eureka/v2/apps HTTP Code: 200 on success Output: JSON/XML 查询所有appID instances GET /eureka/v2/apps/appID HTTP Code: 200 on success Output: JSON/XML 查询特定的AppID/实例ID GET /eureka/v2/apps/appID/instanceID HTTP Code: 200 on success Output: JSON/XML 查询特定的instanceID GET /eureka/v2/instances/instanceID HTTP Code: 200 on success Output: JSON/XML 停止服务实例 PUT /eureka/v2/apps/appID/instanceID/status?value=OUT_OF_SERVICE HTTP Code: * 200 on success * 500 on failure 将实例移回服务(移除覆盖) DELETE /eureka/v2/apps/appID/instanceID/status?value=UP (The value=UP is optional, it is used as a suggestion for the fallback status due to removal of the override) HTTP Code: * 200 on success * 500 on failure Update metadata PUT /eureka/v2/apps/appID/instanceID/metadata?key=value HTTP Code: * 200 on success * 500 on failure 查询特定VIP地址下的所有实例 GET /eureka/v2/vips/vipAddress * HTTP Code: 200 on success Output: JSON/XML * 404 if the vipAddress does not exist. 查询特定安全VIP地址下的所有实例 GET /eureka/v2/svips/svipAddress * HTTP Code: 200 on success Output: JSON/XML * 404 if the svipAddress does not exist.
经验分享 程序员 微信小程序 职场和发展