当前位置:网站首页>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 !
边栏推荐
- Remember a compose version of Huarong Road, you deserve it!
- 2022年性价比高的商业养老保险产品排名
- 新股民怎样炒股票开户?在线开户安全么?
- Intelligent storage | high speed HD media processing capability
- Payment industry tuyere project: smart digital operation 3.0
- SQL Server common SQL
- Industry 4.0 era: the rise of low code may bring about changes in the pattern of manufacturing industry
- Why is easycvr cascaded to the parent platform not displayed?
- VNC multi gear resolution adjustment, 2008R2 setting 1280 × 1024 resolution
- [tcapulusdb knowledge base] reading data example (TDR table)
猜你喜欢

Chaos engineering, learn about it

为什么你的数据图谱分析图上只显示一个值?
Docker中部署Redis集群与部署微服务项目的详细过程

混沌工程,了解一下

专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!

Opengauss Developer Day 2022 was officially launched to build an open source database root community with developers

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

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

Ant won the finqa competition champion and made a breakthrough in AI technology of long text numerical reasoning
SQL语句中EXISTS的详细用法大全
随机推荐
Tcapulusdb Jun · industry news collection
PostgreSQL怎么创建分区表详解
MySQL数据库配置信息查看与修改方法详解
Heat transfer oil electric heater
Installation and use of qingscan scanner
FTP server setup setting website information can I set up FTP myself
Six supervised learning methods: classification of poisonous mushrooms
What should I do if the RDP fortress server connection times out? Why should enterprises use fortress machines?
H265 enables mobile phone screen projection
sql server常用sql
蚂蚁集团自研TEE技术通过国家级金融科技产品认证
How to judge the video frame type in h265 in golang development
What are the operation and maintenance advantages of Fortress machine web application publishing server? Two outstanding advantages
Micro build low code tutorial -hello, world
Server classification of hardware knowledge (2)
How to set the website construction title bar drop-down
Judge whether the target class conforms to the section rule
Ranking of high cost performance commercial endowment insurance products in 2022
SQL Server Common SQL
How to set up external links in website construction