Python连接Redis配置详解
2013-07-21 11:34
567 查看
Python连接Redis配置详解
操作环境: CentOS 5.4
操作步骤:
(一) 安装Redis:
操作环境: CentOS 5.4
操作步骤:
(一) 安装Redis:
[root@localhost /]# yum install redis Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * epel: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.yun-idc.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package redis.i386 0:2.4.10-1.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: redis i386 2.4.10-1.el5 epel 299 k Transaction Summary ================================================================================ Install 1 Package(s) Upgrade 0 Package(s) Total download size: 299 k Is this ok [y/N]: y Downloading Packages: redis-2.4.10-1.el5.i386.rpm | 299 kB 00:01 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : redis 1/1 Installed: redis.i386 0:2.4.10-1.el5 Complete!(二)启动redis:
[root@localhost etc]# redis-server /etc/redis.conf [root@localhost etc]# ps -ef | grep redis root 17699 1 0 12:05 ? 00:00:00 redis-server /etc/redis.conf root 17762 17615 0 12:49 pts/1 00:00:00 grep redis(三)用telnet连接并测试:
[root@localhost etc]# telnet localhost 6379 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. set key1 4 +OK get key1 $1 4 set key2 hello +OK get key2 $5 hello quit +OK Connection closed by foreign host.(四)安装python client:
[root@localhost etc]# easy_install redis Searching for redis Reading http://pypi.python.org/simple/redis/ Best match: redis 2.7.6 Downloading https://pypi.python.org/packages/source/r/redis/redis-2.7.6.tar.gz#md5=e975ea446c40046ef6dc41c98e41a4f8 Processing redis-2.7.6.tar.gz Running redis-2.7.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-v8JaAU/redis-2.7.6/egg-dist-tmp-6xgSQs zip_safe flag not set; analyzing archive contents... Adding redis 2.7.6 to easy-install.pth file Installed /usr/local/lib/python2.6/site-packages/redis-2.7.6-py2.6.egg Processing dependencies for redis Finished processing dependencies for redis(五)测试:
[root@localhost etc]# python Python 2.6.8 (unknown, Dec 6 2012, 15:31:25) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import redis >>> r = redis.Redis(host='127.0.0.1', port=6379, db=0) >>> r.set('name', 'zhangshan') True >>> r.get('name') 'zhangshan' >>> r.set('age', 22) True >>> r.get('age') '22' >>> r.dbsize() 5L >>> r.flushdb() True >>> r.get('name') >>> r.dbsize() 0L >>>
相关文章推荐
- python(十一)下:Redis安装配置及使用详解
- [Python模块] redis.conf配置文件详解
- Python连接Redis的基本配置方法
- Python连接Redis连接配置
- Python连接Redis连接配置
- 详解springboot配置多个redis连接
- Python连接Redis连接配置
- Python连接Redis连接配置
- Python连接Redis连接配置
- python2.7连接oracle数据库配置文件
- Win2003中配置FTP服务,开启防火墙导致客户端无法连接【精华详解】
- Python的Flask框架使用Redis做数据缓存的配置方法
- Redis配置详解-yellowcong
- 扩展阅读- redis 配置参数详解
- CentOS下Redis 2.2.14安装配置详解(转载)
- redis.conf 配置文件详解
- spring-data-redis用配置类连接时,抛异常Cannot get Jedis connection; nested exception is java.lang.NullPointerEx
- 快速部署Python应用:Nginx+uWSGI配置详解
- redis配置文件详解
- redis.conf参数配置文件详解