当前位置:网站首页>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 !
边栏推荐
- Tcapulusdb Jun · industry news collection
- Application practice | Apache Doris integrates iceberg + Flink CDC to build a real-time federated query and analysis architecture integrating lake and warehouse
- Build the first security defense line for enterprises to go to the cloud Tencent's new generation cloud firewall product launch is about to open
- sql server常用sql
- Usage of cobaltstrike: Part 1 (basic usage, listener, redirector)
- Understand the data consistency between MySQL and redis
- How to deploy the deep learning model to the actual project? (classification + detection + segmentation)
- Advantages of micro service registry Nacos over Eureka
- 解密抖音春节红包背后的技术设计与实践
- Detailed explanation of bitmap optimization
猜你喜欢

Ant won the finqa competition champion and made a breakthrough in AI technology of long text numerical reasoning

蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破

游戏安全丨喊话CALL分析-写代码

为什么你的数据图谱分析图上只显示一个值?

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

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

Section 29 basic configuration case of Tianrongxin topgate firewall

脚本之美│VBS 入门交互实战
Mysql中的触发器定义及语法介绍

Slsa: accelerator for successful SBOM
随机推荐
[tcapulusdb knowledge base] insert data example (TDR table)
How to create a virtual server through a fortress machine? What are the functions of the fortress machine?
How to solve the problem that the GPU VNC has two mice with large deviation
pyspark on hpc
What is the API gateway architecture? What are the common gateway types?
蚂蚁集团自研TEE技术通过国家级金融科技产品认证
Beauty of script │ VBS introduction interactive practice
[technical dry goods] the technical construction route and characteristics of zero trust in ant Office
How to shut down the server in the fortress machine? What other operations can the fortress machine perform?
In the eyes of the universe, how to correctly care about counting East and West?
Notes to nodejs (II)
How to set the search bar of website construction and what should be paid attention to when designing the search box
How to build a business analysis system
Performance test - LoadRunner obtains the return value and user-defined parameters (parameter operation)
Problem solving: inittramfs unpacking failed:decoding failed
Low code helps live e-commerce bring goods into the manufacturing industry, impacting the traditional supply chain model of the factory
SQL Server Common SQL
脚本之美│VBS 入门交互实战
Tcapulusdb Jun · industry news collection
Introduction to tcapulusdb lossless relocation