在开始学习之前,我们需先给自己提出几个问题,什么是Redis?与其他同类型的比较,Redis有何优势?Redis的应用场景又是什么?Redis怎么配置?Redis有何缺陷?只要与系统挂钩,我们都会想到Redis如何优化?带着这些疑问,开始我们的旅程。
一、什么是Redis
二、Redis优势
三、Redis应用场景
四、Redis配置
4.1 下载安装包
http://code.google.com/p/redis/downloads/list
4.2 解压并编译安装
#tar -xzvf redis-2.6.14.tar.gz
#sed -i.bak '/^PREFIX/s@/usr/local@/opt/redis@g' redis-2.6.14/src/Makefile #指定redis安装路径为/opt/redis
#make
#make install
4.3 配置路径
为了方便,这里我们把其的service放入PATH中,然后使用source命令使其重新生效
export PATH=$PATH:/opt/redis/bin
source /etc/profile
4.4 修改配置文件(建议在对其修改之前,先备份一个)
cp redis.conf /etc/redis.conf
#vim /etc/redis.conf #对应行修改为下面内容
daemonize yes
logfile /var/log/redis.log
在这里可能会提示以下建议
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl