Python连接Redis连接配置


系统环境:
 
OS:Oracle Linux Enterprise 5.6
 
redis:redis-2.6.8
 
python:Python-2.7.3
 
redis的python包版本:redis-2.7.2.tar
 
前提条件:
 
1.确保Redis已成功安装并且正确配置,参考文档
 
主从复制文档: 

 
参数说明文档: 

 
 
2.确保Python环境已成功配置,参考文档 
 
 
 
配置python连接redis:
 
1.安装Redis的Python包:
 
使用easy-install安装,关于easy-install的配置,参考以上Python环境的搭建。
 
[root@njdyw bin]# easy_install2.7.3 redis
 
Searching for redis
 
Reading http://pypi.python.org/simple/redis/
 
Reading http://github.com/andymccurdy/redis-py
 
Best match: redis 2.7.2
 
Downloading http://pypi.python.org/packages/source/r/redis/redis-2.7.2.tar.gz#md5=17ac60dcf13eb33f82cc25974ab17157
 
Processing redis-2.7.2.tar.gz
 
Running redis-2.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8FAlft/redis-2.7.2/egg-dist-tmp-JzQViJ
 
zip_safe flag not set; analyzing archive contents...
 
Adding redis 2.7.2 to easy-install.pth file
 
 
 
Installed /usr/local/python2.7.3/lib/python2.7/site-packages/redis-2.7.2-py2.7.egg
 
Processing dependencies for redis
 
Finished processing dependencies for redis
 
 
 
--安装Parser包(可选)
 
说明:Parser可以控制如何解析redis响应的内容。redis-py包含两个Parser类,PythonParser和HiredisParser。默认,如果已经安装了hiredis模块,redis-py会使用HiredisParser,否则会使用PythonParser。
 
HiredisParser是C编写的,由redis核心团队维护,性能要比PythonParser提高10倍以上,所以推荐使用。安装方法,使用easy_install:
 
[root@njdyw ~]# easy_install2.7.3 hiredis
 
Searching for hiredis
 
Reading http://pypi.python.org/simple/hiredis/
 
Reading https://github.com/pietern/hiredis-py
 
Best match: hiredis 0.1.1
 
Downloading http://pypi.python.org/packages/source/h/hiredis/hiredis-0.1.1.tar.gz#md5=92128474f6fb027cfb8587fce724ea8e
 
Processing hiredis-0.1.1.tar.gz
 
Running hiredis-0.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZanSCB/hiredis-0.1.1/egg-dist-tmp-XCZBQ0
 
zip_safe flag not set; analyzing archive contents...
 
Adding hiredis 0.1.1 to easy-install.pth file
 
 
 
Installed /usr/local/python2.7.3/lib/python2.7/site-packages/hiredis-0.1.1-py2.7-linux-x86_64.egg
 
Processing dependencies for hiredis
 
Finished processing dependencies for hiredis
  • 1
  • 2
  • 3
  • 下一页

相关内容