一、环境部署
eureka 在本地的url
http://eureka.best.net:8761/
获取在eureka注册的所有服务
http://eureka.best.net:8761/eureka/apps/
获取在eureka注册的MY-SERVICE服务的所有节点
http://eureka.best.net:8761/eureka/apps/MY-SERVICE
二、服务发现
1、发送接口请求,获取服务节点信息
http://eureka.best.net:8761/eureka/apps/MY-SERVICE
报文结构,有3个节点,所以就有3个instance
一个instance 报文内容
{
"instanceId": "10.100.71.59:9088",
"hostName": "10.100.71.59",
"app": "MY-SERVICE",
"ipAddr": "10.100.71.59",
"status": "UP",
"overriddenStatus": "UNKNOWN",
"port": {
"$": 9088,
"@enabled": "true"
},
"securePort": {
"$": 443,
"@enabled": "false"
},
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"leaseInfo": {
"renewalIntervalInSecs": 5,
"durationInSecs": 15,
"registrationTimestamp": 1620617698704,
"lastRenewalTimestamp": 1620632779002,
"evictionTimestamp": 0,
"serviceUpTimestamp": 1620617698704
},
"metadata": {
"management.port": "9088",
"envflag": "normal",
"deployflag": "official"
},
"homePageUrl": "http://10.100.71.59:9088/",
"statusPageUrl": "http://10.100.71.59:9088/info",
"healthCheckUrl": "http://10.100.71.59:9088/health",
"vipAddress": "MY-SERVICE",
"secureVipAddress": "MY-SERVICE",
"isCoordinatingDiscoveryServer": "false",
"lastUpdatedTimestamp": "1620617698704",
"lastDirtyTimestamp": "1620617698588",
"actionType": "ADDED"
}
解析报文,
ipAddr 字段获取 ip ,status 字段获取状态,homePageUrl 字段获取请求url(包含ip和端口),
instance.get(i).get("metadata").get("envflag") ,获取节点别名(泳道标签)
网友评论