04:SpringCloud on Sentinel使用

1:SpringCloud on Nacos 创建Maven工程、注册、配置、Sentinel安装,笔者之前写过传送们门:


     1.1:https://blog.csdn.net/lucklilili/article/details/108245752 创建Maven工程、注册、配置

     1.2:   https://blog.csdn.net/lucklilili/article/details/108257317 Sentinel安装

2:配置Sentinel:

   2.1:bootstrap.yml

spring:
  application:
    name: provider-001
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
      config:
        server-addr: localhost:8848
        file-extension: yaml
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719

  2.2: application.yml

spring:
  profiles:
    active: dev
    #active: test
    #active: prod

   2.3:nacos dev配置 provider-001-dev.yaml

server:
    port: 1001
spring:
    datasource:
        name: test
        url: jdbc:mysql://localhost:3306/map?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
        username: root
        password: root
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        druid:
            filters: stat
            maxActive: 100
            initialSize: 1
            maxWait: 60000
            minIdle: 1
            timeBetweenEvictionRunsMillis: 60000
            minEvictableIdleTimeMillis: 300000
            validationQuery: select 'x'
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            poolPreparedStatements: true
            maxOpenPreparedStatements: 20
mybatis:
    mapper-locations: classpath:mapper/*.xml

management:
    endpoints:
        web:
        exposure:
        include: '*'
feign:
    sentinel:
        enabled: true    

 

3:使用 Sentinel:(第一次登陆sentinel会看不到自己的服务,随便请求下自己本地服务的openApi就可以)

4:验证是否成功:本次只配置了流控 ,接下来访问下试试,一秒钟点击两下,出现以下响应就算配置成功。

猜你喜欢

转载自blog.csdn.net/lucklilili/article/details/108285900