obeckham 发表于 2018-11-2 12:58:24

redis-cluster集群搭建

from rediscluster import StrictRedisCluster  import sys
  def redis_cluster():
  redis_nodes =[{'host':'127.0.0.1','port':7001},
  {'host':'127.0.0.1','port':7002},
  {'host':'127.0.0.1','port':7003},
  {'host':'127.0.0.1','port':7004},
  {'host':'127.0.0.1','port':7005},
  {'host':'127.0.0.1','port':7006}
  ]
  try:
  redisconn = StrictRedisCluster(startup_nodes=redis_nodes)
  except Exception,e:
  print "Connect Error!"
  sys.exit(1)
  redisconn.set('name','chen')
  redisconn.set('age',59)
  print "name is: ", redisconn.get('name')
  print "ageis: ", redisconn.get('age')
  if __name__=="__main__":
  redis_cluster()

页: [1]
查看完整版本: redis-cluster集群搭建