【HAVENT原创】Eureka 注册中心 - 服务的手动剔除与恢复

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

 

Eureka Rest接口- 心跳续约
接口地址: /eureka/apps/appID/instanceID
调用方式:PUT
源码地址:com.netflix.eureka.resources.InstanceResource.renewLease()

返回状态:

          HTTPCode: 200 为成功

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


接口说明:调用该接口进行心跳续约
调用说明:http://server1:8010/eureka/apps/{微服务名称Application}/{服务instanceID}

 

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 请求即可!!!

 

For JSON/XML, the content types supplied must be application/xml or application/json.

OperationHTTP actionDescription
Register new application instancePOST /eureka/v2/apps/appIDInput: JSON/XMLpayload HTTPCode: 204 on success
De-register application instanceDELETE /eureka/v2/apps/appID/instanceIDHTTP Code: 200 on success
Send application instance heartbeatPUT /eureka/v2/apps/appID/instanceIDHTTP Code:
* 200 on success
* 404 if instanceID doesn’t exist
Query for all instancesGET /eureka/v2/appsHTTP Code: 200 on success Output: JSON/XML
Query for all appID instancesGET /eureka/v2/apps/appIDHTTP Code: 200 on success Output: JSON/XML
Query for a specific appID/instanceIDGET /eureka/v2/apps/appID/instanceIDHTTP Code: 200 on success Output: JSON/XML
Query for a specific instanceIDGET /eureka/v2/instances/instanceIDHTTP Code: 200 on success Output: JSON/XML
Take instance out of servicePUT /eureka/v2/apps/appID/instanceID/status?value=OUT_OF_SERVICEHTTP Code:
* 200 on success
* 500 on failure
Move instance back into service (remove override)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 metadataPUT /eureka/v2/apps/appID/instanceID/metadata?key=valueHTTP Code:
* 200 on success
* 500 on failure
Query for all instances under a particular vip addressGET /eureka/v2/vips/vipAddress
* HTTP Code: 200 on success Output: JSON/XML 
* 404 if the vipAddress does not exist.
Query for all instances under a particular secure vip addressGET /eureka/v2/svips/svipAddress
* HTTP Code: 200 on success Output: JSON/XML 
* 404 if the svipAddress does not exist.


 

转载于:https://my.oschina.net/u/943746/blog/2248156

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值