一、Eureka 简介
服务发现技术选型
二、Spring Cloud Eureka 入门案例
1、在浏览器输入:
2、在浏览器输入:
?1[/code>applicationsversions__delta8081enabled="false">443
[/code>name
三、 REST API实例
1、查询所有应用示例
1、命令
?1curl -i 192.168.118.30:8761/eureka/apps
2、输出
1 HTTP/1.1 200
2 Content-Type: application/xml
3 Transfer-Encoding: chunked
4 Date: Thu, 08 Nov 2018 08:40:36 GMT
5
6
7 1
8 UP_1_
9
10 DEMO-CLIENT1
11
12 LAH:demo-client1:8081
13 LAH
14 DEMO-CLIENT1
15 192.168.118.30
16 UP
17 UNKNOWN
18
19
20 1
21
22 MyOwn
23
24
25 30
26 90
27 1541662811411
28 1541666502900
29 0
30 1541660845280
31
32
33 8081
34 55850
35
36
37
38
39 demo-client1
40 demo-client1
41 false
42 1541662811412
43 1541662811343
44 ADDED
45
46
查询所有应用示例
2、根据appid查询
1、命令
?1curl -i 192.168.118.30:8761/eureka/apps/DEMO-CLIENT1
2、输出结果
1 HTTP/1.1 200
2 Content-Type: application/xml
3 Transfer-Encoding: chunked
4 Date: Thu, 08 Nov 2018 09:00:54 GMT
5
6
7 DEMO-CLIENT1
8
9 LAH:demo-client1:8081
10 LAH
11 DEMO-CLIENT1
12 192.168.118.30
13 UP
14 UNKNOWN
15
16
17 1
18
19 MyOwn
20
21
22 30
23 90
24 1541662811411
25 1541667733506
26 0
27 1541660845280
28
29
30 8081
31 55850
32
33
34
35
36 demo-client1
37 demo-client1
38 false
39 1541662811412
40 1541662811343
41 ADDED
42
根据appid查询
3、查询不到的返回结果
?12345【root@kakfa ~】# curl -i 192.168.118.30:8761/eureka/apps/DEMO-CLIENT2HTTP/1.1 404Content-Type: application/xmlContent-Length: 0Date: Thu, 08 Nov 2018 09:02:31 GMT
3、根据appid及instanceld查询
?12345【root@kakfa ~】# curl -i 192.168.118.30:8761/eureka/apps/DEMO-CLIENT2/notfoundHTTP/1.1 404Content-Type: application/xmlContent-Length: 0Date: Thu, 08 Nov 2018 09:05:30 GMT
4、根据instanceld查询
?12345678910111213141516【root@ccb-manage ccb-backend-8080】# curl -i 401WWW-Authenticate: Basic realm="Spring"X-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=blockCache-Control: no-cache, no-store, max-age=0, must-revalidatePragma: no-cacheExpires: 0X-Frame-Options: DENYStrict-Transport-Security: max-age=31536000 ; includeSubDomainsContent-Type: application/json;charset=UTF-8Transfer-Encoding: chunkedDate: Thu, 08 Nov 2018 09:15:24 GMT {"timestamp":1541668524776,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/eureka/apps/instances/192.168.0.134:8090"}/
resource","path":"/eureka/apps/instances/192.168.0.142:8080"}
查询不到返回的结果
?12345【root@kakfa ~】# curl -i 192.168.118.30:8761/eureka/apps/instances/LAH:demo-client1:8081HTTP/1.1 404Content-Type: application/xmlContent-Length: 0Date: Thu, 08 Nov 2018 09:07:40 GM
5、注册新的应用实例
6、注销应用实例
?1curl -i -X
7、暂停下线应用实例
?1curl -i -X PUT
找不到该实例