Linux system hugepage Memory function configuration detailed

Source: Internet
Author: User
Tags memory usage oracle database

In the Linux Environment Performance optimization practice, Hugepage is a frequently mentioned method. Simply put, Hugepage is a way of using memory blocks on the Linux kernel. As an alternative to the traditional 4K page, Hugepage can improve the performance efficiency of Oracle instances in most scenarios.

First, Hugepage Introduction

Hugepage is widely enabled to start with Kernal 2.6, and some versions of the 2.4 kernel can also be used. In the operating system Linux environment, memory is allocated as page pages, with a default size of 4K. If larger memory space is required, frequent page allocations and administrative addressing actions are required.

Hugepage is an alternative to the traditional 4K page. As the name suggests, is using hugepage can let us have a larger memory paging size. This process involves the OS memory addressing process, whether it is hugepage or the traditional normal page.

When a process accesses memory, it is not directly to access the memory location, it is necessary to transfer the transformation through the page table. In the case of using Hugepage, Pagetable has an additional attribute to determine whether the page records are hugepage or regular pages.

There are many benefits to opening hugepage in an Oracle operating environment. Specifically as follows:

Non-swap memory: When the Hugepage is opened, the hugepage is not swap;
Reduce the burden of TLB (translation look aside buffer): TBL is a buffer area inside the CPU that includes part of the page table content. Using Hugepage can reduce the TLB workload;
Reduce the page table space load: In pagetable management, each page record occupies 64byte of space. In other words, if a 50G ram,4k size of the pagetable to have 80MB or so;
Reduced pagetable retrieval load: Smaller pagetable means faster retrieval and positioning capabilities;
Memory Performance Improvement: page number reduced, the size of the increase, reducing the complexity of the management process, and further reduce the probability of the occurrence of bottlenecks;
For Oracle, the Instance Runtime Environment (database and ASM) faces a hugepage optimization problem.

II. Basic Environmental Preparedness

We chose the CentOS version under Kernel2.6 to carry out the experiment.

[Oracle@361way ~]$ Uname-r
2.6.18-128.el5
At this point, the Oracle instance is 11GR2 (11.2.0.3), running in AMM memory management mode. The shared memory segment information is as follows.

[Oracle@361way ~]$ Ipcs-m
------Shared Memory Segments--------
Key shmid owner perms bytes nattch Status
0x00000000 32768 Oracle 640 4096 0
0x00000000 65537 Oracle 640 4096 0
0X01606D30 98306 Oracle 640 4096 0
[Oracle@361way ~]$ grep huge/proc/meminfo
hugepages_total:0
hugepages_free:0
hugepages_rsvd:0
hugepagesize:4096 KB

Note Two questions: one is that currently we do not have hugepage enabled in Meminfo, so there is no corresponding record. The other is AMM, Ipcs–m displays a shared memory size of only three 4096bytes per size.

This question is more complicated, this article introduces a beginning. In 10g, Oracle introduced the Sga_target series parameters and implemented the ASMM (Automatic Shared Memory Management). The essence of ASMM is to realize the dynamic adjustment between the SGA and the various pools within the PGA. However, in 11g, Amm (Automatic Memory Management) was introduced to achieve the adjustment between PGA and SGA.

AMM is actually complicated. The SGA is implemented through system shared memory in Linux, and the PGA is implemented through the process private space. AMM is actually the largest function of the SGA and PGA space-regulated channels through, which will inevitably bring the original SGA shared memory mode of architecture. When AMM, the virtual empty shared segment displayed by Ipcs–m is part of the actual effect.

Third, user memory configuration

The first step in enabling Hugepage is to get the user-parameter limit through and the current memory size is as follows:

--Memory information

[Root@361way ~]# free-t
             Total        used       free     Shared     buffers     Cached
mem:        918380     205044     713336           0      14744     152996
-/+ buffers/cache:       37304     881076
swap:      2455788           0    2455788
total:      3374168     205044    3169124
Modify/etc/security/ limits.conf The parameter file, add the Memlock limit for the database instance user.

[Root@361way ~]# cat/etc/security/limits.conf
#/etc/security/limits.conf
#
(space reason, omitted ...)
#       -fsize-maximum filesize (KB)
#     & nbsp; -Memlock-max locked-in-memory address space (KB)
#       -Nofile- Max number of open files
#ftp              hard     nproc           0
# @student         -       maxlogins       4
Oracle Soft NPROC 2047
Oracle hard nproc 16384
Oracle Soft nofile 1024
Oracle Hard nofile 65536
Oracl E Soft memlock 918380
Oracle Hard Memlock 918380
# End of File
This procedure uses the Memlock tag to set the maximum allowable memory usage per user. This value can be set to the size of the database server's physical memory. Switch to the specified user (Oracle) to view the settings.

[Oracle@361way ~]$ Ulimit-l
918380

Iv. Oracle Setup

If you are using the 11g Oracle version, you will need to make additional configuration to degrade the AMM used to ASMM. This step is important in the early version 11.2.0.1. Because AMM does not support hugepage, if you open the database in Amm+hugepage mode, you will encounter failure information.

