redis3.0集群部署方案

简介:
redis3.0集群部署方案
redis1:192.168.1.10:6379
       192.168.1.10:6380
redis2:192.168.1.11:6379
       192.168.1.11:6380
redis3:192.168.1.12:6379
       192.168.1.12:6380
关闭 selinux ,防火墙允许6379 6380端口通过, 先启动各服务器的redis节点在制作集群       
redis1配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install

mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380

cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/

vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.10
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.10
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes



redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf

ps aux|grep redis
root       1872  0.2  0.5 129408  2600 ?        Ssl  05:06   0:03 redis-server 192.168.1.10:6379 [cluster]                       
root       1876  0.2  0.5 128356  2560 ?        Ssl  05:06   0:03 redis-server 192.168.1.10:6380 [cluster]                       
root       1887  0.0  0.1 103248   872 pts/0    S+   05:32   0:00 grep redis


集群制作:
gem install redis
 
添加集群: 
./redis-trib.rb create --replicas 1 192.168.1.10:6379 192.168.10:6380 192.168.1.11:6379 192.168.1.11:6380 192.168.1.12:6379 192.168.1.12:6380

[root@bogon src]# ./redis-trib.rb create --replicas 1 192.168.1.11:6379 192.168.1.11:6380 192.168.1.10:6379 192.168.1.10:6380 192.168.1.12:6379 192.168.1.12:6380
>>> Creating cluster
Connecting to node 192.168.1.11:6379: OK
Connecting to node 192.168.1.11:6380: OK
Connecting to node 192.168.1.10:6379: OK
Connecting to node 192.168.1.10:6380: OK
Connecting to node 192.168.1.12:6379: OK
Connecting to node 192.168.1.12:6380: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.12:6379
192.168.1.10:6379
192.168.1.11:6379
Adding replica 192.168.1.10:6380 to 192.168.1.12:6379
Adding replica 192.168.1.12:6380 to 192.168.1.10:6379
Adding replica 192.168.1.11:6380 to 192.168.1.11:6379
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
   slots:10923-16383 (5461 slots) master
S: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
   replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
   slots:5461-10922 (5462 slots) master
S: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
   replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
   slots:0-5460 (5461 slots) master
S: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
   replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join...
>>> Performing Cluster Check (using node 192.168.1.11:6379)
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
   slots:10923-16383 (5461 slots) master
M: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
   slots: (0 slots) master
   replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
   slots:5461-10922 (5462 slots) master
M: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
   slots: (0 slots) master
   replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
   slots:0-5460 (5461 slots) master
M: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
   slots: (0 slots) master
   replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

redis2配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install

mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380

cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/

vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.11
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.11
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes



redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf

ps aux|grep redis
root       1872  0.2  0.5 129408  2600 ?        Ssl  05:06   0:03 redis-server 192.168.1.11:6379 [cluster]                       
root       1876  0.2  0.5 128356  2560 ?        Ssl  05:06   0:03 redis-server 192.168.1.11:6380 [cluster]                       
root       1887  0.0  0.1 103248   872 pts/0    S+   05:32   0:00 grep redis

redis3配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install

mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380

cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/

vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.12
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.12
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes



redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf

ps aux|grep redis
root       1872  0.2  0.5 129408  2600 ?        Ssl  05:06   0:03 redis-server 192.168.1.12:6379 [cluster]                       
root       1876  0.2  0.5 128356  2560 ?        Ssl  05:06   0:03 redis-server 192.168.1.12:6380 [cluster]                       

root       1887  0.0  0.1 103248   872 pts/0    S+   05:32   0:00 grep redis



本文转自 msj0905 51CTO博客,原文链接:http://blog.51cto.com/sky66/1694639

