Admin 分布式監控
server端
首先引入依賴
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.1.1</version>
</dependency>
接着修改application類,加入@EnableAdminServer注解
修改yml檔案配置,具體的提醒之類的未設定。
server:
port: 8085
spring:
application:
name: admin
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
management:
endpoints:
web:
exposure:
include: "*"
最後加入logback-spring.xml,需要自行配置
client端
首先引入依賴,不需要加任何注解。
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.1</version>
</dependency>
直接啟動admin服務通路 http://localhost:8085/ 即可
yml可選配置參數
# 解決windows下運作時無法識别主機名的問題
spring.boot.admin.client.prefer-ip=true
server.port=7086
spring.application.name=zk_admin
eureka.instance.preferIpAddress=true
eureka.client.service-url.defaultZone=http://172.16.1.28:7082/eureka/,http://172.16.1.29:7082/eureka/
#定義各種額外的詳情給服務端顯示
#從pom.xml中擷取
info.app.name="@project.name@"
info.app.description="@project.description@"
info.app.version="@project.version@"
info.spring-boot-version="@project.parent.version@"
[email protected]@
#當機郵件提示
spring.mail.host=smtp.126.com
spring.mail.username=****
spring.mail.password=*****
spring.boot.admin.notify.mail.from=*****
spring.boot.admin.notify.mail.to=******
management.security.enabled=false
management.security.roles=SUPERUSER
security.user.name=xjgz2018
security.user.password=xjgz2018.
security.basic.enabled=false
#開啟shutdown的安全驗證
endpoints.health.sensitive= true
endpoints.cors.allowed-methods=HEAD,GET,POST
#啟用shutdown
endpoints.shutdown.enabled=true
#禁用密碼驗證
endpoints.shutdown.sensitive=false