1、安装准备
#安装 gcc
[root@localhost /]# yum -y install gcc tcl
# 查看 gcc 版本是否在 5.3 以上,centos7.6 默认安装 4.8.5
[root@localhost /]# gcc -v
gcc 版本过低编译 redis6.0 时会报错,所下面升级版本
# 升级到 gcc 9.3:
[root@localhost /]# yum -y install centos-release-scl
[root@localhost /]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost /]# scl enable devtoolset-9 bash
# 需要注意的是 scl 命令启用只是临时的,退出 shell 或重启就会恢复原系统 gcc 版本。
# 如果要长期使用 gcc 9.3的话:
[root@localhost /]# echo -e "\nsource /opt/rh/devtoolset-9/enable" >>/etc/profile
这样退出 shell 重新打开就是新版的 gcc了
以下其他版本同理,修改 devtoolset 版本号即可。
2、开始安装
[root@localhost /]# cd /usr/local/
[root@localhost local]# wget http://download.redis.io/releases/redis-6.0.9.tar.gz
[root@localhost local]# tar -zxvf redis-6.0.9.tar.gz
[root@localhost local]# cd redis-6.0.9
[root@localhost redis-6.0.9]# make
# 编译安装到指定目录下
[root@localhost redis-6.0.9]# make PREFIX=/usr/local/redis install
[root@localhost redis-6.0.9]# cp redis.conf /usr/local/redis/6379.conf
3、登陆测试
[root@localhost redis-6.0.9]# cd /usr/local/redis
[root@localhost redis]# ll
总用量 84
-rw-r--r--. 1 root root 84841 12月 19 22:57 6379.conf
drwxr-xr-x. 2 root root 134 12月 19 22:56 bin
[root@localhost redis]# ./bin/redis-server 6379.conf
51189:C 19 Dec 2020 22:57:22.206 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
51189:C 19 Dec 2020 22:57:22.206 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=51189, just started
51189:C 19 Dec 2020 22:57:22.206 # Configuration loaded
51189:M 19 Dec 2020 22:57:22.207 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.0.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 51189
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
51189:M 19 Dec 2020 22:57:22.208 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
51189:M 19 Dec 2020 22:57:22.208 # Server initialized
51189:M 19 Dec 2020 22:57:22.208 # 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.
51189:M 19 Dec 2020 22:57:22.208 # 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 madvise > /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 (set to 'madvise' or 'never').
51189:M 19 Dec 2020 22:57:22.209 * Ready to accept connections
复制一个连接窗口执行
[root@localhost bin]# cd /usr/local/redis
[root@localhost redis]# ./bin/redis-cli
127.0.0.1:6379> ping
PONG
安装已经成功,当然这不是结束,其他的配置直接再 6379.conf 修改即可