Method of building redis cluster based on docker

Method of building redis cluster based on docker

Download the redis image

docker pull yyyyttttwwww/redis

Take an alias

docker tag docker.io/yyyyttttwwww/redis redis

Delete the original image tag

docker rmi docker.io/yyyyttttwwww/redis

Start the redis container of 6 nodes. Note that the network used is net1.

docker run -it -d --name r1 -p 5001:6379 --net=net1 --ip 172.19.0.101 redis bash
docker run -it -d --name r2 -p 5002:6379 --net=net1 --ip 172.19.0.102 redis bash
docker run -it -d --name r3 -p 5003:6379 --net=net1 --ip 172.19.0.103 redis bash
docker run -it -d --name r4 -p 5004:6379 --net=net1 --ip 172.19.0.104 redis bash
docker run -it -d --name r5 -p 5005:6379 --net=net1 --ip 172.19.0.105 redis bash
docker run -it -d --name r6 -p 5006:6379 --net=net1 --ip 172.19.0.106 redis bash

The created containers are not started by default, so they need to be started one by one

docker exec -it -u 0 r1 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit
 
docker exec -it -u 0 r2 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit
 
docker exec -it -u 0 r3 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit
 
docker exec -it -u 0 r4 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit
 
docker exec -it -u 0 r5 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit
 
docker exec -it -u 0 r6 bash
/usr/redis/src/redis-server /usr/redis/redis.conf
exit

Enter any container such as r1 and start the cluster using the ruby ​​script

docker exec -it -u 0 r1 bash
 
/usr/redis/src/redis-trib.rb create --replicas 1 172.19.0.101:6379 172.19.0.102:6379 172.19.0.103:6379 172.19.0.104:6379 172.19.0.105:6379 172.19.0.106:6379

Enter yes to create successfully. The terminal output effect when executing the script is as follows:

Enter the command line of a node to connect to the redis cluster and check the cluster status

You can see that there are 3 master nodes and 3 slave nodes

This is the end of this article about building a redis cluster with docker. For more information about building a redis cluster with docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of the environment construction of docker to build redis cluster
  • Example of building a redis-sentinel cluster based on docker
  • Use Docker to build a Redis master-slave replication cluster
  • Teach you how to build Redis cluster mode and sentinel mode with docker in 5 minutes
  • Building a Redis cluster on Docker
  • Implementation of Redis master-slave cluster based on Docker
  • How to deploy Redis 6.x cluster through Docker
  • How to quickly build a redis cluster using Docker-swarm

<<:  How to split and merge multiple values ​​in a single field in MySQL

>>:  A brief discussion on the VUE uni-app life cycle

Recommend

Sample code for implementing image drawer effect with CSS3

As usual, let’s first post the picture effect: Th...

Windows 10 1903 error 0xc0000135 solution [recommended]

Windows 10 1903 is the latest version of the Wind...

Usage and demonstration of ref in Vue

ref definition: used to register reference inform...

Vue implements multi-grid input box on mobile terminal

Recently, the company has put forward a requireme...

Clever use of webkit-box-reflect to achieve various dynamic effects (summary)

In an article a long time ago, I talked about the...

Detailed analysis of javascript data proxy and events

Table of contents Data Brokers and Events Review ...

Summary of relevant knowledge points of ajax in jQuery

Preface Students who learn JavaScript know that A...

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

Solution to the inaccessibility of Tencent Cloud Server Tomcat port

I recently configured a server using Tencent Clou...

How to reduce the memory and CPU usage of web pages

<br />Some web pages may not look large but ...

5 super useful open source Docker tools highly recommended

Introduction The Docker community has created man...

Linux Cron scheduled execution of PHP code with parameters

1. Still use PHP script to execute. Command line ...

A brief discussion on the lazy loading attribute pattern in JavaScript

Table of contents 1. Introduction 2. On-demand at...