参考官网:Redis
安装非常简单:
$ wget http://download.redis.io/releases/redis-4.0.11.tar.gz
$ tar xzf redis-4.0.11.tar.gz
$ cd redis-4.0.11
$ make
编译之后,打开src目录,已经有可执行程序了,再make install将可执行程序安装到/usr/local/bin目录下,就可以不用输入全部路径了。
实际运行redis前,还需要运行make test检测一下。实际上,make和make install的时候,程序都已经提醒了。
[root@localhost redis-4.0.11]# make install
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-4.0.11/src'
CC Makefile.dep
make[1]: Leaving directory `/usr/local/src/redis-4.0.11/src'
make[1]: Entering directory `/usr/local/src/redis-4.0.11/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: Leaving directory `/usr/local/src/redis-4.0.11/src'
结果make test发生了错误。1.安装tcl;2.将安装包文件权限全修改为777。
# yum install -y tcl
# chmod 777 redis-4.0.11.tar.gz
再次make test,不再报错了。
[root@localhost redis-4.0.11]# make test
cd src && make test
make[1]: Entering directory `/usr/local/src/redis-4.0.11/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/local/src/redis-4.0.11/src'
make: *** [test] Error 2
如果不修改文件权限,就会报“Executing test client: couldn't open socket: connection refused.”的错误。
......
Logged warnings (pid 7146):
(none)
[exception]: Executing test client: couldn't open socket: connection refused.
couldn't open socket: connection refused
while executing
......
最后,开启redis。
[root@localhost src]# redis-server &
[1] 9738
[root@localhost src]# 9738:C 04 Sep 13:21:49.958 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9738:C 04 Sep 13:21:49.958 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=9738, just started
9738:C 04 Sep 13:21:49.958 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
9738:M 04 Sep 13:21:49.960 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 9738
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
9738:M 04 Sep 13:21:49.963 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9738:M 04 Sep 13:21:49.963 # Server initialized
9738:M 04 Sep 13:21:49.963 # 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.
9738:M 04 Sep 13:21:49.963 # 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.
9738:M 04 Sep 13:21:49.963 * DB loaded from disk: 0.000 seconds
9738:M 04 Sep 13:21:49.963 * Ready to accept connections
[root@localhost src]# netstat -tunlp|grep redis
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 9738/redis-server *
tcp 0 0 :::6379 :::* LISTEN 9738/redis-server *