歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Oracle Linux 7禁用Transparent HugePages

Oracle Linux 7禁用Transparent HugePages

日期:2017/2/28 13:53:41   编辑:Linux教程

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]

Copyright © Linux教程網 All Rights Reserved