当前位置:网站首页>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"
边栏推荐
猜你喜欢

Some personal understandings about MySQL indexes (partially refer to MySQL45 lectures)

The go language (functions, closures, defer, panic/recover, recursion, structure, json serialization and deserialization)

EA&UML日拱一卒-状态图::重画按钮状态图

重建二叉树

I.MX6U-驱动开发-3-新字符驱动

自媒体人如何打造出爆文?这3种类型的文章最容易爆

机器人的运动范围

KDE Frameworks 5.20.0:Plasma迎来诸多改进

rk-boot framework combat (1)

月薪15k的阿里测试岗,面试原来这么简单
随机推荐
opencv基本图像的滤波
【集训DAY16】KC ‘ s Stars【dfs】
头条号自媒体运营:如何在今日头条涨500+粉丝?
关于MySQL索引的一些个人理解(部分参考MySQL45讲)
[Cloud native Kubernetes] Build a Kubernetes cluster in binary (middle) - deploy node nodes
servlet执行详解
Worthington Enzymatic Cell Harvest & Cell Adhesion and Harvest
抖音短视频流量获取攻略,掌握好这些一定可以出爆款
绘制几何图形
Worthington经过使用测试的细胞分离系统方案
工厂模式
BEVDetNet: Bird's Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi
CesiumJS ^ source read [0] 2022 - article directory and source engineering structure
基于TNEWS‘ 今日头条中文新闻(短文本)分类
机器人的运动范围
How to design and implement report collaboration system for instruction set data products——Development practice of industrial collaborative manufacturing project based on instruction set IoT operating
Types and check set (set), study T treasure code
Some personal understandings about MySQL indexes (partially refer to MySQL45 lectures)
循环神经网络(RNN)
自媒体短视频标题怎么写?3个爆款标题,让你的视频收获更多流量