spring cloud admin分布式监控
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="@[email protected]"
info.app.description="@[email protected]"
info.app.version="@[email protected]"
info.spring-boot-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