1. Download:
wget http://download.redis.io/releases/redis-2.8.7.tar.gz
2, Decompression installation:
tar xf redis-2.8.7.tar.gz
cd redis-2.8.7
Make
Make install
3. Create the configuration file:
mkdir /etc/redis
cp redis.conf /etc/redis/redis.conf
4, adjust the use of memory allocation and make it effective:
echo “vm.overcommit_memory=1”>>/etc/sysctl.conf
sysctl -p
5. Modify the Redis configuration:
vi /etc/redis/redis.conf
daemonize yes #redis以守护进程的方式运行
#no表示不以守护进程的方式运行(会占用一个终端)
timeout 300 #客户端闲置多长时间后断开连接,默认为0关闭此功能
loglevel verbose #设置redis日志级别
logfile stdout #设置日志文件的输出方式,如果以守护进程的方式运行redis
#并且日志输出设置为stdout,那么日志信息就输出到/dev/null里面去了
6. Start Redis:
Cd/etc/redis
Redis-server redis.conf #启动redis服务
CD ~/REDIS-2.8.7/SRC #进入redis安装目录
REDIS-CLI #进入redis终端
7. Example:
Set key value #设置redis缓存: Set Test-redis "Test for Redis"
Get key #获取redis缓存: Get Test-redis
Del key #删除redis缓存: Del Test-redis
Setex Key Time value #设置redis缓存并设置过期时间: Setex test-redis "test for Redis Too"//expires after 10 seconds
Centos-redis Installation