CentOS7源码安装redis6
CentOS7源码安装redis6
redis官网下载地址:
1.下载源码包
[root@localhost ~]# wget https://download.redis.io/releases/redis-6.2.8.tar.gz
2.安装依赖
redis6需要gcc高版本
[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 (临时启用)
[root@localhost ~]# echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile (永久启用)
3.解压安装
[root@localhost ~]# tar -xvf redis-6.2.8.tar.gz -C /usr/local/ [root@localhost ~]# cd /usr/local/redis-6.2.8/ [root@localhost ~]# make && make install
# redis-server在src目录下 [root@localhost redis-6.2.8]# find src -type f -executable -print src/mkreleasehdr.sh src/redis-trib.rb src/redis-server src/redis-sentinel src/redis-cli src/redis-benchmark src/redis-check-rdb src/redis-check-aof
4.启动redis
[root@localhost redis-6.2.8]# /usr/local/redis-6.2.8/src/redis-server 18489:C 03 Apr 2024 18:37:02.105 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 18489:C 03 Apr 2024 18:37:02.105 # Redis version=6.2.8, bits=64, commit=00000000, modified=0, pid=18489, just started 18489:C 03 Apr 2024 18:37:02.105 # Warning: no config file specified, using the default config. In order to specify a config file use /usr/local/redis-6.2.8/src/redis-server /path/to/redis.conf 18489:M 03 Apr 2024 18:37:02.106 * Increased maximum number of open files to 10032 (it was originally set to 1024). 18489:M 03 Apr 2024 18:37:02.106 * monotonic clock: POSIX clock_gettime _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 6.2.8 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 18489 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | https://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 18489:M 03 Apr 2024 18:37:02.107 # Server initialized 18489:M 03 Apr 2024 18:37:02.107 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. 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. 18489:M 03 Apr 2024 18:37:02.108 * Ready to accept connections
解决警告信息:
1. 内存 overcommit 警告
日志:
WARNING Memory overcommit must be enabled!
建议启用:
# 临时生效
sysctl vm.overcommit_memory=1
# 永久生效
echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl -p
或者放到 /etc/sysctl.d/99-redis.conf:
echo 'vm.overcommit_memory = 1' > /etc/sysctl.d/99-redis.conf
sysctl --system
这主要是为了避免后台 RDB 保存或复制在低内存条件下失败。
2. TCP backlog 警告
日志:
WARNING: The TCP backlog setting of 511 cannot be enforced because
/proc/sys/net/core/somaxconn is set to the lower value of 128.
Redis 配置的 tcp-backlog 是 511,但系统 somaxconn 只有 128。建议调大:
# 临时生效
sysctl -w net.core.somaxconn=1024
# 永久生效
echo 'net.core.somaxconn = 1024' >> /etc/sysctl.conf
sysctl -p
一般设置为 1024 或至少不低于 Redis 的 tcp-backlog。
重新启动redis,正常
[root@localhost redis-6.28]/usr/local/redis-6.2.8/src/redis-server
19899:C 28 Oct 2026 11:29:39.546 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
19899:C 28 Oct 2026 11:29:39.546 * Redis version=6.2.8, bits=64, commit=00000000, modified=0, pid=19899, just started
19899:C 28 Oct 2026 11:29:39.546 # Warning: no config file specified, using the default config. In order to specify a config file use /usr/local/redis-7.2.10/src/redis-server /path/to/redis.conf
19899:M 28 Oct 2026 11:29:39.546 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.8 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 19899
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
19899:M 28 Oct 2026 11:29:39.548 * Server initialized
19899:M 28 Oct 2026 11:29:39.548 * Ready to accept connections tcp

浙公网安备 33010602011771号