redis集群
2021/6/5 2:24:49
本文主要是介绍redis集群,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
端口号分别为:7001~7006
mkdir redis-cluster/7001
make install PREFIX=/var/redis-cluster/7001
cp /var/redis-5.0.5/redis.conf /var/redis-cluster/7001/bin
port 7001
daemonize yes
cluster-enable yes
protected-mode no
#bind 127
cp -r /var/redis-cluster/7001/* /var/redis-cluster/7002
cp -r /var/redis-cluster/7001/* /var/redis-cluster/7003
cp -r /var/redis-cluster/7001/* /var/redis-cluster/7004
cp -r /var/redis-cluster/7001/* /var/redis-cluster/7005
cp -r /var/redis-cluster/7001/* /var/redis-cluster/7006
改port
创建start.sh,
cd 7001/bin
./redis-server redis.conf
cd …
cd …
cd 7002/bin
./redis-server redis.conf
cd …
cd …
cd 7003/bin
./redis-server redis.conf
cd …
cd …
cd 7004/bin
./redis-server redis.conf
cd …
cd …
cd 7005/bin
./redis-server redis.conf
cd …
cd …
cd 7006/bin
./redis-server redis.conf
cd …
cd …
chmod u+x start.sh
./start.sh
创建Redis集群
./redis-cli --cluster create 192.168.1.7:7001 192.168.1.7:7002 192.168.1.7:7003 192.168.1.7:7004 192.168.1.7:7005 192.168.1.7:7006 --cluster-replicas 1
添加主节点
mkdir redis-cluster/7007
make install PREFIX=/var/redis-cluster/7007
cp /var/redis-5.0.5/redis.conf /var/redis-cluster/7007/bin
port7007
daemonize yes
cluster-enable yes
protected-mode no
#bind 127
cp -r 7007 7008
port 7008
./redis-cli --cluster add-node 192.168.1.7:7007 192.168.1.7:7001
hash槽重新分配(数据迁移)
./redis-cli --cluster reshard 192.168.1.7:7007
添加从节点
./redis-cli --cluster add-node 192.168.1.7:7008 192.168.1.7:7007 --cluster-slave --cluster-master-id 388334154ba308f85b7dfbd8d228e35dfcf35832
这篇关于redis集群的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-30阿里云Redis教程:新手入门指南
- 2024-12-27阿里云Redis学习入门指南
- 2024-12-27阿里云Redis入门详解:轻松搭建与管理
- 2024-12-27阿里云Redis学习:新手入门指南
- 2024-12-24Redis资料:新手入门快速指南
- 2024-12-24Redis资料:新手入门教程与实践指南
- 2024-12-24Redis资料:新手入门教程与实践指南
- 2024-12-07Redis高并发入门详解
- 2024-12-07Redis缓存入门:新手必读指南
- 2024-12-07Redis缓存入门:新手必读教程