Cabbage Java study room covers core knowledge
Spring Cloud Alibaba actual combat (1) Preparation (2) Nacos Article Spring Cloud Alibaba actual combat (3) Sentinel Article Spring Cloud Alibaba (5) Zuul (6) RocketMQ (7) Spring Cloud Alibaba Actual combat (7) Seata Spring Cloud Alibaba Combat (8) SkyWalking
GitHub: github.com/D2C-Cai/her…
1. Introduction to Spring Cloud Alibaba
Spring Cloud Alibaba is dedicated to providing one-stop solutions for microservice development. This project contains the necessary components for the development of distributed application microservices that developers can easily use to develop distributed application services through the Spring Cloud programming model.
Relying on Spring Cloud Alibaba, you only need to add some annotations and a few configurations to connect Spring Cloud applications to Ali microservice solution and quickly build a distributed application system through Ali middleware.
1.1. Main Functions
- Service limiting degradation: By default, WebServlet, WebFlux, OpenFeign, RestTemplate, Spring Cloud Gateway, Zuul, Dubbo and RocketMQ are supported. Traffic limiting degradation rules can be modified in real time from the console at run time. You can also view traffic limiting degradation Metrics monitoring.
- Service registry and Discovery: ADAPTS to Spring Cloud service registry and discovery standards. By default, the Ribbon is integrated.
- Distributed configuration management: Supports externalized configurations in distributed systems, and automatically refreshes configurations when they are changed.
- Message-driven capabilities: Build message-driven capabilities for microservice applications based on Spring Cloud Stream.
- Distributed Transactions: Use the @GlobalTransactional annotation to resolve distributed transactions efficiently and with zero intrusion on the business.
- Aliyun Object storage: Aliyun provides massive, secure, low-cost and highly reliable cloud storage services. Supports storage and access of any type of data in any application, anytime, anywhere.
- Distributed task scheduling: Provides second-level, accurate, highly reliable, and highly available scheduled (based on Cron expressions) task scheduling service. It also provides a distributed task execution model, such as grid task. Grid tasks can be evenly distributed to all workers (schedulerx-client) for execution.
- Ali Cloud SMS service: the global coverage of SMS services, friendly, efficient and intelligent interconnected communication capabilities, help enterprises quickly build customer access channels.
1.2. Main components
- Sentinel: Traffic is taken as the entry point to protect the stability of services from multiple dimensions such as flow control, circuit breaker degradation and system load protection.
- Nacos: A dynamic service discovery, configuration management, and service management platform that makes it easier to build cloud-native applications.
- RocketMQ: An open source distributed messaging system based on highly available distributed clustering technology that provides low-latency, highly reliable messaging publishing and subscription services.
- Dubbo: Apache Dubbo™ is a high-performance Java RPC framework.
- Seata: Alibaba’s open source product, an easy-to-use, high-performance microservice distributed transaction solution.
- Alibaba Cloud OSS: Alibaba Cloud Object Storage Service (OSS) is a massive, secure, low-cost, and reliable Cloud Storage Service provided by Alibaba Cloud. You can store and access any type of data in any application, at any time, anywhere.
- Alibaba Cloud SchedulerX: A distributed task scheduling product developed by Ali Middleware team, which provides second-level, accurate, highly reliable and highly available timing (based on Cron expressions) task scheduling service.
- Alibaba Cloud SMS: SMS service covering the world, friendly, efficient and intelligent connected communication ability, help enterprises quickly build customer access channels.
1.3. Versioning specifications
The version number is in the format of X.X.X, where x is a number starting from 0 and is not limited to 0 to 9. When the project is in the incubator phase, the first version number is fixed to 0, that is, the version number is 0.x.x.
The interface and annotations of the Actuator module in Spring Boot 1 and Spring Boot 2 have been greatly changed, and the upgrade of Spring-cloud-Commons from 1.x.x to 2.0.0 has also been greatly changed. So we take the same version as the SpringBoot version:
- The 1.5.x version applies to Spring Boot 1.5.x
- The 2.0.x version applies to Spring Boot 2.0.x
- The 2.1.x version applies to Spring Boot 2.1.x
- The 2.2.x version applies to Spring Boot 2.2.x
2. Main content
Spring Cloud Alibaba practical tutorial series will be divided into the following parts, teach you how to use docker deployment service, practical application distributed suite:
component | function |
---|---|
Nacos | Dynamic service discovery and configuration management |
Sentinel | Flow control, circuit breaker degradation, system load protection |
Seata | High performance microservice distributed transactions |
RocketMQ | Highly available distributed messaging system |
Zuul+Oauth2 | Distributed network authentication system |
SkyWalking | Distributed link tracking and monitoring system |
3. Preparation
The beginning of this tutorial series is devoted to preparation to reduce confusion during the actual combat. Based on actual combat, supplemented by basic principles, specific in-depth principle analysis will be another opening chapter, please look forward to.
3.1. Install the Docker environment quickly
- Install the Docker
Docker installation resource files are stored in Amazon S3, but the connection fails intermittently. So when you install Docker, it’s going to be slow. You can install Docker at high speed by executing the following command. Applicable to Most Linux, such as Ubuntu, Debian, Centos, etc. Docker official resources will be synchronized every 3 hours.
curl -sSL https://get.daocloud.io/docker | sh
Copy the code
- Install the Docker Compose
Docker Compose is stored in Git Hub and is not very stable. You can also install Docker Compose at high speed by executing the following command. You can customize the version you need by modifying the version in the URL.
The curl -l https://get.daocloud.io/docker/compose/releases/download/1.28.2/docker-compose- ` ` uname - s - ` uname -m ` > /usr/local/bin/docker-composeCopy the code
chmod +x /usr/local/bin/docker-compose
Copy the code
- Configure the Docker image site
Configure Docker image site *. This script adds –registry-mirror to your Docker configuration file /etc/docker/daemon.json. Ubuntu14.04, Debian, CentOS6, CentOS7, Fedora, Arch Linux, openSUSE Leap 42.1, other versions may vary slightly.
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
Copy the code
3.2. Create an initial project
First, come up with a name for your project. For this tutorial, it’s called herring.
The reason herring- XXX wraps a layer on middleware projects is that many enterprise development needs their own secondary encapsulation. The construction of the project is different, the reader need not be too entangled, according to their own habits to build.
The main project | The first layer | The second floor | Project description |
---|---|---|---|
herring | herring-alibaba | herring-nacos | Dynamic service discovery and configuration management |
herring-sentinel | Flow control, circuit breaker degradation, system load protection | ||
herring-seata | High performance microservice distributed transactions | ||
herring-rocketmq | Highly available distributed messaging system | ||
herring-common | herring-feign | Declarative Web Service client | |
herring-mysql | Mysql > Select mysql > mysql | ||
herring-redis | Distributed cache Select Redis | ||
herring-tools | Common toolkits JWT, Lombok, etc | ||
herring-services | herring-base | Service base client NACOS, Sentinel, Skywalking client | |
herring-base-tx | Service transaction related client seata, rocketMQ client | ||
herring-product | Build your own experimental microservice (you can build your own) | ||
herring-member | Build your own experimental microservice (you can build your own) | ||
herring-orders | Build your own experimental microservice (you can build your own) | ||
herring-security | herring-oauth2 | Oauth2.0 security authentication service | |
herring-gateway | Zuul Distributed Gateway service | ||
herring-skywalking | Distributed link tracking and monitoring system |
- Select the versioning convention for the project framework:
The main project | The first layer |
---|---|
spring-boot | 2.2.3. RELEASE |
spring-cloud | Hoxton.SR5 |
spring-cloud-alibaba | 2.2.3. RELEASE |
- Convention POM for the parent project version:
<? The 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" > The < modelVersion > 4.0.0 < / modelVersion > < groupId > org. Jackey < / groupId > < artifactId > selected < / artifactId > < packaging > pom < / packaging > < version > 1.0 - the SNAPSHOT < / version > < properties > < project. Build. SourceEncoding > utf-8 < / project. Build. SourceEncoding > < maven.com piler. Source > 1.8 < / maven.com piler source > < maven.com piler target > 1.8 < / maven.com piler. Target > < Java version > 1.8 < / Java version > < spring - cloud - alibaba. Version > 2.2.3. RELEASE < / spring - cloud - alibaba. Version > < spring - cloud version > Hoxton. SR5 < / spring - cloud. Version > < spring - the boot. Version > 2.2.3. RELEASE < / spring - the boot. Version > </properties> <dependencyManagement> <dependencies> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring-cloud-alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>Copy the code
Install MySQL 5.7 quickly using Docker
Pull the MySQL 5.7 image
Docker pull daocloud. IO/library/mysql: 5.7.4Copy the code
Start the container of MySQL 5.7 image, pay attention to set the initial password and map data archive directory
Docker run - name mysql_5. 7 - v/docker/mysql/data: / var/lib/mysql - p, 3306:3306 - e MYSQL_ROOT_PASSWORD = (your root password) - d Daocloud. IO/library/mysql: 5.7.4Copy the code
3.3. Use Docker to quickly install Redis 3.2
Pull the Redis 3.2 image
Docker pull daocloud. IO/library/redis: 3.2.8Copy the code
Start the Redis 3.2 image container, setting persistence parameters and mapping data archive directory
Docker run - name redis_3. 2 - v/docker/redis/data: data - p / 6379:6379 - d daocloud. IO/library/redis: 3.2.8 redis server. - --appendonly yesCopy the code
Spring Cloud Alibaba actual combat (1) Preparation (2) Nacos Article Spring Cloud Alibaba actual combat (3) Sentinel Article Spring Cloud Alibaba (5) Zuul (6) RocketMQ (7) Spring Cloud Alibaba Actual combat (7) Seata Spring Cloud Alibaba Combat (8) SkyWalking
GitHub: github.com/D2C-Cai/her…