ES mlockall作用——preventing that memory from being paged to the swap area

elasticsearch还有一个重要的参数bootstrap.mlockall,这个参数的目的是当你无法关闭系统的swap的时候,建议把这个参数设为true。防止在内存不够用的时候,elasticsearch的内存被交换至交换区,导致性能骤降

 

mlock, munlock, mlockall, munlockall - lock and unlock memory

Synopsis

#include <sys/mman.h>

int mlock(const void *addr, size_t len);
int munlock(const void *addr, size_t len);

int mlockall(int flags);
int munlockall(void);

Description

mlock() and mlockall() respectively lock part or all of the calling process's virtual address space into RAM, preventing that memory from being paged to the swap areamunlock() andmunlockall() perform the converse operation, respectively unlocking part or all of the calling process's virtual address space, so that pages in the specified virtual address range may once more to be swapped out if required by the kernel memory manager. Memory locking and unlocking are performed in units of whole pages.

 

mlock系统调用的作用mlock系统调用允许程序在物理内存上锁住它的部分或全部地址空间,这将阻止Linux将这个内存页调度到交换空间(即阻止系统将某个页面换出到交换分区),即使该程序已有一段时间没有访问这段空间。一个严格时间相关的程序可能会希望锁住物理内存,因为内存页面调出调入的时间延迟可能太长或过于不可预知。安全性要求较高的应用程序可能希望防止敏感数据被换出到交换文件中,因为这样在程序结束后,攻击者可能从交换文件中恢复出这些数据。锁定一个内存区间只需简单将指向区间开始的指针及区间长度作为参数调用mlock()Linux分配内存到页且每次只能锁定整页内存,被指定的区间涉及到的每个内存页都将被锁定。

 

参考:https://linux.die.net/man/2/mlockall

转载于:https://www.cnblogs.com/bonelee/p/6207097.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值