redis下载配置启动
wget http://download.redis.io/releases/redis-5.0.4.tar.gz
tar zxf redis-5.0.4.tar.gz && mv redis-5.0.4/ /usr/local/redis
[root@docker-registry redis]# ./src/redis-server
84658:C 13 Feb 2020 16:04:11.513 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
84658:C 13 Feb 2020 16:04:11.513 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=84658, just started
84658:C 13 Feb 2020 16:04:11.513 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
84658:M 13 Feb 2020 16:04:11.514 * 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: 84658
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
84658:M 13 Feb 2020 16:04:11.515 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
84658:M 13 Feb 2020 16:04:11.515 # Server initialized
84658:M 13 Feb 2020 16:04:11.515 # 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.
84658:M 13 Feb 2020 16:04:11.515 # 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.
84658:M 13 Feb 2020 16:04:11.515 * DB loaded from disk: 0.000 seconds
84658:M 13 Feb 2020 16:04:11.515 * Ready to accept connections
解决启动时候遇到的三个warning
- WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
永久解决
[root@docker-registry redis]# cat /etc/sysctl.conf |grep -v "#"
net.ipv4.ip_forward = 1
net.core.somaxconn= 1024
[root@docker-registry redis]# sysctl -p
net.ipv4.ip_forward = 1
net.core.somaxconn = 1024
2、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.
添加vm.overcommit_memory = 1到/etc/sysctl.conf
[root@docker-registry redis]# sysctl -p
net.ipv4.ip_forward = 1
net.core.somaxconn = 1024
vm.overcommit_memory = 1
3、you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.、
[root@docker-registry redis]# source /etc/rc.local
[root@docker-registry redis]# cat /etc/rc.local|grep -v "#"
touch /var/lock/subsys/local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
重启redis_server
[root@docker-registry redis]# ./src/redis-server
85693:C 13 Feb 2020 16:24:26.527 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
85693:C 13 Feb 2020 16:24:26.527 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=85693, just started
85693:C 13 Feb 2020 16:24:26.527 # Warning: no config file specified, using the default config. In order to specify a config file use ./src/redis-server /path/to/redis.conf
85693:M 13 Feb 2020 16:24:26.528 * 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: 85693
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
遇到的一些问题
- 启动redis_server时候ctrl+z[1]+ 已停止 ./src/redis-server,后台进程是存在的,但是本地redis-cli没有连接redis-server成功
[root@docker-registry redis]# ./src/redis-cli -h 127.0.0.1 -p 6379
^C
[root@docker-registry redis]# ps aux|grep redis
root 84658 0.0 0.6 153888 6716 pts/0 Tl 16:04 0:00 ./src/redis-server *:6379
- 解决方法
解决方法一:开启server后,开辟另一个终端redis-cli即可
解决方法二:修改redis.conf文件将daemonize改