sudo apt-get update sudo apt-get install make gcc python-dev -y wget http://download.redis.io/releases/redis-3.2.8.tar.gz tar xzf redis-3.2.8.tar.gz cd redis-3.2.8 make sudo make install #启动服务端 redis-server redis.conf #启动客户端连接 ancongadmin@yancongadmin-All-Series:~/downloads/redis-3.2.8/src$ ./redis-cli 127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> set foo bar OK 127.0.0.1:6379> get foo "bar" 127.0.0.1:6379> #Linux上为Python语言安装Redis客户端库 ~:$ wget -q http://peak.telecommunity.com/dist/ez_setup.py # 下载ez_setup模块 ~:$ sudo python ez_setup.py # 通过运行ez_setup模块来下载并安装 setuptools。 Downloading http://pypi.python.org/packages/2.7/s/setuptools/... # [trimmed] # Finished processing dependencies for setuptools==0.6c11 # ~:$ sudo python -m easy_install redis hiredis # 通过运行setuptools的easy_install包来安装redis包以及hiredis包。 Searching for redis # redis包为Python提供了一个连接至Redis的接口。 [trimmed] # Finished processing dependencies for redis # Searching for hiredis # hiredis包是一个C库,它可以提高Python的Redis客户端的速度。 [trimmed] # Finished processing dependencies for hiredis # ~:$ #使用Python来测试Redis $ python Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import redis >>> conn = redis.Redis() >>> conn.set('hello', 'world') True >>> conn.get('hello') 'world' >>> redis 使用key-value,键值 默认端口:6379
参考:
Redis 实战 一位博士写的书,书中的redis为2.6版本