当前位置:网站首页>Detailed process of deploying redis cluster and micro service project in docker
Detailed process of deploying redis cluster and micro service project in docker
2022-06-23 22:52:00 【1024 Q】
One 、 Use Docker The benefits of deployment
Two 、Docker And Kubernetes contrast
3、 ... and 、Redis Cluster deployment practice
Four 、Spring Boot project Packaging mirroring
Summary

Docker Is that : Run the same container on different instances
Docker The five advantages of : Continuous deployment and testing 、 The multi cloud service platform supports 、 Environmental standardization and version control 、 Isolation 、 Security
Docker Suitable for smaller applications , When the amount of concurrency is small 、 Microservices are more than 10 individual , It is recommended that Docker Deploy , such Also save resources 、 Reduce development costs .
K8S It is suitable for large clusters , High concurrency , And microservices surpass 10 individual , At the same time, the performance is also very good , On the premise of good performance , The development cost has also increased a lot !
3、 ... and 、Redis Cluster deployment practiceNext, deploy the three master and three slave as shown in the figure Redis colony

Stop all containers , Delete all records
docker rm $(docker ps -a -q)Create a custom network redis
docker network create redis --subnet 172.38.0.0/16
Create six by script redis Basic information of
for port in $(seq 1 6); \do \mkdir -p /mydata/redis/node-${port}/conftouch /mydata/redis/node-${port}/conf/redis.confcat << EOF >/mydata/redis/node-${port}/conf/redis.confport 6379 bind 0.0.0.0cluster-enabled yes cluster-config-file nodes.confcluster-node-timeout 5000cluster-announce-ip 172.38.0.1${port}cluster-announce-port 6379cluster-announce-bus-port 16379appendonly yesEOFdone
start-up 6 individual redis Containers , And mount the data
# Start at one time by script for port in $(seq 1 6); \dodocker run -p 637${port}:6379 -p 1637${port}:16379 --name redis-${port} \-v /mydata/redis/node-${port}/data:/data \-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \-d --net redis --ip 172.38.0.1${port} redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf; \done
Get into redis-1 Set the create cluster in
# Get into redis-1docker exec -it redis-1 /bin/sh# Create clusters redis-cli --cluster create 172.38.0.11:6379 172.38.0.12:6379 172.38.0.13:6379 172.38.0.14:6379 172.38.0.15:6379 172.38.0.16:6379 --cluster-replicas 1
Into the container
redis-cli -c# View details CLUSTER INFO
see nodes
CLUSTER NODES
Set the value
set k1 v1
We can see , Set the value to 13 Node , We stop the node , Get the value again to see
# New windows stop redis-3 Containers docker stop redis -3Get in the original window k1
# You need to re-enter and get again get k1
You can see , Values have been synchronized to other nodes , After the master node hangs up , We can still get the value !
Four 、Spring Boot project Packaging mirroringCreate a SpringBoot project
TestController
@RestControllerpublic class TestController { @GetMapping("/hello") public String hello() { return "Hello World!!!"; }}Local test successfully accessed , Then compile the project as jar package
// Enter project directory mvn clean packagedownload Docker Mirror image

To write Dockerfile
FROM java:8COPY *.jar /app.jarCMD ["--server.port=8080"]EXPOSE 8080ENTRYPOINT ["java", "-jar", "/app.jar"]take jar Bao He Dockerfile Upload to server

Server files

compile Dockerfile
docker build -t xiaowang .
Test access
curl localhost:49153
Successfully uploaded the image !
SummaryThat's all 【Bug The terminator 】 Yes Docker actual combat – Deploy Redis Cluster and deploy microservice projects A brief introduction , Use Docker It is very convenient to deploy our application , quick , But if the architecture is huge , Not recommended Docker 了 , We can use our k8s Cluster deployment , It is the most popular technology nowadays !
This is about Docker Deployment in China Redis This is the end of the article on clustering and deploying microservices , More about Redis Please search the previous articles of SDN or continue to browse the following related articles. I hope you will support SDN more in the future !
边栏推荐
- Three ways to enable IPv6 on Tencent cloud
- [tcapulusdb knowledge base] reading data example (TDR table)
- Go build command (go language compilation command) complete introduction
- Targeted, real-time audio and video optimization in remote control
- How to set the border of layers in website construction? What is the role of border design
- Chaos engineering, learn about it
- Method of thread synchronization in kotlin
- [tcapulusdb knowledge base] [generic table] read data interface description
- 运维故障经历分享
- H265 enables mobile phone screen projection
猜你喜欢

Save: software analysis, verification and test platform

Application practice | Apache Doris integrates iceberg + Flink CDC to build a real-time federated query and analysis architecture integrating lake and warehouse

脚本之美│VBS 入门交互实战

Slsa: accelerator for successful SBOM

為什麼你的數據圖譜分析圖上只顯示一個值?

Section 29 basic configuration case of Tianrongxin topgate firewall

应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构

Pourquoi une seule valeur apparaît - elle sur votre carte de données?

The technical design and practice of decrypting the red envelopes of Tiktok Spring Festival
PostgreSQL怎么创建分区表详解
随机推荐
[technical dry goods] the technical construction route and characteristics of zero trust in ant Office
Discussion: will low code integrated oa/erp/mes system be an important part of enterprise application ecology?
Analysis and application of ThreadLocal source code
Get and post are nothing more than TCP links in nature?
Talk about the problems and solutions of IT enterprise fixed assets management system
[tcapulusdb knowledge base] example of deleting data (TDR table)
Game security - call analysis - write code
This article takes you to understand the JVM class loading mechanism
How to choose the server for website construction, including which servers and how much to rent
CS1.6 service startup tutorial
FTP server setup setting website information can I set up FTP myself
如何利用数仓创建时序表
Why don't people like PHP?
Notes to nodejs (II)
Installation and use of qingscan scanner
专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!
What are the steps required for TFTP to log in to the server through the fortress machine? Operation guide for novice
Operation and maintenance failure experience sharing
Three ways to enable IPv6 on Tencent cloud
How does data Vientiane CI | app quickly integrate HLS encryption to prevent video leakage?