redis高可用之redis3.0叢集
一、安裝配置:
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Redis叢集與高可用Redis
- 10、redis哨兵叢集高可用Redis
- Redis快取高可用叢集Redis快取
- Redis高可用-主從,哨兵,叢集Redis
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- redis通訊與高可用叢集原理Redis
- redis叢集Redis
- redis 叢集Redis
- Redis操作及叢集搭建以及高可用配置Redis
- 11、redis使用ruby實現叢集高可用Redis
- 深入剖析Redis系列(二) - Redis哨兵模式與高可用叢集Redis模式
- Redis cluster 叢集Redis
- redis系列:叢集Redis
- Redis Cluster(叢集)Redis
- redis叢集原理Redis
- 搭建 Redis 叢集Redis
- redis叢集搭建Redis
- redis偽叢集配置Cluster叢集模式Redis模式
- Redis三種高可用模式:主從、哨兵、叢集Redis模式
- 高可用之戰:Redis Sentinal(哨兵模式)Redis模式
- 【Redis】用python操作redis叢集RedisPython
- 認識Redis叢集——Redis ClusterRedis
- Redis(5.0) 叢集搭建Redis
- 搭建Redis原生叢集Redis
- redis叢集指導Redis
- Redis--叢集搭建Redis
- docker-redis叢集DockerRedis
- redis叢集報錯Redis
- 搭建redis cluster叢集Redis
- redis叢集的搭建Redis
- redis 4.0.11 叢集搭建Redis
- redis 叢集構建Redis
- Docker搭建Redis叢集DockerRedis
- Jedis操作單節點redis,叢集及redisTemplate操作redis叢集(一)Redis
- 基於Dokcer搭建Redis叢集(主從叢集)Redis
- Redis高可用之戰:主從架構Redis架構
- 【Redis叢集實戰】Redis Cluster 部署Redis
- Redis Cluster高可用叢集線上遷移操作記錄Redis
- Redis叢集高頻問答,連夜肝出來了Redis