A few lines of code will take you quickly to understand the powerful technical support point of Taobao Double Eleven Sentinel+Nacos

Now that the Internet has developed to a certain stage, I don’t know if you are using the first generation of microservices.
1. Service registration and discovery: Eureka under Netflix
2. Load invocation of service: Ribbon under Netflix
3. Load invocation of service: under Netflix Feign
4, service fuse downgrade: Hystrix under Netflix
5. Service gateway: Zuul under Netflix
6. Distributed configuration of service: Spring official Spring Cloud Config
7. Service development: Spring Boot

虽 然 N e t f l i x 公 司 旗 下 的 大 部 分 产 品 已 经 进 入 了 维 护 阶 段 , {虽然Netflix公司旗下的大部分产品已经进入了维护阶段,} While natural N E T F L I X known Division flag under a large portion of partial production products have been through the intake into the maintenance care stage segment ,
 But I want to pay tribute to its open source! {But I want to pay tribute to its open source! } But is I want to to it 's open source cause King !

Even though most of Netflix's products have entered the maintenance stage, many excellent products have emerged, and the second generation of
microservices has slowly been born. 1. Service registration and discovery: Zookeeper under Apache, Consul under HashiCorp, Consul under Ali Nacos (of course Nacos is the focus)
2. Service load call: Ribbon, LoadBalancer, OpenFeign
3. Service fuse degradation: Sentinel
4. Service gateway: Spring GateWay
5. Service configuration: Nacos
6. Service bus: Nacos
7. Service discovery : Spring Boot

From this, you can see that Ali’s Nacos has a top three, Nacos+Sentinel can indeed do a lot of things, emmmm! It smells so good!

Insert picture description here




First push a wave: the following is the basic roadmap of nacos

Download link: https://download.csdn.net/download/Kevinnsm/19361214
Insert picture description here


Detailed explanation of cloud server Linux jdk installationhttps://blog.csdn.net/Kevinnsm/article/details/116193837?spm=1001.2014.3001.5501
In 2021, Zero Foundation will take you into the world of nacos. Download and install the nacos-xiaobai tutorial. The details are exploding!https://blog.csdn.net/Kevinnsm/article/details/117387323?spm=1001.2014.3001.5501
Local Navicat connects to Alibaba Cloud database RDS for MySQL (the most detailed in the entire network, there is no one!)https://blog.csdn.net/Kevinnsm/article/details/117437544?spm=1001.2014.3001.5501
One minute to take you quickly into the world of Nacos, the easiest tutorial in history! You can see it even with zero foundation! Who opposes?https://blog.csdn.net/Kevinnsm/article/details/117390678?spm=1001.2014.3001.5501
Will Nacos Configuration Center? How dare you! How to implement Nacos as a service configuration center step by step (the most detailed series in the entire network)https://blog.csdn.net/Kevinnsm/article/details/117410495?spm=1001.2014.3001.5501
Zero foundation takes you step by step to build a Nacos high-availability cluster (the most detailed in history, a textbook!) For this, I have prepared three cloud servers + cloud databaseshttps://blog.csdn.net/Kevinnsm/article/details/117440619?spm=1001.2014.3001.5501




Okay, let’s get to the topic of today!

Insert picture description here


1. Sentinel download and installation tutorial: {1, Sentinel download and installation tutorial:} . 1 , S E n- T I n- E L of the carrier An apparatus taught path :

https://blog.csdn.net/Kevinnsm/article/details/117479096?spm=1001.2014.3001.5501

2. Core code preparation {2, core code preparation} 2 , the nuclear core substituting code registration prepared

Ⅰ 、 p o m {Ⅰ, pom} Ⅰ 、p o m

    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-datasource-nacos</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

Ⅱ 、 a p p l i c a t i o n. Y m l {Ⅱ、application.yml} Ⅱ , a p p l i c a t i o n . Y m l

server:
  port: 8084	#服务启动端口
spring:
  application:
    name: sentinel-service
  cloud:
    nacos:
      discovery:
        server-addr: xxxx.xxxx:8848  #nacos中心地址
    sentinel:
      transport:
        dashboard: xxxx.xxxx:8080    #sentinel中心地址
        port: 8719	#该端口表示会一直从8719开始寻找空闲的端口
        client-ip: xxxx.xxxx
        #这样配置之后,该服务会注册进nacos中心,nacos中心也将被sentinel监视

Ⅲ 、 c o n t r o l l e r {Ⅲ, controller} Ⅲ 、c o n t r o l l e r

@RestController
public class SentinelController {

    @GetMapping("/sentinel/hello")
    public String hello() {
        return "hello";
    }
    @GetMapping("/sentinel/good")
    public String good() {
        return "good";
    }
}

3. Test {3, test} 3 , test test

Need to start nacos and sentinel first, I operate on the cloud server

Sentinel start command

java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=Your IP:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar

Access nacos and sentinel clients

Insert picture description here


Insert picture description here
Note that the first time you need to access the interface, the Sentinel console can display the data
Insert picture description here

Refresh the Sentinel console again

Insert picture description here


Insert picture description here


Insert picture description here

success! ❤️

Insert picture description here