redis之timeout连接超时问题解决
经反映redis连接超时,先定位到redis配置文件目录被删除;继而重启redis后出现连接中断问题(未启动成功);查看redis的输出日志时发下报以下错误:
根据提示在/etc/sysctl.conf文件中添加vm.overcommit_memory = 1,
修改其大透明页,并将调整redis的timeout从300到500重启正常;
echo never > /sys/kernel/mm/transparent_hugepage/enabled
关于vm.overcommit_memory
它是 内存分配策略 可选值:0、1、2。 0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。 1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。 2, 表示内核允许分配超过所有物理内存和交换空间总和的内存
关于Overcommit和OOM
Linux对大部分申请内存的请求都回复"yes",以便能跑更多更大的程序。因为申请内存后,并不会马上使用内存。这种技术叫做 Overcommit。 当linux发现内存不足时,会发生OOM killer(OOM=out-of-memory)。它会选择杀死一些进程(用户态进程,不是内核线程),以便释放内存。 当oom-killer发生时,linux会选择杀死哪些进程?选择进程的函数是oom_badness函数(在mm/oom_kill.c中),该 函数会计算每个进程的点数(0~1000)。 点数越高,这个进程越有可能被杀死。每个进程的点数跟oom_score_adj有关,而且 oom_score_adj可以被设置(-1000最低,1000最高)。
关于/sys/kernel/mm/transparent_hugepage/enabled
透明大页介绍 Transparent Huge Pages的一些官方介绍资料: Transparent Huge Pages (THP) are enabled by default in RHEL 6 for all applications. The kernel attempts to allocate hugepages whenever possible and any Linux process will receive 2MB pages if the mmap region is 2MB naturally aligned. The main kernel address space itself is mapped with hugepages, reducing TLB pressure from kernel code. For general information on Hugepages, see: What are Huge Pages and what are the advantages of using them? The kernel will always attempt to satisfy a memory allocation using hugepages. If no hugepages are available (due to non availability of physically continuous memory for example) the kernel will fall back to the regular 4KB pages. THP are also swappable (unlike hugetlbfs). This is achieved by breaking the huge page to smaller 4KB pages, which are then swapped out normally. But to use hugepages effectively, the kernel must find physically continuous areas of memory big enough to satisfy the request, and also properly aligned. For this, a khugepaged kernel thread has been added. This thread will occasionally attempt to substitute smaller pages being used currently with a hugepage allocation, thus maximizing THP usage. In userland, no modifications to the applications are necessary (hence transparent). But there are ways to optimize its use. For applications that want to use hugepages, use of posix_memalign() can also help ensure that large allocations are aligned to huge page (2MB) boundaries. Also, THP is only enabled for anonymous memory regions. There are plans to add support for tmpfs and page cache. THP tunables are found in the /sys tree under /sys/kernel/mm/redhat_transparent_hugepage.
查看是否启用透明大页
cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never使用命令查看时,如果输出结果为[always]表示透明大页启用了。[never]表示透明大页禁用、[madvise]表示(只在MADV_HUGEPAGE标志的VMA中使用THP 如何HugePages_Total返回0,也意味着标准大页禁用了(注意传统/标准大页和透明大页的区别) 透明大页(THP)管理和标准/传统大页(HP)管理都是操作系统为了减少页表转换消耗的资源而发布的新特性,虽然ORACLE建议利用大页机制来提高数据库的性能,但是ORACLE却同时建议关闭透明大页管理。这二者的区别在于大页的分配机制,标准大页管理是预分配的方式,而透明大页管理则是动态分配的方式。 [ ~]# grep -i HugePages_Total /proc/meminfo HugePages_Total: 0 cat /proc/sys/vm/nr_hugepages返回0也意味着传统大页禁用了(传统大页和透明大页)。[ ~]# cat /proc/sys/vm/nr_hugepages 0
相关推荐
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04