In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about how to optimize the Hugepages of linux memory, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Hugepages was introduced after Linux kernal 2.6, and its purpose is to use larger memory page size to accommodate the increasing system memory.
Theoretical knowledge:
(1. Page Table size
The common page size of Hugepages is 2m, which is 500 times that of 4k size, so the size of page table can be greatly reduced.
This is a system without Hugepage, and the memory of the system is about 4 gigabytes.
Cat / proc/meminfoMemTotal: 132086880 kBPageTables: 4059612 kB this is a system configured with Hugepage. The system memory is 96g, and the PageTable size is only 78MMemTotal: 98999880 kBPageTables: 79916 the virtual memory address segment of the kB process is connected to the page tables and then to the physical memory. So when accessing memory, you need to access page tables to get the mapping between virtual memory and physical memory, and then access physical memory.
(3. Memory pages using Hugepages will not be swapped out and will always be resident in memory, so it also reduces the extra overhead of memory replacement.
2. Several points that should be paid attention to when using Hugepages on database server
For example, if the Hugepages is set to 90G and the Oracle SGA is set to 91G, then oracle will not use the 90G Hugepages at startup. This 90g is wasted. So when setting up the Hugepages, you need to calculate the size of the SGA, and a script will be given to calculate it later.
(3. PGA does not use Hugepages memory. So 11g AMM (Automatic Memory Management,memory_target parameter) is not supported. ASMM (Automatic Shared Memory Management, SGA_target parameter) is supported, so don't confuse the two.
Examples are as follows:
HugePages_Total: 43000HugePages_Free: 29493HugePages_Rsvd: 23550Hugepagesize: 2048 kBHugePages_Total is the number of pages allocated, multiplied by Hugepagesize to get the allocated memory size. The number of 84GBHugePages_Free is about the number of Hugepages that has never been used. Even though oracle sga has allocated this part of memory, if there is no actual write, you will still see Free. It is easy to misunderstand that HugePages_Rsvd is the number of page that has been allocated and reserved but not yet used. When Oracle is just started, most of the memory should be Reserved and Free, with the use of oracle SGA, Reserved and Free will continue to reduce HugePages_Free-HugePages_Rsvd this part of the memory is not used, if there is no other oracle instance, this part of memory may never be used, that is, wasted. Memory with 11.5GB on this system is wasted. 3. Set HugePages steps:
Add the memlock limit to the / etc/security/limits.conf file, noting that this value is slightly less than the actual physical memory. For example, the physical memory is 64GB, which can be set as follows:
* hard memlock 60397977
If you use Oracle Linux's oracle?-validated package, or Exadata DB compute will automatically configure this parameter.
Step 2: verify that memlock uses the following command to check the parameter values: here, it is best to restart the server and then verify, which is relatively safe.
60397977
Step 3: disable AMM in 11g-pay attention
In addition: ASM instance also uses AMM by default, but because ASM instances do not require large SGA, it does not make much sense to use HugePages for ASM instances.
Ensure that all database instances have been started, including ASM instances. Use the hugepages_settings.sh script to get the recommended values for the thevm.nr_hugepages kernel parameters.
... (slightly)
...
Verify the configuration:
To ensure the validity of the HugePages configuration, the HugePages_ Free value should be less than the HugePages_Total value and equal to the HugePages_Rsvd value.
Example: machine configuration: 128g physical memory + 56g SGA
Root > # grep HugePages / proc/meminfoHugePages_Total: 28674HugePages_Free: 707HugePages_Rsvd: 706
Attached calculation hugepages script:
#! / bin/bash## hugepages_settings.sh## Linux bash script to compute values for the# recommended HugePages/HugeTLB configuration## Note: This script does calculation for all shared memory# segments available when the script is run No matter it# is an Oracle RDBMS sharedmemory segment or not.## This script is provided by Doc ID 401749.1 from My Oracle Support# http://support.oracle.com# Welcome textecho "This script is provided by Doc ID 401749.1 from My Oracle Support (http://support.oracle.com) where it is intended to compute values forthe recommended HugePages/HugeTLB configuration forthe current sharedmemory segments. Before proceeding with the execution please make surethat: * Oracle Database instance (s) are up and running * Oracle Database 11g Automatic Memory Management (AMM) is not setup (See Doc ID 749851.1) * The shared memory segments can be listed by command: # ipcs-mPress Enter to proceed... "read# Check for the kernel versionKERN= `uname-r | awk-F. '{printf ("% d% d\ n", $1 do MIN_PG= 2);}' `# Find out the HugePage sizeHPG_SZ= `grep Hugepagesize / proc/meminfo | awk'{Initialize the counterNUM_PG=0# Cumulative number of pages required to handle the running shared memory segmentsfor SEG_BYTES in $2}'`# Initialize the counterNUM_PG=0# Cumulative number of pages required to handle the running shared memory segmentsfor SEG_BYTES in `ipcs-m | awk'{print $5}'| grep "[0-9] [0-9] *" `do MIN_PG= `echo "$SEG_BYTES/ ($HPG_SZ*1024)" | bc-q`if [$MIN_PG-gt 0] Then NUM_PG= `echo "$NUM_PG+$MIN_PG+1" | bc-q`echo `echo "$NUM_PG * $HPG_SZ * 1024" | bc-q` # An SGA less than 100MB does not make sense# Bail out if that is the caseif [$RES_BYTES-lt 100000000]; then echo "*" echo "* * ERROR * *" echo "*" echo "Sorry! There are not enough total of shared memory segments allocated forHugePages configuration. HugePages can only be used for shared memory segmentsthat you can list by command: # ipcs-mof a size that can match an Oracle Database SGA. Please make sure that: * Oracle Database instance is up and running * Oracle Database 11g Automatic Memory Management (AMM) is not configured "exit 1fi# Finish with resultscase $KERN in '2.4') HUGETLB_POOL= `echo" $NUM_PG*$HPG_SZ/1024 "| bc-q`; echo" Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL "; '2.6') echo" Recommended setting: vm.nr_hugepages = $NUM_PG "; *) echo" Unrecognized kernel version $KERN. Exiting. "; esac
The above is how to optimize the Hugepages of linux memory. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.