社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
建议修改好配置的daemonize为yes后,使用命令redis-server redis.conf应用改配 置文件启动redis
如果设置为127.0.0.1,则表示仅本机可访问,注销这句表示全部可以访问,这里我们注释掉。想配置内网访问,或者限定IP,一般使用云服务器安全组策略来配置实现。
protected-mode参数是为了禁止外网访问redis,如果启用了,则只能够通过lookback ip(127.0.0.1)访问Redis
logfile "/usr/local/redis/redis-4.0.12/logs/redis.log" # 建议先创建好redis.log文件,再来配置
redis提供了下面几种淘汰策略供用户选择,其中默认的策略为noeviction策略:
noeviction:当内存使用达到阈值的时候,所有引起申请内存的命令会报错。
allkeys-lru:在主键空间中,优先移除最近未使用的key。
volatile-lru:在设置了过期时间的键空间中,优先移除最近未使用的key。
allkeys-random:在主键空间中,随机移除某个key。
volatile-random:在设置了过期时间的键空间中,随机移除某个key。
volatile-ttl:在设置了过期时间的键空间中,具有更早过期时间的key优先移除。
requirepass foobared
第一个警告:The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
第二个警告: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.
第三个警告: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.
解决方案:
第一个警告:
将net.core.somaxconn = 1024添加到/etc/sysctl.conf中,然后执行sysctl -p 生效配置。
第二个警告:
将vm.overcommit_memory = 1添加到/etc/sysctl.conf中,然后执行sysctl -p生效配置。
第三个警告:
将echo never > /sys/kernel/mm/transparent_hugepage/enabled添加到/etc/rc.local中,然后执行source /etc/rc.local生效配置。
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!