当前位置:网站首页>Redis cluster setup - use docker to quickly build a test redis cluster
Redis cluster setup - use docker to quickly build a test redis cluster
2022-07-27 13:50:00 【Bald and weak.】
List of articles
Use scripts to quickly build six redis example
1. Pull docker Mirror image
docker pull redis:5.0.7
2. Quickly build six redis example
for port in $(seq 7001 7006); \
do \
mkdir -p /mydata/redis/node-${port}/conf
touch /mydata/redis/node-${port}/conf/redis.conf
cat << EOF >/mydata/redis/node-${port}/conf/redis.conf
port ${port}
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
# Current node ip
cluster-announce-ip 192.168.56.10
cluster-announce-port ${port}
# The port for information exchange between clusters
cluster-announce-bus-port 1${port}
appendonly yes
EOF
docker run -p ${port}:${port} -p 1${port}:1${port} --name redis-${port} \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-d redis:5.0.7 redis-server /etc/redis/redis.conf; \
done
3. Other commands
docker stop $(docker ps -a |grep redis-700 | awk '{ print $1}')
docker start $(docker ps -a |grep redis-700 | awk '{ print $1}')
docker rm $(docker ps -a |grep redis-700 | awk '{ print $1}')

build redis colony
1. Just go into one redis example
docker exec -it redis-7001 bash

2. establish redis colony
redis-cli --cluster create 192.168.56.10:7001 192.168.56.10:7002 192.168.56.10:7003 192.168.56.10:7004 192.168.56.10:7005 192.168.56.10:7006 --cluster-replicas 1
–cluster-replicas 1 It means to set the master node to have a slave node .

We can see ,7001、7002、7003 It's the master node ,7006 yes 7002 From the ,7005 yes 7001 From the ,7004 yes 7003 From the .
here ,redis Cluster building completed
Test use redis colony
1. Connect any one redis node
docker exec -it redis-7002 /bin/bash
redis-cli -c -h 192.168.56.10 -p 7002
2. Get cluster information
cluster info

3. Get cluster node information
cluster nodes

4.set/get Test data 
We found that , Will redirect normally
5. At this point, we stop a master node 
Then check the node information , Will find 7005 Number redis Instead of 7001, Become the master node 
6. At this time, the 7001 start-up 
We found that ,7001 Automatically become 7005 The slave node of 
边栏推荐
- SQL教程之 SQL 聚合函数入门教程
- Fiddler抓包工具+夜神模拟器
- Unapp prevents continuous click errors
- Database kernel developer, worth a mug!!!
- Go language series: how to build a go language development environment?
- 软考 系统架构设计师 简明教程 | 系统设计
- evutil_make_internal_pipe_: pipe: Too many open files
- Keras deep learning practice - recommend system data coding
- eBPF/Ftrace
- Gray histogram
猜你喜欢

Fiddler抓包工具+夜神模拟器

Keras深度学习实战——推荐系统数据编码

Cute image classification -- a general explanation of the article "what are the common flops in CNN model?"

小程序毕设作品之微信校园洗衣小程序毕业设计成品(4)开题报告

不需要标注数据的语义分割!ETH&鲁汶大学提出MaskDistill,用Transformer来进行无监督语义分割,SOTA!...

产品经理经验谈100篇(十一)-策略产品经理:模型与方法论

Product manager experience 100 (XI) - Strategic Product Manager: model and methodology

剑指Offer 07 重建二叉树 -- 从中序与后序遍历序列构造二叉树

【C进阶】指针数组 VS 数组指针

Use recyclerview to realize the left sliding menu of the list
随机推荐
Selenium eight elements positioning and relative locator
English grammar_ Personal pronoun
Meshlab farthest point sampling (FPS)
小程序毕设作品之微信校园洗衣小程序毕业设计成品(8)毕业设计论文模板
Software system architecture designer concise tutorial | software system modeling
软考 系统架构设计师 简明教程 | 系统设计
腾讯云联合中国工联院发布工业AI质检标准化研究成果加速制造业智能化转型
【实习经验】Date工具类中添加自己实现的方法
Network packet loss, network delay? This artifact helps you get everything done!
Unapp prevents continuous click errors
小程序毕设作品之微信校园洗衣小程序毕业设计成品(4)开题报告
2、Citrix Virtual Apps and Desktops 2203剪贴板重定向策略
在“元宇宙空间”UTONMOS将打开虚实结合的数字世界
egg-swagger-doc 图形验证码解决方案
Echart line chart displays the last point and vertical dotted line by default
Image features and extraction
JS 模块、闭包应用
echart折线图默认显示最后一个点以及纵向虚线
Product manager experience 100 (XI) - Strategic Product Manager: model and methodology
[internship experience] add your own implementation method to the date tool class