redis3.0集群部署方案

本文涉及的产品
云数据库 Redis 版,标准版 2GB
推荐场景:
搭建游戏排行榜
云原生内存数据库 Tair,内存型 2GB
简介:
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

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
4月前
|
负载均衡 监控 NoSQL
Redis的集群方案有哪些?
Redis集群包括主从复制(基础,手动故障恢复)、哨兵模式(自动高可用)和Redis Cluster(官方分布式解决方案,自动分片和容错)。此外,还有如Codis、Redisson和Twemproxy等第三方工具用于代理和负载均衡。选择方案需考虑应用场景、数据规模和并发需求。
339 2
|
4月前
|
监控 NoSQL Linux
【分布式】Redis的持久化方案解析
【1月更文挑战第25天】【分布式】Redis的持久化方案解析
|
4月前
|
运维 NoSQL 算法
【Redis故障排查】「连接失败问题排查和解决」带你深入分析一下Redis阻塞原因以及问题排查方案指南
【Redis故障排查】「连接失败问题排查和解决」带你深入分析一下Redis阻塞原因以及问题排查方案指南
844 0
|
4月前
|
缓存 运维 NoSQL
【Redis故障排查】「连接失败问题排查和解决」带你总体分析和整理Redis的问题故障实战开发指南及方案
【Redis故障排查】「连接失败问题排查和解决」带你总体分析和整理Redis的问题故障实战开发指南及方案
1161 0
|
3月前
|
存储 NoSQL Redis
Redis系列学习文章分享---第九篇(Redis快速入门之好友关注--关注和取关 -共同关注 -Feed流实现方案分析 -推送到粉丝收件箱 -滚动分页查询)
Redis系列学习文章分享---第九篇(Redis快速入门之好友关注--关注和取关 -共同关注 -Feed流实现方案分析 -推送到粉丝收件箱 -滚动分页查询)
33 0
|
4月前
|
负载均衡 监控 NoSQL
Redis的几种主要集群方案
【5月更文挑战第15天】Redis集群方案包括主从复制(基础,读写分离,手动故障恢复)、哨兵模式(自动高可用,自动故障转移)和Redis Cluster(官方分布式解决方案,自动分片、容错和扩展)。此外,还有Codis、Redisson和Twemproxy等工具用于代理分片和负载均衡。选择方案需考虑应用场景、数据量和并发需求,权衡可用性、性能和扩展性。
244 2
|
3月前
|
NoSQL 算法 Java
技术好文:Redis实现分布式锁的7种方案
技术好文:Redis实现分布式锁的7种方案
|
3月前
|
存储 NoSQL 算法
Redis集群,集群的概念 三种主流分片方式1.哈希求余 一致性哈希算法:方案三:哈希槽分区算法问题一Redis集群是最多有16384个分片吗问题二:为什么是16384个,集群扩容:1.新的主节点
Redis集群,集群的概念 三种主流分片方式1.哈希求余 一致性哈希算法:方案三:哈希槽分区算法问题一Redis集群是最多有16384个分片吗问题二:为什么是16384个,集群扩容:1.新的主节点
|
4月前
|
存储 缓存 NoSQL
【技术分享】求取列表需求的redis缓存方案
【技术分享】求取列表需求的redis缓存方案
60 0
|
4月前
|
存储 缓存 NoSQL
Redis实现延迟任务的几种方案
Redis实现延迟任务的几种方案