linux redis安装

============== Redis 安装 ===============

wget http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz

tar zxf tcl8.6.0-src.tar.gz
cd tcl8.6.0/unix/

./configure
make install

cd /usr/local/

wget http://download.redis.io/releases/redis-2.6.16.tar.gz

tar zxf redis-2.6.16.tar.gz
rm -rf redis-2.6.16.tar.gz

cd /usr/local/redis-2.6.16
make

cd /usr/local/redis-2.6.16
cp src/redis-server /usr/local/bin/redis-server-2.6.16
cp src/redis-cli /usr/local/bin/redis-cli-2.6.16
cp src/redis-benchmark /usr/local/bin/redis-benchmark-2.6.16
cp src/redis-check-aof /usr/local/bin/redis-check-aof-2.6.16
cp src/redis-check-dump /usr/local/bin/redis-check-dump-2.6.16

ln -s /usr/local/bin/redis-server-2.6.16 /usr/local/bin/redis-server
ln -s /usr/local/bin/redis-cli-2.6.16 /usr/local/bin/redis-cli
ln -s /usr/local/bin/redis-benchmark-2.6.16 /usr/local/bin/redis-benchmark
ln -s /usr/local/bin/redis-check-aof-2.6.16 /usr/local/bin/redis-check-aof
ln -s /usr/local/bin/redis-check-dump-2.6.16 /usr/local/bin/redis-check-dump

mkdir -p /data/redis_data/{etc,data,log}
useradd -M -r --home-dir /data/redis_data redis
chown -R redis:redis /data/redis_data
cp redis.conf /data/redis_data/etc

编辑配置文件
vi /data/redis_data/etc/redis.conf
分别修改下面3个参数:

daemonize yes
bind 127.0.0.1
dir /data/redis_data/data


将附件中的启动文件复制到    /etc/init.d/

修改启动文件权限
chmod +x /etc/init.d/redis
touch /data/redis_data/log/redis.log
chown redis:redis /data/redis_data/log/redis.log
chkconfig --add redis
chkconfig redis on
/etc/init.d/redis start


验证是否已经成功启动:
netstat -an | grep LISTEN | grep 6379
正常会弹出如下信息
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN



安装 Redis 模块
/usr/local/python-2.7/bin/easy_install  redis
/usr/local/python-2.7/bin/easy_install hiredis

验证方法
import redis 
r = redis.StrictRedis(host='127.0.0.1', port=6379) 
r.set('foo', 'hello') 
print r.get('foo') 

http://blog.csdn.net/chosen0ne/article/details/7319807

你可能感兴趣的:(linux)