由于客户32G内存中,而且连接数非常多。考虑到这样的因素,对其服务器使用linux 中hugepage的功能,由于Oracle AMM管理方式不能和hugepage共同使用,需要将ORACLE内存管理方式变换为ASMM才能与hugepage使用。在调试的过程中遇到了一些问题。和一些解决方法。
这里我用测试机演示
[root@oracle ~]# uname -a
Linux oracle 2.6.18-164.el5 #1 SMP Thu Sep3 02:16:47 EDT 2009 i686 i686 i386 GNU/Linux
[root@oracle ~]# grep Huge /proc/meminfo
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 4096 kB
这里显示并没有使用hugepage
SYS@PROD>show parameter memory
NAME TYPE VALUE
----------------------------------------------- ------------------------------
hi_shared_memory_address integer 0
memory_max_target big integer 812M
memory_target big integer 812M
shared_memory_address integer 0
由于memory_target 有值说明我们使用的是AMM内存管理方式
我们分配预配备给SGA=800M PGA=200M
要对/etc/security/limits.conf添加两行
(以KB计算=预分配内存*1024)
oracle hard memlock 819200
oracle soft memlock 819200
切换ORACLE用户验证是否生效
[oracle@oracle~]$ ulimit -l
819200
使用官方脚本计算hugepage 设置的值
[oracle@oracle~]$ vi hugepages_settings.sh(结尾有脚本)
[oracle@oracle~]$ sh hugepages_settings.sh
hugepages_settings.sh:line 1: nges_settings.sh: command not found
Recommendedsetting: vm.nr_hugepages = 1
在出现为1值时考是否将oracle 从AMM管理方式切换到ASMM管理方式
SYS@PROD>createpfile='/home/oracle/init.ora' from spfile;
在这里面删除
memory_max_target
memory_target
设置
sga_max_size
sga_target
pga_aggregate_target
设置完成后关闭数据库
SYS@PROD>startuppfile='/home/oracle/init.ora'
正常启动后创建SPFILE文件
SYS@PROD>createspfile from memory
再次执行脚本
[oracle@oracle~]$ sh hugepages_settings.sh
hugepages_settings.sh:line 1: nges_settings.sh: command not found
Recommendedsetting: vm.nr_hugepages = 180
[root@oracle~]# sysctl -w vm.nr_hugepages=180 ====当前有效
vm.nr_hugepages= 180
还是要修改
[root@oracle~]# vi /etc/sysctl.conf
在最后一行添加
vm.nr_hugepages=180
[root@oracle~]# grep Huge /proc/meminfo
HugePages_Total: 180
HugePages_Free: 180
HugePages_Rsvd: 0
Hugepagesize: 4096 kB
当HugePages_Free和HugePages_Total 相等时是没有生效的
需要重启实例
之后再查看
[oracle@oracle~]$ grep Huge /proc/meminfo
HugePages_Total: 180
HugePages_Free: 5
HugePages_Rsvd: 1
Hugepagesize: 4096 kB
值得注意的是 我们SGA没有设置好是会导致即使设置了hugepage还是无法使用
SGA要设置好
sga_max_size
sga_target
最好相等
点击(此处)折叠或打开
- #!/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 shared memory segment or not.
- # Check for the kernel version
- KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
- # Find out the HugePage size
- HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
- # Start from 1 pages to be on the safe side and guarantee 1 free HugePage
- NUM_PG=1
- # Cumulative number of pages required to handle the running shared memory segments
- for 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`
- fi
- done
- # Finish with results
- case $KERN in
- '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
- echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
- '2.6'|'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
- *) echo "Unrecognized kernel version $KERN. Exiting." ;;
- esac
- # End
参考ORACLE官方配置文档:https://docs.oracle.com/database/121/UNXAR/appi_vlm.htm#UNXAR391