There are two types of errors in accessing Redis with Python today on this computer (Windows):
If I am in the way of Sentinel, I will report unknown command ' SENTINEL ' such errors;
If I match Strictredis, I will report Noauth authentication required. Error;
Mark, find a way to solve it tomorrow ....
PS: Finally found that the MONGO connection failure is the password is not set to cause (actually because the online configuration as the offline configuration .... )
For the first mistake, the company recently had a problem on the line, the main reason is that Sentinel did not start up, but the process of some of the pits, the company has 3 of the Redis Sentinel Machine, one of the machine downtime, The other two machines are not always able to elect a single, because do not know which temporary workers in the Redis configuration when the election machine is configured to 3, so long as the one can not be elected. In fact, the configuration should be changed to N-m, N is the number of machines, and M is the number of machines allowed to go down.
The code for the Redis is attached as follows:
import redisimport configparserimport redis.sentinelclass RedisConn: _RP = None def __init__ (self): CP = Configparser.safeconfigparser () cp.read (' avatar_redis.conf ') host = Cp.get ( ' Redis ', ' host ') port = cp.get (' Redis ', ' port ') db_name = Cp.get (' Redis ', ' dbName ') Pass_word = cp.ge T (' Redis ', ' passWord ') SELF._RP = Redis. Strictredis (Host=host, Port=port, Db=0, password=pass_word) # = Redis. ConnectionPool (Host=host, Port=port, db=0, password= ") #sentinel = Redis.sentinel.Sentinel ([(Host, Port)], socket_ timeout=0.1) #self. _RP = Sentinel.master_for (db_name, socket_timeout=0.1) #self. _RP = Redis. Redis (Connection_pool=conn_pool) def get_conn (self): return SELF._RP def set_value (self, Key, value): Self._rp.set (key, value) def get_value (self, key): Return Self._rp.get (Key)