下载编译 http://redis.io/download
mkdir /data/install
cd /data/install
wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz
tar -xvzf redis-2.6.13.tar.gz
cd redis-stable
make
建立redis目录
cp src/redis-server /usr/local/bin/
cp src/redis-cli /usr/local/bin/
mkdir -p /usr/local/redis/conf
mkdir -p /usr/local/redis/run
mkdir -p /data/redis_data
cp redis.conf /usr/local/redis/conf/
配置redis.conf
daemonize yes
pidfile /usr/local/redis/run/redis.pid
dir /data/redis_data
创建脚本
echo '
#!/bin/bash
if [ "$1" = "start" ];
then
echo "redis start..."
/usr/local/bin/redis-server /usr/local/redis/conf/redis.conf && echo "start scuess!"
fi
if [ "$1" = "stop" ];
then
echo "redis stop..."
kill "cat /usr/local/redis/run/redis.pid" && echo "stop scuess!"
fi
' > /etc/init.d/redis
chmod a+x /etc/init.d/redis
启动redis服务
/etc/init.d/redis start
netstat -nlpt | grep 6379
测试
[root@df768d2c5a6c redis-stable]# redis-cli
127.0.0.1:6379> set key1 1111
OK
127.0.0.1:6379> get key1
"1111"
127.0.0.1:6379>