系统环境和版本说明
Linux操作系统选用Ubuntu 14.04,Redis的版本选取目前的最新稳定版本2.8.9。
1.下载Redis的安装包
wget http://download.redis.io/releases/redis-2.8.9.tar.gz
2.解压
tar -zxvf redis-2.8.9.tar.gz
3.编译
sudo make
4.安装
sudo make install
5.在安装成功之后,可以运行测试,确认Redis的功能是否正常
sudo make test
1 seconds - unit/quit
1 seconds - unit/scan
1 seconds - unit/auth
2 seconds - unit/multi
3 seconds - unit/protocol
11 seconds - unit/expire
13 seconds - unit/type/list-2
4 seconds - integration/aof
3 seconds - integration/rdb
16 seconds - unit/type/list
1 seconds - unit/pubsub
2 seconds - integration/convert-zipmap-hash-on-load
2 seconds - unit/slowlog
0 seconds - unit/introspection
19 seconds - unit/type/hash
2 seconds - unit/limits
21 seconds - unit/other
22 seconds - unit/aofrw
6 seconds - unit/scripting
27 seconds - unit/type/set
9 seconds - unit/dump
30 seconds - unit/type/zset
31 seconds - unit/sort
16 seconds - unit/maxmemory
13 seconds - unit/bitops
34 seconds - integration/replication-2
37 seconds - unit/basic
42 seconds - unit/type/list-3
40 seconds - integration/replication-psync
43 seconds - integration/replication
26 seconds - unit/hyperloglog
50 seconds - integration/replication-3
52 seconds - integration/replication-4
54 seconds - unit/obuf-limits
313 seconds - unit/memefficiency
\o/ All tests passed without errors!
Cleanup: may take some time... OK
测试最后一步等待时间有点长~~~我还以为卡了
如果出现进入Redis连接拒绝,请先确定服务是否启动了
gulugu@Dell:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
作为后台进程启动服务 redis-server &
redis-server &
[1] 14496
wangxiong@Dell:~/Soft/redis-2.8.9$ [14496] 02 Aug 16:46:52.436 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[14496] 02 Aug 16:46:52.437 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[14496] 02 Aug 16:46:52.437 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[14496] 02 Aug 16:46:52.437 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 14496
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[14496] 02 Aug 16:46:52.438 # Server started, Redis version 2.8.9
[14496] 02 Aug 16:46:52.438 # 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.
[14496] 02 Aug 16:46:52.438 * The server is now ready to accept connections on port 6379
正常访问:
gulugulu@Dell:~$ redis-cli
127.0.0.1:6379>
因为没有添加开机启动,所以开机的时候我执行启动服务,发现端口并不是6379,所以还是会报连接拒绝,我尝试这样去绑定端口6379
gg@Dell:~$ redis-server --port 6379 --daemonize yes
gg@Dell:~$ redis-cli -p 6379
127.0.0.1:6379> exit
gg@Dell:~$ ps -aux|grep redis
root 3913 0.0 0.0 85864 4304 pts/4 T 17:19 0:00 sudo redis-server
root 3973 0.0 0.0 85864 4488 pts/4 T 17:21 0:00 sudo redis-server
wangxio+ 4071 0.0 0.0 15100 6040 pts/0 S+ 17:25 0:00 redis-cli
wangxio+ 4105 0.0 0.1 42260 8692 ? Ssl 17:26 0:00 redis-server *:6379
wangxio+ 4119 0.0 0.0 15956 2216 pts/10 S+ 17:27 0:00 grep --color=auto redis