在生产环境中使用sentinel

在生产环境中,我们可以使用拉模式或者推模式来实现规则的持久化,但是都需要一些配置,这里介绍阿里云的sentinel托管平台AHAS(Application High Availability Service)来实现规则的持久化。

一、开通AHAS

开通AHAS说明
在这里插入图片描述

二、进入AHAS控制台

1、AHAS控制台地址

2、接入 Spring Boot 应用

三、操作演示

1、添加依赖

		<!--AHAS依赖-->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>spring-boot-starter-ahas-sentinel-client</artifactId>
            <version>1.5.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.alibaba.csp</groupId>
                    <artifactId>sentinel-transport-simple-http</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

注意:对于spring-cloud-starter-alibaba-sentinel依赖我们需要排除sentinel-transport-simple-http(与原生sentinel控制台通信需要的)依赖。

2、application.yml

ahas.namespace: default
project.name: content-center
ahas.license: 许可证

3、重启应用,访问资源

在这里插入图片描述
如果页面没有显示相应的应用,参考如下解决方案。
在这里插入图片描述
在这里插入图片描述
再次重启应用,我们依然可以看到之前配置的规则依然生效。
在这里插入图片描述

发布了135 篇原创文章 · 获赞 41 · 访问量 4249

猜你喜欢

转载自blog.csdn.net/weixin_41842236/article/details/105174368
今日推荐