3、阿里云服务器SpringBoot2.x生产环境部署实战 简介:讲解SpringBoot生产环境部署和常见注意事项 1、去除相关生产环境没用的jar 比如热部署dev-tool 2、本地maven打包成jar包 mvn clean package -Dmaven.test.skip=true 跳过测试 3、服务器安装jdk,上传Jar包 上传工具: windows: winscp securtyCRT mac: filezilla ssh root@120.79.160.143 访问路径 http://120.79.160.143:8080/api/v1/user/find java -jar xxxx.jar 守护进程、系统服务、shell脚本 打包指定配置文件 1、使用maven的profiles 2、使用springboot的profile=active 访问不了 1、阿里云防火墙是否开启,可以选择关闭,关闭是不安全的,可以选择开放端口 2、阿里云的安全访问组,开启对应的端口,如果应用是以80端口启动,则默认可以访问 4、成熟的互联网公司应该有的架构 本地提交生产代码->gitlab仓库->Jenkins自动化构建->运维或者开发人员发布 4、SpringBoot2.x监控Actuator实战上集 简介:讲解SpringBoot使用actuator监控配置和使用 可用性:100%,99.9% 1、介绍什么是actuator 官方介绍: Spring Boot包含许多附加功能,可帮助您在将应用程序投入生产时监视和管理应用程序。 可以选择使用HTTP端点或JMX来管理和监控您的应用程序,自动应用于审计,健康和指标收集; 一句话:springboot提供用于监控和管理生产环境的模块 官方文档:https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#production-ready 2、加入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> 3、加入上述依赖后,访问几个url /actuator/health /actuator/info /actuator 5、SpringBoot2.x监控Actuator实战下集及生产环境建议(核心知识) 简介:SpringBoot2.x监控Actuator实战下集及生产环境建议,SpringBoot新旧版本区别 注意点: 网上的资料大多数没有讲到访问的前缀 端点基础路径由 / 调整到 /actuator 如:/info调整为/actuator/info /actuator/xxx 1、只能访问几个url 1)需要在配置文件中加入下列配置 management.endpoints.web.exposure.include=* 2)官网说明:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-security-actuator 原因: 出于安全考虑,除/ health和/ info之外的所有执行器默认都是禁用的。 management.endpoints.web.exposure.include属性可用于启用执行器 2、建议 在设置management.endpoints.web.exposure.include之前,请确保暴露的执行器不包含敏感信息和/ 或通过将其放置在防火墙进行控制,不对外进行使用 禁用的端点将从应用程序上下文中完全删除。如果您只想更改端点所暴露的技术,请改用 include和exclude属性 。 例子: 开启全部:management.endpoints.web.exposure.include=* 开启某个:management.endpoints.web.exposure.include=metrics 关闭某个:management.endpoints.web.exposure.exclude=metrics 或者用springadmin进行管理 相关资料:https://www.cnblogs.com/ityouknow/p/8440455.html 或者用自己编写脚本监控 CPU、内存、磁盘、nginx的http响应状态码200,404,5xx 3、介绍常用的几个 /health 查看应用健康指标 /actuator/metrics 查看应用基本指标列表 /actuator/metrics/{name} 通过上述列表,查看具体 查看具体指标 /actuator/env 显示来自Spring的 ConfigurableEnvironment的属性