1.下载redis3.0.2
[root@Moxiaokai ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
[root@Moxiaokai ~]# ll
redis-3.0.2.tar.gz
2.解压并编译安装
[root@Moxiaokai ~]# tar -xzf redis-3.0.2.tar.gz
[root@Moxiaokai ~]# ll
redis-3.0.2 redis-3.0.2.tar.gz
[root@Moxiaokai ~]# cd redis-3.0.2
[root@Moxiaokai redis-3.0.2]# make
检查redis是否有异常
[root@Moxiaokai redis-3.0.2]# make test
[root@Moxiaokai redis-3.0.2]# make install
在 make test时redis-3.0.2的时候可能提示错误:
[root@Moxiaokai redis-3.0.2]# make test
make:cc:Command not found ,make: *** [adlist.o] Error 127
这里是由于新安装的Linux系统没有安装gcc环境,需要安装gcc,为了方便选择用yum进行安装。
[root@Moxiaokai redis-3.0.2]# yum -y install gcc
make: *** [test] Error 1
[root@Moxiaokai redis-3.0.2]# make test
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
root@Moxiaokai redis-3.0.2]#wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
root@Moxiaokai redis-3.0.2]#tar -xzvf tcl8.6.1-src.tar.gz -C /usr/local/
root@Moxiaokai redis-3.0.2]#cd /usr/local/tcl8.6.1/unix/
root@Moxiaokai redis-3.0.2]# ./configure
root@Moxiaokai redis-3.0.2]# make
root@Moxiaokai redis-3.0.2]# make install
3.运行redis
i)开启Server进程
[root@Moxiaokai redis-3.0.2]# ./src/redis-server
24841:C 08 Nov 07:20:33.378 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
24841:M 08 Nov 07:20:33.379 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.2 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 24841
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
24841:M 08 Nov 07:20:33.381 # Server started, Redis version 3.0.2
24841:M 08 Nov 07:20:33.383 # 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 vm.overcommit_memory=1' for this to take effect.
24841:M 08 Nov 07:20:33.383 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
24841:M 08 Nov 07:20:33.384 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
24841:M 08 Nov 07:20:33.384 * The server is now ready to accept connections on port 6379
ii)关闭Server进程
[root@Moxiaokai redis-3.0.2]#./redis-cli shutdown
登入客户端进行关闭:
[root@Moxiaokai redis-3.0.2]#./redis-cli
127.0.0.1:6379> shutdown
not connected>
4.程序验证:
[root@vstar75 src]# ./redis-cli
127.0.0.1:6379> set MyName 'Moxiaokia'
OK
127.0.0.1:6379> get MyName
"Moxiaokia"
127.0.0.1:6379>
5.启动参数方式启动Serverredis.conf
[root@Moxiaokai redis-3.0.2]# ./src/redis-server redis.conf
6.将 Redis 作为 Linux 服务随机启动
[root@Moxiaokai redis-3.0.2]#vi /etc/rc.local
加入:
/root/install/redis-3.0.2/src/redis-server