redis Clusterコマンドredis-trib.rbコマンド

19041 ワード

       -  ,    redis-trib.rb   ,  cluster                   

CLUSTER info:       。
CLUSTER nodes:             (node)     。
CLUSTER meet  : ip port             。
CLUSTER addslots  [slot ...]:       (slot)  (assign)     。
CLUSTER delslots  [slot ...]:                。
CLUSTER slots:    、    。
CLUSTER slaves :              。
CLUSTER replicate :                。
CLUSTER saveconfig:                 ,                     。
CLUSTER keyslot :  key        。
CLUSTER flushslots:             ,                   。
CLUSTER countkeysinslot :             。
CLUSTER getkeysinslot  :  count     。

CLUSTER setslot  node            ,             ,             ,       。  
CLUSTER setslot  migrating                 。  
CLUSTER setslot  importing    node_id           slot     。  
CLUSTER setslot  stable      slot    (import)    (migrate)。 

CLUSTER failover:        。
CLUSTER forget :           ,         ,    60s,60s            。
CLUSTER reset [HARD|SOFT]:      ,soft          ,       id,hard       id,        soft  。

CLUSTER count-failure-reports :              。
CLUSTER SET-CONFIG-EPOCH:    epoch,              。
 
  
 
  
 
  
 
  
 
  

redis-trib.rb用法(不带任何参数执行redis-trib.rb即显示用法):

$ ./redis-trib.rb

Usage: redis-trib   

 

  rebalance       host:port

                  --auto-weights

                  --timeout 

                  --pipeline 

                  --use-empty-masters

                  --weight 

                  --threshold 

                  --simulate

  add-node        new_host:new_port existing_host:existing_port

                  --slave

                  --master-id 

  reshard         host:port

                  --timeout 

                  --pipeline 

                  --yes

                  --slots 

                  --to 

                  --from 

  check           host:port

  set-timeout     host:port milliseconds

  call            host:port command arg arg .. arg

  fix             host:port

                  --timeout 

  info            host:port

  create          host1:port1 ... hostN:portN

                  --replicas 

  import          host:port

                  --replace

                  --copy

                  --from 

  help            (show this help)

  del-node        host:port node_id

 

For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.

    redis-trib.rb      :
1、create:
2、check:
3、info:
4、fix:
5、reshard: slot
6、rebalance: slot
7、add-node:
8、del-node:
9、set-timeout:
10、call:
11、import: redis
redis-trib.rb redis-trib.rb 。

redis-trib.rb :ClusterNode RedisTrib。ClusterNode ,RedisTrib redis-trib.rb 。

ClusterNode

ClusterNode 。ClusterNode (ruby @ ):

@r: redis 。
@info: , cluster nodes cluster info 。
@dirty: , true, 。
@friends: info 。 cluster nodes 。
ClusterNode :

initialize:ClusterNode , 。
friends: @friends 。
slots: slots 。
has_flag?: info flags flag。
to_s: java toString , 。
connect: redis 。
assert_cluster: 。
assert_empty: , db 。
load_info: cluster info cluster nodes 。
add_slots: slot, , dirty true, flush_node_config 。
set_as_replica:slave master 。dirty true。
flush_node_config: 。
info_string: info 。
get_config_signature: cluster nodes 。 。
info: @info , info 。
is_dirty?: @dirty。
r: redis 。
ClusterNode , , , 。 redis-trib.rb , create :

create host1:port1 ... hostN:portN
       --replicas
host1:port1 ... hostN:portN , ,--replicas , , --slave , , , help redis-trib.rb 。

host:port, redis-trib.rb , , 。