当前位置:网站首页>Docker installs redis cluster (including deployment script)
Docker installs redis cluster (including deployment script)
2022-07-30 00:15:00 【Wanshanhan】
附录redis中文网站:
官网
Chinese website one
Chinese website 2
下载redis镜像
Download the latest version directly here
docker pull redis:latest
集群部署
集群部署脚本
可以根据自己需求修改
your_ip=172.1.1.116
port_pre=800
echo "Start creating the mount file"
echo "配置的ip为${your_ip},端口以 $port_pre} 开头"
for port in $(seq 1 6); do
mkdir -p /home/redis/${port_pre}${port}/conf
mkdir -p /home/redis/${port_pre}${port}/data
mkdir -p /home/redis/${port_pre}${port}/logs
touch /home/redis/${port_pre}${port}/conf/redis.conf
cat <<EOF >/home/redis/${port_pre}${port}/conf/redis.conf port ${port_pre}${port} bind 0.0.0.0 #开启集群 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 cluster-announce-ip ${your_ip} #你的服务器ip,Because to open access to the outside world,So use your server hereip cluster-announce-port ${port_pre}${port} cluster-announce-bus-port 1${port_pre}${port} #开启集群 appendonly yes EOF
done
echo "The creation of the mount file is complete!"
#This is created for directory reasons docker的shell只能linux用,win10用不了
# 创建容器,Because it needs to be accessible from the Internet,所以要使用host模式,否则只能在docker内网应用访问.
echo "开始创建容器"
echo "配置的ip为${your_ip},端口以 ${port_pre} 开头"
for port in $(seq 1 6); do
docker run --name redis-${port_pre}${port} -d --restart=always --net host --privileged=true -v /home/redis/${port_pre}${port}/data:/data \
-v /home/redis/${port_pre}${port}/conf/redis.conf:/usr/local/etc/redis-cluster/${port_pre}${port}/redis${port_pre}${port}.conf \
-v /home/redis/${port_pre}${port}/logs:/usr/local/redis/logs \
redis redis-server /usr/local/etc/redis-cluster/${port_pre}${port}/redis${port_pre}${port}.conf
echo "创建容器redis-${port_pre}${port}"
done
#上面的--restart=always可选可不选,表示是否dockerRestarting the container also starts automatically
# 开启集群
echo "The container is created,准备开启redis集群"
echo "Please copy the following two lines at the same time,Paste and execute together,开启redis集群"
echo "docker exec -it redis-${port_pre}1 /bin/sh"
echo "redis-cli --cluster create ${your_ip}:${port_pre}1 ${your_ip}:${port_pre}2 ${your_ip}:${port_pre}3 ${your_ip}:${port_pre}4 ${your_ip}:${port_pre}5 ${your_ip}:${port_pre}6 --cluster-replicas 1"
边栏推荐
- From the perspective: the interviewer interview function test engineer mainly inspects what ability?
- what is a .pro file in qt
- Minesweeper game in c language
- The basic parallel I/O port of single chip microcomputer development
- 557. 反转字符串中的单词 III
- cp强制覆盖与不覆盖拷贝方法
- Go日志库——logrus
- EA & UML Sun Arch - State Diagram :: Redraw Button State Diagram
- One article to answer web performance optimization
- Paper Intensive Reading - YOLOv3: An Incremental Improvement
猜你喜欢
Elephant Swap: Provide arbitrage space in the crypto market with ePLATO
“ 我是一名阿里在职9年软件测试工程师,我的经历也许能帮到处于迷茫期的你 ”
EA & UML Sun Gong Yip - Multitasking Programming Super Introductory - (7) About mutex, you must know
Go日志库——logrus
更换可执行文件glibc版本的某一次挣扎
月薪15k的阿里测试岗,面试原来这么简单
2022年企业直播行业发展洞察
News text classification
Comprehensive Practice - Three-Mison Chess Mini Game
Google Chrome (google) is set to translate Chinese, the translation option does not take effect or the translation option does not pop up
随机推荐
2022杭电多校第三场 Two Permutations (dp, 哈希)
随便记记第二周
图论:二分图
利用热点事件来创作软文的3大技巧?自媒体人必看
Worthington用于细胞收获的胰蛋白酶&细胞释放程序
BEVDetNet: Bird's Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi
二维数组的查找
EA & UML Sun Arch - State Diagram :: Redraw Button State Diagram
The difference and usage of call, apply and bind
vim相关介绍(三)
UE4 制作十字准心+后坐力
From the perspective: the interviewer interview function test engineer mainly inspects what ability?
某团实习面经
指令集数据产品如何设计和实现报表协同系统——基于指令集物联网操作系统的工业协同制造项目开发实践
How do we-media people create explosive articles?These 3 types of articles are most likely to explode
ZLMediaKit源码学习——UDP
EA&UML日拱一卒-多任务编程超入门-(9)线程同步
自媒体人如何打造出爆文?这3种类型的文章最容易爆
Worthington细胞分离技术丨基本原代细胞分离方法和材料
Docker install MySQL8.0