当前位置:网站首页>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 !
边栏推荐
- How to use FTP to upload websites to the web
- Slsa: accelerator for successful SBOM
- PostgreSQL怎么创建分区表详解
- Targeted, real-time audio and video optimization in remote control
- Start learning simple JS
- SAVE: 软件分析验证和测试平台
- Three ways to enable IPv6 on Tencent cloud
- How to set up links for website construction how to build a website
- 反序列化——php反序列化
- Go deep: the evolution of garbage collection
猜你喜欢

Ant group's self-developed tee technology has passed the national financial technology product certification

蚂蚁集团自研TEE技术通过国家级金融科技产品认证
SQL语句中EXISTS的详细用法大全

Section 29 basic configuration case of Tianrongxin topgate firewall

在宇宙的眼眸下,如何正确地关心东数西算?

Why is only one value displayed on your data graph?

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

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

The technical design and practice of decrypting the red envelopes of Tiktok Spring Festival

openGauss Developer Day 2022正式开启,与开发者共建开源数据库根社区
随机推荐
First talk about the necessary skills of Architecture
Industry 4.0 era: the rise of low code may bring about changes in the pattern of manufacturing industry
Consequences of website construction without SSL authentication are websites without SSL authentication reliable
Is the website under construction because there is no FTP upload? Can I upload without FTP
Pourquoi une seule valeur apparaît - elle sur votre carte de données?
SAP mm ml81n creates a service receipt for a purchase order and reports an error - no matching Po items selected-
Apache log4j 2 reported high-risk vulnerability, coding teamed up with Tencent to protect software security
Section 30 high availability (HA) configuration case of Tianrongxin topgate firewall
5 minutes to explain what is redis?
Three ways to enable IPv6 on Tencent cloud
Use elastic security to detect the vulnerability exploitation of cve-2021-44228 (log4j2)
sql server常用sql
蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破
How to deploy the deep learning model to the actual project? (classification + detection + segmentation)
Grpc: quickly configure the general API to obtain process meta information
2021-12-10: which can represent a 64 bit floating point number or a 64 bit signed integer
Start learning simple JS
在宇宙的眼眸下,如何正确地关心东数西算?
新股民怎样炒股票开户?在线开户安全么?
How to build a website after registering a domain name