ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux 6 大页设置

linux 6 大页设置

原创 Linux操作系统 作者:zy_rain 时间:2023-07-13 17:21:58 1 删除 编辑

linux 6大页设置

1.1linux 6 禁用透明大页

官方文档资料:

D isabling Transparent HugePages

Starting with Red Hat Enterprise Linux 6, Oracle Linux 6, SUSE 11 and  Unbreakable Enterprise Kernel 2 (UEK2) kernels, Transparent HugePages  are enabled by default at runtime. However, Transparent HugePages might  cause delays 

in memory allocation because memory is allocated  dynamically. Hence, Oracle recommends that you disable Transparent  HugePages on all Oracle Database servers to avoid performance issues.

Although Transparent HugePages are similar to HugePages, they are set up dynamically at runtime by the khugepaged  thread in the kernel while standard HugePages are preallocated at  startup. 

Oracle recommends that you use standard HugePages for enhanced  performance.

To check if Transparent HugePages are enabled run one of the following commands as the root user:

Red Hat Enterprise Linux kernels:

# cat /sys/kernel/mm/redhat_transparent_hugepage/enab'led

Other kernels:

# cat /sys/kernel/mm/transparent_hugepage/enabled

The following is a sample output that shows Transparent HugePages are being used as the [always] flag is enabled.

[always] never

Note:

If Transparent HugePages are removed from the kernel then the /sys/kernel/mm/transparent_hugepage or /sys/kernel/mm/redhat_transparent_hugepage files do not exist.

To disable Transparent HugePages perform the following steps:

  1. Add the following entry to the kernel boot line in the /etc/grub.conf file:

    transparent_hugepage=never

    For example:

    title Oracle Linux Server (2.6.32-300.25.1.el6uek.x86_64)         root (hd0,0)         kernel /vmlinuz-2.6.32-300.25.1.el6uek.x86_64 ro root=LABEL=/ transparent_hugepage=never         initrd /initramfs-2.6.32-300.25.1.el6uek.x86_64.img
  2. Restart the system to make the changes permanent.

1.2 实际操作:

1.2.1 查看透明大页状态

[root@racdbdg grub]# cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

[always]表示透明大页启用

1.2.2 添加 transparent_hugepage=never 到 /etc/grub.conf

[root@racdbdg ~]# vi  /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,1)

#          kernel /vmlinuz-version ro root=/dev/sda4

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda1

device (hd0) HD(1,800,1f4000,fddaa853-5701-4852-9d09-318f8c745a14)

default=1

timeout=5

splashimage=(hd0,1)/grub/splash.xpm.gz

hiddenmenu

title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-61.1.28.el6uek.x86_64)

root (hd0,1)

kernel /vmlinuz-4.1.12-61.1.28.el6uek.x86_64 ro root=UUID=2ee4f5d9-d364-4dc5-8c1f-6e8746670d00 rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=a

uto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet        initrd /initramfs-4.1.12-61.1.28.el6uek.x86_64.img

title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-696.el6.x86_64)

root (hd0,1)

kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=UUID=2ee4f5d9-d364-4dc5-8c1f-6e8746670d00 rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M  KE

YBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet transparent_hugepage=never        

        initrd /initramfs-2.6.32-696.el6.x86_64.img

1.2.3 重启系统

reboot

[root@racdbdg ~]#  cat /sys/kernel/mm/transparent_hugepage/enabled

always madvise [never]

[never]表示已经禁用透明大页

2.标准大页的配置

大页设置步骤“关闭数据库-->调整大页-->启动数据库”,不要先“调整大页-->启动数据库”,否则可能导致中间数据库使用普通内存,系统又使用大页,导致内存不够用。

设置步骤:

2.1 修改数据库参数,主要是不使用memory_target参数

alter system set memory_target = 0 scope = spfile;

alter system set use_large_page = only scope =   spfile;   #这个参数最好不要设置,否则如果大页配置不够用,数据库就起不来了,使用默认值true即可

下面的参数根据实际情况配置

alter   system set sga_max_size=60G scope=spfile;

alter   system set sga_target=0 scope=spfile;

alter   system set pga_aggregate_target=10240M scope=spfile;

alter   system set shared_pool_size=12G scope=spfile;

alter   system set db_cache_size=36G scope=spfile;

alter   system set large_pool_size=3G scope=spfile;

 2.2 停库

sqlplus / as sysdba

shutdown immediate

 2.3 检查/proc/meminfo, 确认系统支持HugePage

cat /proc/meminfo | grep HugePage

HugePage_Total:   0

HugePage_Free:    0

HugePage_Rsvd:   0

Hugepagesize:      2048 kB

2.4 计划要设置的内存大页数量

计算公式为:sga(MB)/2M + 100   #其实比 sga(MB)/2M 大几十或100都行

如:假如 SGA = 215G,那么内存页 = 215*1024/2 + 100 = 110180

vi   /etc/sysctl.conf

vm.nr_hugepages   = 110180

让设置生效,执行

 sysctl -p

2.5 在limits.conf中设置 oracle用户和 grid 用户可以锁定的内存大小,以KB为单位

确认memlock参数配置

ulimit -a | grep "max locked memory"     #如果设置的过小需要按照下面的配置进行修改

vi   /etc/security/limits.conf

oracle   soft memlock 41947136

oracle   hard memlock 41947136

grid   soft memlock 41947136

grid   hard memlock 41947136

或者不设限

oracle   soft memlock -1

oracle   hard memlock -1

grid   soft memlock -1

grid   hard memlock -1

然后用oracle用户和grid用户连接到数据库服务器,使用 ulimit -a 参数查看是否生效

2.6  启动数据库

sqlplus / as sysdba

startup

2.7 检查大页是否生效

a.  检查/proc/meminfo 中HugePages_Free是否已经减少,如果已经减少,表明已经使用到HugePage Memory

b. 检查数据库实例启动日志如下标红部分是否为100%, 为100%,表明已经使用HugePage Memory.

Starting ORACLE instance (normal)

*********************************** Large Pages Information *****************************************

Per process system memlock (soft) limit = 64KB

Total Shared Global Region in Large Pages = KB (100%)

2.8 设置其他节点

按照上面的操作,分别配置其他节点的hugepage.

------Learning records ------the end------


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30349701/viewspace-2964054/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
没有刻骨铭心的记忆,怎么会有潇洒自如的帅气!

注册时间:2015-07-15

  • 博文量
    16
  • 访问量
    17897