下载Redis指定版本的源码压缩包到当前目录。
wget http://download.redis.io/releases/redis-3.0.7.tar.gz
解压缩Redis源码压缩包。
o/releases/redis-3.0.7.tar.gz
建立一个redis目录的软连接,指向redis-3.0.7。
ln -s redis-3.0.7 redis
进入redis目录。
cd redis
编译(编译之前确保操作系统已经安装gcc)安装。
make make install
这里有两点要注意:第一,第3步中建立了一个redis目录的软链接,这样做是为了不把redis目录固定在指定版本上,有利于Redis未来版本升级,算是安装软件的一种好习惯。
redis-cli -v #查看版本
配置、启动、操作、关闭Redis
表1-2 Redis可执行文件说明
可执行文件 | 作用 |
redis-server | 启动redis服务 |
redis-cli | redis命令行客户端 |
redis-benchmark | redis基准测试工具 |
redis-check-aof | redis ao持久化文件检测和修复工具 |
redis-check-dump | redis rdb 持久化文件检测和修复工具 |
redis-sentinel | 启动redis sentinel |
[root@master redis]# redis-se
redis-sentinel redis-server
[root@master redis]# redis-server
42726:C 11 Sep 22:12:06.137 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
42726:M 11 Sep 22:12:06.138 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 42726
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
42726:M 11 Sep 22:12:06.140 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
42726:M 11 Sep 22:12:06.140 # Server started, Redis version 3.0.7
42726:M 11 Sep 22:12:06.140 # 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.
42726:M 11 Sep 22:12:06.140 # 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.
42726:M 11 Sep 22:12:06.140 * The server is now ready to accept connections on port 6379
可以看到直接使用redis-server启动Redis后,会打印出一些日志,通过日志可以看到一些信息,上例中可以看到:当前的Redis版本的是3.0.7。Redis的默认端口是6379。