1、安装
虽然之前已经装过了 再记录一下
去官网下载最新稳定版 http://redis.io/download
[root@centos7 bin]# wget http://download.redis.io/releases/redis-5.0.4.tar.gz
解压
[root@centos7 bin]# tar -zxvf redis-5.0.4.tar.gz
进入解压的文件夹 cd
[root@centos7 bin]# cd redis-5.0.4
编译
[root@centos7 bin]# make
安装 make install PREFIX=/usr/local/redis
[root@centos7 redis-5.0.4]# make install PREFIX=/usr/local/redis
cd src && make install
make[1]: 进入目录“/usr/src/redis-5.0.4/src”
CC Makefile.dep
make[1]: 离开目录“/usr/src/redis-5.0.4/src”
make[1]: 进入目录“/usr/src/redis-5.0.4/src”Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/usr/src/redis-5.0.4/src”
测试 进入目录启动redis
[root@centos7 redis]# cd /usr/local/redis/bin/
[root@centos7 bin]# ./redis-server11113:C 16 Apr 2019 12:20:33.054 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11113:C 16 Apr 2019 12:20:33.054 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=11113, just started
11113:C 16 Apr 2019 12:20:33.054 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
11113:M 16 Apr 2019 12:20:33.055 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.4 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 11113
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'11113:M 16 Apr 2019 12:20:33.056 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
11113:M 16 Apr 2019 12:20:33.056 # Server initialized
11113:M 16 Apr 2019 12:20:33.056 # 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.
11113:M 16 Apr 2019 12:20:33.057 # 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.
11113:M 16 Apr 2019 12:20:33.057 * DB loaded from disk: 0.000 seconds
11113:M 16 Apr 2019 12:20:33.057 * Ready to accept connections
启动成功。
退出:Ctrl+c 即可退出。
2、配置
后台启动redis
复制解压文件夹里redis的配置文件到安装的bin目录
[root@centos7 bin]# cp /usr/src/redis-5.0.4/redis.conf /usr/local/redis/bin/
修改配置文件
[root@centos7 bin]# vim redis.conf
找到 daemonize=no 修改为yes,保护守护进程开启,也就是在后台可以运行
在第136行
保存退出
[root@centos7 bin]# ./redis-server redis.conf
11153:C 16 Apr 2019 12:29:38.761 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11153:C 16 Apr 2019 12:29:38.762 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=11153, just started
11153:C 16 Apr 2019 12:29:38.762 # Configuration loaded
这样就可以后台启动了
输入命令查看是否后台启动了
[root@centos7 bin]# ps aux|grep redis
root 11154 0.1 0.4 153884 7672 ? Ssl 12:29 0:00 ./redis-server 127.0.0.1:6379
root 11159 0.0 0.0 112724 984 pts/0 S+ 12:30 0:00 grep --color=auto redis
结束进程
[root@centos7 bin]# kill 11154
也可以强制结束
[root@centos7 bin]# kill -9 11154
设置开机自启动redis
[root@centos7 bin]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
重启开机之后输入命令 redis已经启动了
[root@centos7 ~]# systemctl status redis
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since 二 2019-04-16 12:47:22 CST; 51s ago
Main PID: 6221 (redis-server)
CGroup: /system.slice/redis.service
└─6221 /usr/bin/redis-server 127.0.0.1:63794月 16 12:47:22 centos7 systemd[1]: Starting Redis persistent key-value database...
4月 16 12:47:22 centos7 systemd[1]: Started Redis persistent key-value database.
测试启动redis客户端 成功
[root@centos7 ~]# /usr/local/redis/bin/redis-cli
127.0.0.1:6379>