什么是Memlock?如何计算Memlock的值?(Doc ID 2511230.1)

What is Memlock and How to Calculate the Values for Memlock? (Doc ID 2511230.1)

APPLIES TO:

Linux OS - Version Oracle Linux 6.10 to Oracle Linux 7.6 [Release OL6U10 to OL7U6]
Linux x86
Linux x86-64

GOAL

This document describes the use of memlock and how to calculate the values for memlock
本文档介绍了memlock的用法以及如何计算memlock的值

SOLUTION

The memlock parameter specifies how much memory the user can lock into its address space. Note that Huge Pages are locked in physical memory.   memlock参数指定用户可以锁定其地址空间的内存量。请注意,巨大页面已锁定在物理内存中。

The value of the memlock should be at least 90 percent of the current RAM when HugePages memory is enabled and at least 3145728 KB (3 GB) when HugePages memory is disabled.  启用HugePages内存时,memlock的值应至少为当前RAM的90%,而禁用HugePages内存时,其值应至少为3145728 KB(3 GB)

To check whether hugepage is enabled or disabled, For example  检查是否启用hugepage

$ grep Huge /proc/meminfo

AnonHugePages: 0 kB
HugePages_Total: 306
HugePages_Free: 306
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB

Here it means that hugepage is enabled in OS but not yet used by the database.  

在这里,这意味着在操作系统中启用了大页面,但数据库尚未使用它。

HugePages_Rsvd --> This is the number of hugepages Kernel calculates as per the sga_target set in the complete system.

HugePages_Rsvd --> 这是内核根据整个系统中设置的sga_target计算的大页面数。

For calculating memlock:  计算memlock

Use "grep Huge| /proc/meminfo" to find the size of the huge page. It is probably 2048KB. Then multiply the number of huge pages you want to allocate by 2048. That's what you need to set memlock to.

使用"grep Huge| /proc/meminfo"查找Hugepagesize。它可能是2048KB。然后将要分配的Hugepagesize乘以2048。这就是将memlock设置为的值。

$ cat proc/meminfo | grep -i hugepages

AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB


For example. Let's say I want my SGA to be 32GB in size. Then with 2MB for each page, we're looking at 32768/2 = 16384 pages. I round up a bit because they all don't fit nicely into those pages. So I'd allocate 16400 huge pages. Then memlock would be 16400*2048 = 33587200.  
例如。假设我希望我的SGA大小为32GB。然后,每页有2MB,我们看的是32768/2 = 16384页。我总结一下,因为它们都不适合这些页面。因此,我将分配16400个huge pages。然后,memlock将为16400 * 2048 =33587200。
Memlock is one of the step while configuring the hugepages, for example see below:
Memlock是配置hugepages时的步骤之一,例如,请参见以下内容:
The below steps is to enter the number of hugepages in the server config file. For that you need root permissions.

以下步骤是在服务器配置文件中输入hugepages的数量。为此,您需要root权限。

$ vi /etc/sysctl.conf
<SNIP>
vm.nr_hugepages=20480
</SNIP>

Correctly inserted, following result should show up:  正确写入后,应显示以下结果:

$ grep vm.nr_hugepages /etc/sysctl.conf

vm.nr_hugepages=20480

The next parameter is hard and soft memlock in /etc/security/limits.conf for the user. This value should be smaller than available memory but minor to SGA. Hugepages should fit into that by 100 percent. 

下一个参数是用户的/etc/security/limits.conf中的hard and soft memlock。该值应小于可用内存,但小于SGA。Hugepages应该适合100%

For that following calculation:

Number Hugepages * Hugepagesize = minimum Memlock

Following example:
20480 * 2048 = 41943040
$ vi /etc/security/limits.conf

oracle soft memlock 41943040
oracle hard memlock 41943040

Correctly inserted, following result should show up:

$ grep oracle /etc/security/limits.conf

...
oracle soft memlock 41943040
oracle hard memlock 41943040 

NOTE: There is no impact in setting a higher value (less than RAM size).  注意:设置较高的值(小于RAM大小)没有影响。

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值