wget http://download.redis.io/redis-stable.tar.gz
tar xf redis-stable.tar.gz
cd redis-stable
make
出现报错:
CC server.o
In file included from server.c:30:0:
server.h:1045:5: 错误:expected specifier-qualifier-list before ‘_Atomic’
_Atomic unsigned int lruclock; /* Clock for LRU eviction */
sam src ./redis-server
26796:C 22 May 2020 16:33:41.620 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
26796:C 22 May 2020 16:33:41.620 # Redis version=6.0.3, bits=64, commit=00000000, modified=0, pid=26796, just started
26796:C 22 May 2020 16:33:41.620 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.0.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 26796
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
26796:M 22 May 2020 16:33:41.621 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
26796:M 22 May 2020 16:33:41.621 # Server initialized
26796:M 22 May 2020 16:33:41.621 # 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.
26796:M 22 May 2020 16:33:41.621 # 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.
26796:M 22 May 2020 16:33:41.622 * Ready to accept connections
sam src$ sudo netstat -lnapt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 26796/./redis-serve
安装
出现报错:
原因是定主数据结构里用了
_Atomic
这个关键字,而系统里的 gcc 版本还不支持这个关键字。安装 clang 用 clang 编译:
在 src/ 下生成了几个可执行文件:
启动
./redis-server
启动 redis启动信息:
从其中可以看到一些信息:
./redis-server /path/to/redis.conf
TCP backlog
就是监听队列大小 511 的设置未生效,因为 Centos 系统的默认限制没改/proc/sys/net/core/somaxconn
默认是 128可见 redis 非常依赖操作系统的一些配置优化。
netstat 查看一下端口使用情况:
试试