一、下载redis
本次部署测试采用的redis版本是redis-2.8.19.tar.gz;
二、安装redis
下载后解压 tar -zxvf redis-2.8.19.tar.gz到任意目录,例如/home/bppf_tools/redis/redis-2.8.19
解压后,进入redis目录
cd /home/bppf_tools/redis/redis-2.8.19
执行make命令
接着cp redis.conf /etc/ (这个文件是redis启动时读取的配置文件)
cp src/redis-benchmark src/redis-cli src/redis-server src/redis-sentinel /usr/bin/
三、启动redis服务
[root@esxi3v03 redis-2.8.19]# redis-server /etc/redis.conf &
[1] 9237
[root@esxi3v03 redis-2.8.19]# [9237] 19 Dec 14:20:03.228 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.19 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 9237
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[9237] 19 Dec 14:20:03.230 # Server started, Redis version 2.8.19
[9237] 19 Dec 14:20:03.230 # 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.
[9237] 19 Dec 14:20:03.230 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[9237] 19 Dec 14:20:03.230 * DB loaded from disk: 0.000 seconds
[9237] 19 Dec 14:20:03.230 * The server is now ready to accept connections on port 6379
查看进程,确认redis已经启动
[root@esxi3v03 redis-2.8.19]# ps -ef | grep redis
root 9237 6278 0 14:20 pts/1 00:00:00 redis-server *:6379
root 9242 6278 0 14:20 pts/1 00:00:00 grep redis
四、测试redis
[root@esxi3v03 redis-2.8.19]# redis-cli
127.0.0.1:6379> set name lichunan
OK
127.0.0.1:6379> get name
"lichunan"
五、关闭redis服务
redis-cli shutdown
redis服务关闭后,缓存数据会自动dump到硬盘上,硬盘地址为redis.conf中的配置项dbfilename dump.rdb所设定
强制备份数据到磁盘,使用如下命令
redis-cli save 或者 redis-cli -p 6379 save(指定端口)