阅读更多
转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/97.html?1455870336
如何在Linux上安装Redis呢,下面以阿里云主机linux 64位作为示例进行安装测试:
1、下载源码编译并安装
# wget http://download.redis.io/releases/redis-2.8.19.tar.gz
# tar xzf redis-2.8.19.tar.gz
# cd redis-2.8.19
# make
2、编译成功过后,在src目录下,有三个可执行文件redis-server、redis-benchmark、redis-cli。我这里将其统一放到/usr/local/redis目录下
#mkdir /usr/local/redis
#cp redis-server /usr/redis
#cp redis-benchmark /usr/redis
#cp redis-cli /usr/redis
#cd ../
#cp redis.conf /usr/redis
#cd /usr/redis
3.将redis添加到系统环境变量中:
#vi /etc/profile
在文件最后加入下面代码:
export PATH=/usr/local/redis:$PATH
保存并重新编译
#source /etc/profile
4、启动Redis服务。
#redis-server redis.conf
如果出现类似下面的输出信息则启动成功:
[20466] 04 Mar 16:34:05.702 # Server started, Redis version 2.8.19
[20466] 04 Mar 16:34:05.702 # WARNING overcommit_memory is set to 0! Background
save may fail under low memory condition. To fix this issue add 'vm.overcommit_m
emory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.ove
rcommit_memory=1' for this to take effect.
[20466] 04 Mar 16:34:05.703 # WARNING: The TCP backlog setting of 511 cannot be
enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[20466] 04 Mar 16:34:05.703 * The server is now ready to accept connections on p
ort 6379
5、测试
#redis-cli
redis> set mydata "Hello Redis"
OK
redis> get mydata
"Hello Redis"