zoukankan      html  css  js  c++  java
  • Sentinel 控制台

     https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0

    下载最新版本的控制台 jar 包

    https://github.com/alibaba/Sentinel/releases

    https://github.com/alibaba/Sentinel/releases/download/1.8.2/sentinel-dashboard-1.8.2.jar

    根据你使用的Spring Cloud、Spring Boot、Spring Cloud Alibaba 版本下载对应的 Sentinel 版本

    https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E

     

     https://github.com/alibaba/Sentinel/releases/download/1.8.1/sentinel-dashboard-1.8.1.jar

    启动

    注意:启动 Sentinel 控制台需要 JDK 版本为 1.8 及以上版本。

    使用如下命令启动控制台:

    java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar

    其中 -Dserver.port=8080 用于指定 Sentinel 控制台端口为 8080

    从 Sentinel 1.6.0 起,Sentinel 控制台引入基本的登录功能,默认用户名和密码都是 sentinel。可以参考 鉴权模块文档 配置用户名和密码。

    注:若您的应用为 Spring Boot 或 Spring Cloud 应用,您可以通过 Spring 配置文件来指定配置,详情请参考 Spring Cloud Alibaba Sentinel 文档

    用户可以通过如下参数进行配置:

    • -Dsentinel.dashboard.auth.username=sentinel 用于指定控制台的登录用户名为 sentinel
    • -Dsentinel.dashboard.auth.password=123456 用于指定控制台的登录密码为 123456;如果省略这两个参数,默认用户和密码均为 sentinel
    • -Dserver.servlet.session.timeout=7200 用于指定 Spring Boot 服务端 session 的过期时间,如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟;

    同样也可以直接在 Spring properties 文件中进行配置。

    注意:部署多台控制台时,session 默认不会在各实例之间共享,这一块需要自行改造。

     
     

    控制台配置项

    控制台的一些特性可以通过配置项来进行配置,配置项主要有两个来源:System.getProperty() 和 System.getenv(),同时存在时后者可以覆盖前者。

    通过环境变量进行配置时,因为不支持 . 所以需要将其更换为 _

    配置项类型默认值最小值描述
    auth.enabled boolean true - 是否开启登录鉴权,仅用于日常测试,生产上不建议关闭
    sentinel.dashboard.auth.username String sentinel - 登录控制台的用户名,默认为 sentinel
    sentinel.dashboard.auth.password String sentinel - 登录控制台的密码,默认为 sentinel
    sentinel.dashboard.app.hideAppNoMachineMillis Integer 0 60000 是否隐藏无健康节点的应用,距离最近一次主机心跳时间的毫秒数,默认关闭
    sentinel.dashboard.removeAppNoMachineMillis Integer 0 120000 是否自动删除无健康节点的应用,距离最近一次其下节点的心跳时间毫秒数,默认关闭
    sentinel.dashboard.unhealthyMachineMillis Integer 60000 30000 主机失联判定,不可关闭
    sentinel.dashboard.autoRemoveMachineMillis Integer 0 300000 距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭
    sentinel.dashboard.unhealthyMachineMillis Integer 60000 30000 主机失联判定,不可关闭
    server.servlet.session.cookie.name String sentinel_dashboard_cookie - 控制台应用的 cookie 名称,可单独设置避免同一域名下 cookie 名冲突

    配置示例:

    • 命令行方式:
    java -Dsentinel.dashboard.app.hideAppNoMachineMillis=60000
    • Java 方式:
    System.setProperty("sentinel.dashboard.app.hideAppNoMachineMillis", "60000");
     
    • 环境变量方式:
    sentinel_dashboard_app_hideAppNoMachineMillis=60000
     
     
     
    为了方便快捷启动可以在桌面创建.bat文件
    java -Dserver.port=8858 -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=123456 -jar E:\SpringCloud\sentinel-dashboard-1.8.1.jar
    pause

     访问http://localhost:8858/#/login , 默认用户名/密码:sentinel/sentinel 

    客户端接入控制台

    引入JAR包

    客户端需要引入 Transport 模块来与 Sentinel 控制台进行通信。您可以通过 pom.xml 引入 JAR 包:

    <dependency>
        <groupId>com.alibaba.csp</groupId>
        <artifactId>sentinel-transport-simple-http</artifactId>
        <version>1.8.1</version>
    </dependency>
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <!--    <parent>-->
    <!--        <artifactId>springcloudalibaba</artifactId>-->
    <!--        <groupId>com.wsm.springcloud</groupId>-->
    <!--        <version>0.0.1-SNAPSHOT</version>-->
    <!--    </parent>-->
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.5.6</version>
            <relativePath></relativePath>
        </parent>
    
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>sentinel_demo</artifactId>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <!--            <version>2.5.5</version>-->
            </dependency>
    
            <!-- sentinel 核心库 -->
            <!-- https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-core -->
            <dependency>
                <groupId>com.alibaba.csp</groupId>
                <artifactId>sentinel-core</artifactId>
                <version>1.8.1</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.22</version>
                <scope>provided</scope>
            </dependency>
    
            <!-- 如果要使用@SentinelResource -->
            <!-- https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-annotation-aspectj -->
            <dependency>
                <groupId>com.alibaba.csp</groupId>
                <artifactId>sentinel-annotation-aspectj</artifactId>
                <version>1.8.1</version>
            </dependency>
    
            <!-- 整合控制台 -->
            <!-- https://mvnrepository.com/artifact/com.alibaba.csp/sentinel-transport-simple-http -->
            <dependency>
                <groupId>com.alibaba.csp</groupId>
                <artifactId>sentinel-transport-simple-http</artifactId>
                <version>1.8.1</version>
            </dependency>
    
        </dependencies>
    
    </project>

     配置启动参数

    启动时加入 JVM 参数 -Dcsp.sentinel.dashboard.server=consoleIp:port 指定控制台地址和端口。若启动多个应用,则需要通过 -Dcsp.sentinel.api.port=xxxx 指定客户端监控 API 的端口(默认是 8719)。

    从 1.6.3 版本开始,控制台支持网关流控规则管理。您需要在接入端添加 -Dcsp.sentinel.app.type=1 启动参数以将您的服务标记为 API Gateway,在接入控制台时您的服务会自动注册为网关类型,然后您即可在控制台配置网关规则和 API 分组。

    除了修改 JVM 参数,也可以通过配置文件取得同样的效果。更详细的信息可以参考 启动配置项

  • 相关阅读:
    dbt macro 说明
    构建一个dbt 数据库适配器
    dbt 包的构建
    dbt 生产环境使用
    来自官方的一些dbt 最佳实践
    knowledge-repo 知识管理简单试用
    dbt 包管理
    dbt 的知识文档管理
    knowledge 开源知识管理系统
    hasura graphql server 集成gitlab
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15619754.html
Copyright © 2011-2022 走看看