redis高可用之redis3.0集群
2015-05-29 07:18
621 查看
一、安装配置:
1、redis安装配置:
版本:Redis server v=3.0.1
关键配置参数(7000):
daemonize yes
pidfile /var/run/redis_7000.pid
port 7000
logfile "/etc/cluster/7000/redis_7000.log"
dir /etc/cluster/7000
appendonly yes
appendfilename "appendonly.aof"
cluster-enabled yes
cluster-config-file nodes.conf
7001,7002,7003,7004,7005修改直接修改端口号即可
配置好后启动这个6个redis节点
2、集群配置:
[root@localhost src]# yum install ruby
[root@localhost src]# yum install rubygems
找不到可以到这个链接下载
https://rubygems.org/gems/redis/versions
[root@localhost src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating cluster
Connecting to node 127.0.0.1:7000: OK
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: 8128762ecea3a8798ed5d8b06b9520c969e50cd7 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 425117c39f0f201b145deb1663c994f058883009 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 5a6cb57aff9e4c00a819c86e78b279864e4993b5 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: 9526e18bd0dee29b7deeaff25d140a0139b3962c 127.0.0.1:7003
replicates 8128762ecea3a8798ed5d8b06b9520c969e50cd7
S: ee01f05c92b56ce9cb13619073146b6bbcc97cd3 127.0.0.1:7004
replicates 425117c39f0f201b145deb1663c994f058883009
S: 2129adb0613dc207d37cb44d53ae11a32766c2c3 127.0.0.1:7005
replicates 5a6cb57aff9e4c00a819c86e78b279864e4993b5
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 127.0.0.1:7000)
M: 8128762ecea3a8798ed5d8b06b9520c969e50cd7 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 425117c39f0f201b145deb1663c994f058883009 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 5a6cb57aff9e4c00a819c86e78b279864e4993b5 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
M: 9526e18bd0dee29b7deeaff25d140a0139b3962c 127.0.0.1:7003
slots: (0 slots) master
replicates 8128762ecea3a8798ed5d8b06b9520c969e50cd7
M: ee01f05c92b56ce9cb13619073146b6bbcc97cd3 127.0.0.1:7004
slots: (0 slots) master
replicates 425117c39f0f201b145deb1663c994f058883009
M: 2129adb0613dc207d37cb44d53ae11a32766c2c3 127.0.0.1:7005
slots: (0 slots) master
replicates 5a6cb57aff9e4c00a819c86e78b279864e4993b5
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@localhost src]#
二、常用命令:
cluster info 列出集群信息
cluster nodes 列出节点主从信息
redis-trib.rb check 127.0.0.1:7000 检查集群状态
cluster replicate 2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835 指定当前链接节点为2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835 的从库
cluster数据操作:
redis-cli -c -p xxxx 可以看到数据会自动写入到对应的节点中
节点添加、删除、slot分配 请看redis-trib.rb帮助,简单明了:
redis-trib.rb
Usage: redis-trib
del-node host:port node_id
set-timeout host:port milliseconds
add-node new_host:new_port existing_host:existing_port
--master-id
--slave
help (show this help)
call host:port command arg arg .. arg
check host:port
create host1:port1 ... hostN:portN
--replicas
import host:port
--from
reshard host:port
--from
--slots
--yes
--to
fix host:port
For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
官方文档:http://redis.io/topics/cluster-tutorial
1、redis安装配置:
版本:Redis server v=3.0.1
关键配置参数(7000):
daemonize yes
pidfile /var/run/redis_7000.pid
port 7000
logfile "/etc/cluster/7000/redis_7000.log"
dir /etc/cluster/7000
appendonly yes
appendfilename "appendonly.aof"
cluster-enabled yes
cluster-config-file nodes.conf
7001,7002,7003,7004,7005修改直接修改端口号即可
配置好后启动这个6个redis节点
2、集群配置:
[root@localhost src]# yum install ruby
[root@localhost src]# yum install rubygems
找不到可以到这个链接下载
https://rubygems.org/gems/redis/versions
[root@localhost src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating cluster
Connecting to node 127.0.0.1:7000: OK
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: 8128762ecea3a8798ed5d8b06b9520c969e50cd7 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 425117c39f0f201b145deb1663c994f058883009 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 5a6cb57aff9e4c00a819c86e78b279864e4993b5 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: 9526e18bd0dee29b7deeaff25d140a0139b3962c 127.0.0.1:7003
replicates 8128762ecea3a8798ed5d8b06b9520c969e50cd7
S: ee01f05c92b56ce9cb13619073146b6bbcc97cd3 127.0.0.1:7004
replicates 425117c39f0f201b145deb1663c994f058883009
S: 2129adb0613dc207d37cb44d53ae11a32766c2c3 127.0.0.1:7005
replicates 5a6cb57aff9e4c00a819c86e78b279864e4993b5
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 127.0.0.1:7000)
M: 8128762ecea3a8798ed5d8b06b9520c969e50cd7 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 425117c39f0f201b145deb1663c994f058883009 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 5a6cb57aff9e4c00a819c86e78b279864e4993b5 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
M: 9526e18bd0dee29b7deeaff25d140a0139b3962c 127.0.0.1:7003
slots: (0 slots) master
replicates 8128762ecea3a8798ed5d8b06b9520c969e50cd7
M: ee01f05c92b56ce9cb13619073146b6bbcc97cd3 127.0.0.1:7004
slots: (0 slots) master
replicates 425117c39f0f201b145deb1663c994f058883009
M: 2129adb0613dc207d37cb44d53ae11a32766c2c3 127.0.0.1:7005
slots: (0 slots) master
replicates 5a6cb57aff9e4c00a819c86e78b279864e4993b5
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@localhost src]#
二、常用命令:
cluster info 列出集群信息
cluster nodes 列出节点主从信息
redis-trib.rb check 127.0.0.1:7000 检查集群状态
cluster replicate 2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835 指定当前链接节点为2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835 的从库
cluster数据操作:
redis-cli -c -p xxxx 可以看到数据会自动写入到对应的节点中
节点添加、删除、slot分配 请看redis-trib.rb帮助,简单明了:
redis-trib.rb
Usage: redis-trib
del-node host:port node_id
set-timeout host:port milliseconds
add-node new_host:new_port existing_host:existing_port
--master-id
--slave
help (show this help)
call host:port command arg arg .. arg
check host:port
create host1:port1 ... hostN:portN
--replicas
import host:port
--from
reshard host:port
--from
--slots
--yes
--to
fix host:port
For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
官方文档:http://redis.io/topics/cluster-tutorial
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20625855/viewspace-1676162/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20625855/viewspace-1676162/
相关文章推荐
- Redis3.0的主从、集群高可用
- Redis3.0的主从、集群高可用
- cool-2018-03-07-redis(3.0)集群安装
- (转)基于Redis Sentinel的Redis集群(主从&Sharding)高可用方案
- Redis3.0 集群
- Nginx反向代理,负载均衡,Redis集群 Twemproxy,redis session共享,keepalived高可用-搭建千万级网站系统
- Redis集群的高可用测试(含Jedis客户端的使用)
- spring集成 JedisCluster 连接 redis3.0 集群
- redis 3.0的集群部署
- 分布式架构学习之:032--使用Redis3.0集群实现Tomcat集群的Session共享
- Redis 集群的高可用测试(含 Jedis 客户端的使用)
- Redis高可用集群方案——哨兵
- 15套Java架构师,集群,高可用,高可扩 展,高性能,高并发,性能优化,Redis,ActiveMQ,Nginx,Mycat,Netty,Jvm大型分布 式项目实战视频教程
- centos6.5环境下redis3.0集群搭建和配置
- Centos7 Redis3.0 集群搭建备忘
- 高级架构师JAVA,集群,高可用,高性能,高并发,性能优化,Redis,ActiveMQ,Nginx,Netty,Jvm大型分布 式项目实战视频
- Redis高可用开源缓存集群方案--总结自网络
- 基于Redis Sentinel的Redis集群(主从&Sharding)高可用方案
- Redis3.0--集群安装部署
- redis-3.0集群安装