相关文章
|
负载均衡 监控 NoSQL
Redis的集群方案有哪些?
Redis集群包括主从复制(基础,手动故障恢复)、哨兵模式(自动高可用)和Redis Cluster(官方分布式解决方案,自动分片和容错)。此外,还有如Codis、Redisson和Twemproxy等第三方工具用于代理和负载均衡。选择方案需考虑应用场景、数据规模和并发需求。
785 2
|
运维 NoSQL 算法
【Redis故障排查】「连接失败问题排查和解决」带你深入分析一下Redis阻塞原因以及问题排查方案指南
【Redis故障排查】「连接失败问题排查和解决」带你深入分析一下Redis阻塞原因以及问题排查方案指南
2023 0
|
canal NoSQL 关系型数据库
Redis应用—7.大Value处理方案
本文介绍了一种用于监控Redis大key的方案设计及其实现步骤。主要内容包括:方案设计、安装与配置环境、binlog数据消费者。
863 29
Redis应用—7.大Value处理方案
|
canal 缓存 NoSQL
Redis缓存与数据库如何保证一致性?同步删除+延时双删+异步监听+多重保障方案
根据对一致性的要求程度,提出多种解决方案:同步删除、同步删除+可靠消息、延时双删、异步监听+可靠消息、多重保障方案
Redis缓存与数据库如何保证一致性?同步删除+延时双删+异步监听+多重保障方案
|
存储 监控 NoSQL
Redis高可用架构全解析:从主从复制到集群方案
Redis高可用确保服务持续稳定,避免单点故障导致数据丢失或业务中断。通过主从复制实现数据冗余,哨兵模式支持自动故障转移,Cluster集群则提供分布式数据分片与水平扩展,三者层层递进,保障读写分离、容灾切换与大规模数据存储,构建高性能、高可靠的Redis架构体系。
|
负载均衡 监控 NoSQL
Redis的几种主要集群方案
【5月更文挑战第15天】Redis集群方案包括主从复制(基础,读写分离,手动故障恢复)、哨兵模式(自动高可用,自动故障转移)和Redis Cluster(官方分布式解决方案,自动分片、容错和扩展)。此外,还有Codis、Redisson和Twemproxy等工具用于代理分片和负载均衡。选择方案需考虑应用场景、数据量和并发需求,权衡可用性、性能和扩展性。
717 2
|
存储 NoSQL Redis
Redis系列学习文章分享---第九篇(Redis快速入门之好友关注--关注和取关 -共同关注 -Feed流实现方案分析 -推送到粉丝收件箱 -滚动分页查询)
Redis系列学习文章分享---第九篇(Redis快速入门之好友关注--关注和取关 -共同关注 -Feed流实现方案分析 -推送到粉丝收件箱 -滚动分页查询)
347 0
|
监控 NoSQL 关系型数据库
保障Redis与MySQL数据一致性的强化方案
在设计时,需要充分考虑到业务场景和系统复杂度,避免为了追求一致性而过度牺牲系统性能。保持简洁但有效的策略往往比采取过于复杂的方案更加实际。同时,各种方案都需要在实际业务场景中经过慎重评估和充分测试才可以投入生产环境。
748 0
|
NoSQL 算法 安全
redis分布式锁在高并发场景下的方案设计与性能提升
本文探讨了Redis分布式锁在主从架构下失效的问题及其解决方案。首先通过CAP理论分析,Redis遵循AP原则,导致锁可能失效。针对此问题,提出两种解决方案:Zookeeper分布式锁(追求CP一致性)和Redlock算法(基于多个Redis实例提升可靠性)。文章还讨论了可能遇到的“坑”,如加从节点引发超卖问题、建议Redis节点数为奇数以及持久化策略对锁的影响。最后,从性能优化角度出发,介绍了减少锁粒度和分段锁的策略,并结合实际场景(如下单重复提交、支付与取消订单冲突)展示了分布式锁的应用方法。
1329 3
|
存储 监控 NoSQL
Redis集群有哪些方案
1. 主从复制集群 : 读写分离, 一主多从 , 解决高并发读的问题 2. 哨兵集群 : 主从集群的结构之上 , 加入了哨兵用于监控集群状态 , 主节点出现故障, 执行主从切换 , 解决高可用问题 3. Cluster分片集群 : 多主多从 , 解决高并发写的问题, 以及海量数据存储问题 , 每个主节点存储一部分集群数据

热门文章

最新文章