Python access to Redis issues

Source: Internet
Author: User
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) 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.