1. 官网下载redis
也可以通过以下方式下载
wget http://download.redis.io/releases/redis-4.0.9.tar.gz
2. 上传Linux服务器
3. 解压redis-4.0.9.tar.gz
[root@chenwangmin software]# tar -zxvf redis-4.0.9.tar.gz
4.移动到安装目录下
[root@chenwangmin software]# mv redis-4.0.9 /usr/redis
5. 对解压后的文件夹进行编译
[root@chenwangmin redis]# make
显示结果:
cd src && make all
make[1]: Entering directory `/usr/redis/src'
CC Makefile.dep
make[1]: Leaving directory `/usr/redis/src'
make[1]: Entering directory `/usr/redis/src'
........................
6. 对编译的文件进行安装
[root@chenwangmin redis]# make PREFIX=/usr/local/redis install
显示结果:
cd src && make install
make[1]: Entering directory `/usr/redis/src'
CC Makefile.dep
make[1]: Leaving directory `/usr/redis/src'
make[1]: Entering directory `/usr/redis/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/redis/src'
7.查看安装后的bin目录
[root@chenwangmin redis]# cd /usr/local/redis/bin
[root@chenwangmin bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
1.redis-benchmark 性能测试工具
2. redis-check-aof AOF文件修复工具
3. redis-check-rdb RDB文件检查工具
4. redis-cli 客户端
5. redis-server 服务端
8. 把redis.conf文件拷贝到安装后的redis目录
[root@chenwangmin tmp]# cd /usr/local/redis/
[root@chenwangmin redis]# ls
bin
[root@chenwangmin redis]# cp /usr/redis/redis.conf ./redis.conf
[root@chenwangmin redis]# ls
bin redis.conf
9.启动redis服务
启动服务
[root@chenwangmin bin]# ./redis-server
30141:C 16 May 13:26:46.798 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
30141:C 16 May 13:26:46.798 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=30141, just started
30141:C 16 May 13:26:46.798 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 30141
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
30141:M 16 May 13:26:46.802 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
30141:M 16 May 13:26:46.802 # Server initialized
30141:M 16 May 13:26:46.802 # 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.
30141:M 16 May 13:26:46.802 # 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.
30141:M 16 May 13:26:46.802 * Ready to accept connections
^C30141:signal-handler (1526448458) Received SIGINT scheduling shutdown...
30141:M 16 May 13:27:38.473 # User requested shutdown...
30141:M 16 May 13:27:38.473 * Saving the final RDB snapshot before exiting.
30141:M 16 May 13:27:38.477 * DB saved on disk
30141:M 16 May 13:27:38.477 # Redis is now ready to exit, bye bye...
启动客户端
[root@chenwangmin redis]# ./bin/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
10. 备注
如果要后台启动redis服务,只要修改redis.conf 配置文件中的daemonize 属性 为yes
daemonize yes
或
[root@chenwangmin bin]# ./redis-server &
查看redis 进程
[root@chenwangmin redis]# ps -ef|grep redis
root 30332 1 0 13:36 ? 00:00:00 ./bin/redis-server 127.0.0.1:6379
root 30344 25117 0 13:37 pts/0 00:00:00 grep redis
停止服务
[root@chenwangmin redis]# ./bin/redis-cli shutdown