Redis-启动时提示

阅读更多

 

8065:C 30 May 15:13:58.830 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8065:C 30 May 15:13:58.845 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=8065, just started
8065:C 30 May 15:13:58.845 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.1 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 8065
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

8065:M 30 May 15:13:58.847 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8065:M 30 May 15:13:58.847 # Server initialized
8065:M 30 May 15:13:58.847 # 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.
8065:M 30 May 15:13:58.848 # 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.
8065:M 30 May 15:13:58.889 * DB loaded from disk: 0.041 seconds
8065:M 30 May 15:13:58.889 * Ready to accept connections

 

 

启动分析:

The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
tcp backlog配置为511,但是linux系统中的设置为128.所以告警了。
[root@localhost 6379]# cat /proc/sys/net/core/somaxconn
128

    

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.

overcommit_memory设置值为0,在内存不足的时候,将影响后台保存。建议调整为1。
修改文件/etc/sysctl.conf ,添加 vm.overcommit_memory = 1 或者
执行命令 sysctl vm.overcommit_memory=1

1.overcommit_memory是什么?  
overcommit_memory是一个内核对内存分配的一种策略。 具体可见/proc/sys/vm/overcommit_memory下的值      
2.overcommit_memory有什么作用?  
overcommit_memory取值又三种分别为0, 1, 2
overcommit_memory=0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
overcommit_memory=1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
overcommit_memory=2, 表示内核允许分配超过所有物理内存和交换空间总和的内存
--------------------- 
作者:Loopers 
来源:CSDN 
原文:https://blog.csdn.net/longwang155069/article/details/50897026 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

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.
linux内核中,支持允许THP。这是redis不建议的。这将造成延迟和内存使用问题。
为了解决问题,用root身份执行命令
echo never > /sys/kernel/mm/transparent_hugepage/enabled
为了linux重启后还可以保存配置,推荐 写入到/etc/rc.local文件中。
为了THP配置生效,需要重启redis应用。

---------------------------------------------------------------------------------------

transparent_hugepage 是什么

只有64位系统才有transparent_hugepage功能。

从rhel6开始系统将默认对所有程序开启transparent_hugepage(THP),linux内核将尽可能的尝试分配2M的页大小给程序使用,内核空间在内存中自身是2M对齐的,目的是减少内核TLB(现代CPU使用一小块关联内存,用来缓存最近访问的虚拟页的PTE。这块内存称为translation lookaside buffer)的压力,增大page大小自然会减少TLB大小。如果内存没有2M连续大小的空间可分配,内核会回退到分配4KB页的方案。THP页也是可以换出的,这是通过把2M的大页分割成4KB的普通页实现的。

内核通过增加一个khugepaged内核线程,来不停的寻找连续的足够大的尽量对其的内存区域来满足内存分配请求。这个线程会偶尔尝试使用大的内存分配来替换连续的小内存页以最大化THP 的使用。

 

数据库应用不建议开启Transparent HugePages

ORACLE和mongodb数据库不建议开启THP,THP在运行时动态分配内存,可能会带来运行时内存分配的延误。

 

关闭Transparent HugePages

查询系统是否开启了THP命令

[root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@middle ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never

如果括号中的是always表示开启了,never则表示为开启

 

方案1

在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

或者新建一个service

[root@middle ~]# vi /etc/systemd/system/disable-thp.service

[Unit]
Description=Disable Transparent Huge Pages (THP)

[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"

[Install]
WantedBy=multi-user.target


[root@middle ~]#systemctl daemon-reload

使生效
[root@middle ~]#systemctl start disable-thp
开机即生效
[root@middle ~]#systemctl enable disable-thp
 

方案2

通过修改grub启动参数来实现

[root@middle ~]# cat /etc/default/grub  
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

将 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet" 这一行修改为

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet transparent_hugepage=never"

并执行

[root@middle ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
 

方案3

以上两个方案不是能实时生效,需要重启系统。如果需要实时生效需要

echo never >> /sys/kernel/mm/transparent_hugepage/enabled
echo never >> /sys/kernel/mm/transparent_hugepage/defrag

 

 
 

你可能感兴趣的:(redis,linux,kernel)