Redis Cluster
Cd/usr/local/redis3.0/src
./redis-trib.rb Create--replicas 1 ip1:7000 ip1:7001
Cluster info/nodes
Redis-cli-c-H yourhost-p yourpost
Https://github.com/andymccurdy/redis-py
Pip Install Redis-py-cluster
PIP Upgrade pip-9.0.1.tar.gz
# !/usr/bin/env python# coding:utf-8# import redisfrom rediscluster import strictredisclusterimport sysredis_nodes = [{' host ': ' Ip1 ', ' Port ':7000}]try: redisconn = strictrediscluster (startup_nodes=redis_nodes) Except Exception,e: print "connect error!" sys.exit (1) redisconn.set (' name ', ' admin ') redisconn.set (' age ', 18) print "name is: ", redisconn.get (' name ') print "age is: ", redisconn.get (' Age ') Install the redis server and the python redis Library (Pip install redis) on your computer. Create a redis hash table test that contains the fields count (1) and name (' Fester bestertester '), which outputs all fields of test . # redisconn.hmset (' Test ', {' count ': 1, ' name ': ' Fester bestertester '}) print redisconn.hgetall (' test ') Auto-test count field and output it. >>> conn.hincrby (' Test ', ' count ', 3) 4>>> conn.hget (' Test ', ' count ') B ' 4 '
This article is from the "Python Operation" blog, declined reprint!
Python Operation Redis Cluster