Oracle Linux 7禁用Transparent HugePages

eric0435發表於2016-03-29

Transparent HugePages記憶體在Red Hat企業Linux 6,SUSE 11和Oracle Linux 6的Oracle Linux Unbreakable Enterprise Kernel2(UEK2)早期版本中預設是啟用的。Transparent HugePages記憶體在Oracle Linux Unbreakable Enterprise Kernel2(UEK2)核心中預設情況下是禁用的。"tuned.service"在Oracle Linux7中預設是將transparent_hugepage設定為always。即使在grub核心命令列中它是禁用的,在boot時tuned service將被設定為'always'。在UEK3中預設情況下是禁用的。

Transparent HugePages可能會造成記憶體在執行時的延遲分配。為了避免效能問題,Oracle強烈建議對所有Oracle資料庫伺服器禁用Transparent HugePages。為了提高效能Oracle建議使用標準HugePages。

Transparent HugePages記憶體與標準HugePages記憶體的差異在於核心khugepaged執行緒在執行時動態分配記憶體。標準HugePages記憶體是在啟動時預先分配在執行時不會發生改變。
1.檢查Transparent HugePage是否被啟用

[root@oracle12c ~]# uname -r
3.10.0-123.el7.x86_64
[root@oracle12c ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never ---這說明Transparent Hugepage被啟用

2.有兩種禁用Transparent HugePage的模式
2.1對吞吐效能方面全域性禁用Transparent HugePage
先對檔案/usr/lib/tuned/throughput-performance/tuned.conf進行備份

[root@oracle12c ~]# ls -lrt /usr/lib/tuned/throughput-performance/tuned.conf*
-rw-r--r--. 1 root root 2050 May 7 2014 /usr/lib/tuned/throughput-performance/tuned.conf
-rw-r--r--. 1 root root 2050 Mar 29 11:04 /usr/lib/tuned/throughput-performance/tuned.conf.bkp

[root@oracle12c ~]# more /usr/lib/tuned/throughput-performance/tuned.conf | grep "transparent_hugepages"
transparent_hugepages=always

修改檔案/usr/lib/tuned/throughput-performance/tuned.conf,將其中的
[vm]
transparent_hugepages=always
修改為
[vm]
transparent_hugepages=never

[root@oracle12c ~]# more /usr/lib/tuned/throughput-performance/tuned.conf | grep "transparent_hugepages"
transparent_hugepages=never

重啟作業系統來驗證修改結果

[root@oracle12c ~]# uname -r
3.10.0-123.el7.x86_64
[root@oracle12c ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

2.2.對正使用的調整概要檔案禁用Transparent HugePage
先識別正使用的調整概要檔案

[root@oracle12c ~]# tuned-adm active
Current active profile: virtual-guest --這說明當前正使用的概要檔案是Virtual-guest

Virtual-guest profile是使用檔案/usr/lib/tuned/virtual-guest/tuned.conf,並且它包含了來自檔案/usr/lib/tuned/throughput-performance/tuned.conf中的"throughput-performance"。首先對檔案/usr/lib/tuned/virtual-guest/tuned.conf進行備份

[root@oracle12c ~]# cp /usr/lib/tuned/virtual-guest/tuned.conf /usr/lib/tuned/virtual-guest/tuned.conf.bkp
[root@oracle12c ~]# ls -lrt /usr/lib/tuned/virtual-guest/tuned.conf*
-rw-r--r--. 1 root root 697 Nov 6 2013 /usr/lib/tuned/virtual-guest/tuned.conf
-rw-r--r--. 1 root root 697 Mar 29 11:26 /usr/lib/tuned/virtual-guest/tuned.conf.bkp

[root@oracle12c ~]# more /usr/lib/tuned/virtual-guest/tuned.conf
#
# tuned configuration
#

[main]
include=throughput-performance

[sysctl]
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up. Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 30

# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 30

向檔案/usr/lib/tuned/virtual-guest/tuned.conf中增加"transparent_hugepages=never"來禁用
Transparent HugePage

[root@oracle12c ~]# vi /usr/lib/tuned/virtual-guest/tuned.conf
#
# tuned configuration
#

[main]
include=throughput-performance
[vm]
transparent_hugepages=never
[sysctl]
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up. Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 30

# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 30

重啟作業系統來驗證結果

[root@oracle12c ~]# uname -r
3.10.0-123.el7.x86_64
[root@oracle12c ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2071593/,如需轉載,請註明出處,否則將追究法律責任。

相關文章