zoukankan      html  css  js  c++  java
  • 不间断重启springboot项目

    前提:

    服务至少要部署两台机上,当其中一台下线后,由另一台提供对外服务

    1,依赖

     <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
        </dependencies>
    
    
    
    
     <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Hoxton.SR3</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
    
            </dependencies>
        </dependencyManagement>

    application.yml 配置

    management.endpoint.shutdown.enabled=true
    management.endpoint.health.show-details=always
    management.endpoints.web.exposure.include=*
    #微服务上线请求
    curl -H "Content-Type:application/vnd.spring-boot.actuator.v2+json;charset=UTF-8" -X POST http://localhost:2{{ port }}/actuator/service-registry?status=UP

    #微服务下线请求
    curl -H "Content-Type:application/vnd.spring-boot.actuator.v2+json;charset=UTF-8" -X POST http://localhost:2890/actuator/service-registry?status=DOWN

    #eureka 小知识
    >eureka 清理过期服务的时间间隔是0s,即不清理实例
    ```yaml
    eureka.server.eviction-interval-timer-in-ms

    ```

    >eureka 客户端配置

    eureka 服务端如果发现客户端在这个时间段内没有收到心跳,会将客户端下线
    默认值90s
    ```yaml
    eureka.instance.lease-expiration-duration-in-seconds
    ```

    >客户端通过eureka.instance.lease-renewal-interval-in-seconds
    每隔这个时间会主动心跳一次,默认值为30s,更新自己的状态。

  • 相关阅读:
    ubuntu 解决“无法获得锁 /var/lib/dpkg/lock -open (11:资源暂时不可用)”的方法
    解决VMware安装ubuntu16.04后无法全屏的问题
    力推:无限制下载神器aria2
    使用Pangolon在同一副图中,画出两个轨迹,比较误差
    Pangolin中opengl的混合(gl_blend)
    Ubuntu 16.04: How to install OpenCV
    ubuntu16.04下安装Eigen
    ubuntu16.04下安装Sophus
    svn删除账户信息
    javaweb乱码(tomcat服务器)
  • 原文地址:https://www.cnblogs.com/dongma/p/14727796.html
Copyright © 2011-2022 走看看