警告-

Increased maximum number of open files to 10032 (it was originally set to 1024).

解决:

#查看系统限制  
[root@centos224]# ulimit -a  
  
#设置“open files”数量  
[root@centos224]# ulimit -n 10032  
  
#或者设置用户限制  
[root@centos224]# vi /etc/security/limits.conf

警告二

1、WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

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.

解决

第一个警告:
echo 1 > /proc/sys/vm/overcommit_memory  不需要启机器就生效
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf  


第二个警告:
echo 1024 > /proc/sys/net/core/somaxconnn  echo redis是511
echo  "net.core.somaxconn  = 1020" > /etc/sysctl.conf ;

overcommit_memory参数说明:

设置内存分配策略(可选,根据服务器的实际情况进行设置)
/proc/sys/vm/overcommit_memory
可选值:0、1、2。
0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2, 表示内核允许分配超过所有物理内存和交换空间总和的内存

第三个警告:

`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.`
[root@centos224]# echo never > /sys/kernel/mm/transparent_hugepage/enabled  
[root@centos224]# vi /etc/rc.local  
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then  
   echo never > /sys/kernel/mm/transparent_hugepage/enabled  
fi  
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then  
   echo never > /sys/kernel/mm/transparent_hugepage/defrag  
fi
################################## NETWORK #####################################
 
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

解决办法:注释掉bind 127.0.0.1可以使所有的ip访问redis

在redis3.2之后,redis增加了protected-mode,在这个模式下,即使注释掉了bind 127.0.0.1,再访问redisd时候还是报错,如下

redis

解决办法:protected-mode no 。添加验证密码也可以解决问题

添加验证密码

在3.2.10里面没有

#requirepass

没有这选项注释好的,找一个空白行、设置密码为123321

``

Last modification:February 10, 2020
如果觉得我的文章对你有用,请随意赞赏