In the latest version 11.2.0.2 and after, the introduction of parameter use_large_pages to avoid such a problem. But AMM is incompatible with hugepage, or it exists.

The database is currently using AMM.

Sql> Show parameter target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
Archive_lag_target integer 0
Db_flashback_retention_target integer 1440
Fast_start_io_target integer 0
Fast_start_mttr_target integer 0
Memory_max_target Big Integer 360M
Memory_target Big Integer 360M
Parallel_servers_target Integer 16
Pga_aggregate_target Big Integer 0
Sga_target Big Integer 0
The key to AMM is two aspects, one is Memory_target and Memory_max_target set Non-null. The other is sga_target and pga_aggregate_target parameter set to NULL. If you want to turn off the AMM and degenerate the asmm, you need to set the instance startup parameter.

Note: This article is not to modify the AMM to ASMM as the focus, this part of the content slightly, left to other articles to explain. After modification, the server needs to be restarted because some of the parameters belong to static parameters.

Sql> Conn/as SYSDBA
Connected.
Sql> Show parameter target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
Archive_lag_target integer 0
Db_flashback_retention_target integer 1440
Fast_start_io_target integer 0
Fast_start_mttr_target integer 0
Memory_max_target Big Integer 0
Memory_target Big Integer 0
Parallel_servers_target Integer 16
Pga_aggregate_target Big Integer 108M
Sga_target Big Integer 252M
Note that the shared memory mechanism is really implemented at this time, and we can see the real shared segment from the ipcs–m.

[Oracle@361way dbs]$ Ipcs-m
------Shared Memory Segments--------
Key shmid owner perms bytes nattch Status
0x00000000 327680 Oracle 640 4194304 27
0x00000000 360449 Oracle 640 260046848 27
0X01606D30 393218 Oracle 640 4194304 27


v. Experience script calculates hugepage maximum value

In MOS 401749.1, Oracle recommends a shell script to compute the hugepage value. Run this script to set the computed values in the system parameters.

[Oracle@361way upload]$ ls-l | grep huge
-rwxr-xr-x 1 Oracle Oinstall 3037 Oct 09:42 hugepages_settings.sh
Execute the script and note that all instances of Oracle, including database and ASM, are started, AMM closed, and the SGA size exceeds 100M in this process.

[Oracle@361way upload]$./hugepages_settings.sh
This script. is provided by Doc ID 401749.1 from my Oracle Support
(http://support.oracle.com) where it is intended to compute values for
The recommended hugepages/hugetlb configuration for the current shared
Memory segments. Before proceeding with the execution * note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* the ' pga_aggregate_target ' is outside the SGA and
You are should accommodate this while calculating SGA size.
* In case you changes the DB SGA size,
As the new SGA won't be fit in the previous hugepages configuration,
It had better disable the whole hugepages,
Start the DB with new SGA size and run the script. Again.
And make sure that:
* Oracle Database instance (s) are up and running
* Oracle Database 11g Automatic Memory Management (AMM) is not setup
(For the Doc ID 749851.1)
* The shared memory segments can is listed by command:
# ipcs-m
Press Enter to proceed ...
Recommended Setting:vm.nr_hugepages = 67

Change the calculated 67 parameter/etc/sysctl.conf

--Set parameters

[Root@361way ~]# vi/etc/sysctl.conf
(add content as follows ...) )
Vm.nr_hugepages = 67
"/etc/sysctl.conf" 49L, 1325C written
Use Sysctl–p to take effect settings.

[Root@361way ~]# Sysctl-p
Net.ipv4.ip_forward = 0
(Space reasons, there are omitted ...) )
Net.core.wmem_max = 1048586
Vm.nr_hugepages = 67


Six, hugepage start test

After setting, it is a good idea to reboot the server, including Oracle.

[Oracle@361way ~]$ Ipcs-m
------Shared Memory Segments--------
Key shmid owner perms bytes nattch Status
0x00000000 32768 Oracle 640 4194304 26
0x00000000 65537 Oracle 640 260046848 26
0X01606D30 98306 Oracle 640 4194304 26
[Oracle@361way ~]$ grep huge/proc/meminfo
hugepages_total:67
Hugepages_free:3
hugepages_rsvd:0
hugepagesize:4096 KB
In the Meminfo file, you can find information about Hugepages, which indicates successful activation.

Vii. Summary

The block size of normal physical memory is 4KB, when physical memory expands to 8GB. The number of memory blocks that need to be managed is greatly increased, while the use of memory requires CPU resources, which means that the more memory blocks the program uses, the less efficient the system is, and the higher the amount of memory used may result in a failure to allocate. And when the memory is allocated, the higher the CPU resource occupancy rate.

The Hugepages technology is available on Linux systems for large memory (Very Large Memory). is to use the larger memory page to manage, so that for today's high-end models, 16GB, 32GB of memory can also be relatively easy to cope with. On a Redhat Linux system, the size of a memory page is 2MB.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.