数据库管理143期 2024-02-08
- [数据库管理-第143期 Oracle DB 19c需要调整的基本参数V2(20240202)](#数据库管理-第143期 Oracle DB 19c需要调整的基本参数V2(20240202))
-
- [1 DRM](#1 DRM)
- [2 readmostly objects](#2 readmostly objects)
- [3 内存大页](#3 内存大页)
- [4 CLUSTER_INTERCONNECTS](#4 CLUSTER_INTERCONNECTS)
- [5 db_files](#5 db_files)
- [6 内存配置](#6 内存配置)
- [7 555.1](#7 555.1)
- 总结
数据库管理-第143期 Oracle DB 19c需要调整的基本参数V2(20240202)
作者:胖头鱼的鱼缸(尹海文)
Oracle ACE Associate: Database(Oracle与MySQL)
网思科技 DBA总监
10年数据库行业经验,现主要从事数据库服务工作
拥有OCM 11g/12c/19c、MySQL 8.0 OCP、Exadata、CDP等认证
墨天轮MVP、认证技术专家,ITPUB认证专家,OCM讲师
圈内拥有"总监"、"保安"、"国产数据库最大敌人"等称号,非著名社恐(社交恐怖分子)
公众号:胖头鱼的鱼缸;CSDN:胖头鱼的鱼缸(尹海文);墨天轮:胖头鱼的鱼缸;ITPUB:yhw1809。
除授权转载并标明出处外,均为"非法"抄袭。
2020年9月14日写过一篇《Oracle数据库管理每周一例-第十四期 19c需要调整的参数及操作》(https://blog.csdn.net/yhw1809/article/details/108571904),但是时过境迁,而且当时也是为了处理一些19c前期版本BUG和在Exadata上进行的调整,这里针对19c较新补丁(≥19.20)的数据库参数或操作进行一个总结。本文不包含针对特定BUG和功能性调整的参数变更。
1 DRM
DRM仍然是RAC环境运行的主要不稳定因素之一,简介《Oracle数据库管理每周一例-第十一期 DRM》(https://blog.csdn.net/yhw1809/article/details/108195827),这里仍然建议关闭DRM:
sql
alter system set "_lm_drm_disable"=4/5 scope=both sid='*';
无需重启实例
or
alter system set "_lm_drm_disable"=7 scope=both sid='*';
需要重启集群
2 readmostly objects
该参数依然可能造成GC相关异常:
sql
alter system set "_gc_persistent_read_mostly"=false scope=spfile sid='*';
alter system set "_gc_read_mostly_locking"=false scope=spfile sid='*';
需要重启集群
3 内存大页
Oracle数据库建议开启内存大页:
shell
hugepages_settings.sh
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
# on Oracle Linux
#
# 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.
#
# This script is provided by Doc ID 401749.1 from My Oracle Support
# http://support.oracle.com
# Welcome text
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating the overall size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And make sure that:
* 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 -m
Press Enter to proceed..."
read
# 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}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | 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
RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`
# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
echo "***********"
echo "** ERROR **"
echo "***********"
echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:
# ipcs -m
of 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 1
fi
# 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') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
# End
chmod +x hugepages_settings.sh
./hugepages_settings.sh
---> Recommended setting: vm.nr_hugepages = XXXX
将上面脚本生成内容写入到/etc/sysctl.conf中,通过下面命令生效
sysctl -p
sql
alter system set use_large_pages='ONLY' scope=spfile sid='*';
需要重启实例
4 CLUSTER_INTERCONNECTS
Oracle RAC建议在数据库配置CLUSTER_INTERCONNECTS相关参数以提升私网连接指向性与性能:
sql
alter system set CLUSTER_INTERCONNECTS='192.nnn.nnn.X1:192.nnn.nnn.X2' sid='<instanceName>' scope=spfile;
按实例配置不同节点私网IP信息,需要重启集群
5 db_files
Oracle默认db_files大小往往不能满足实际生产需求:
sql
alter system set db_files=10240 scope=spfile sid='*';
需要重启集群
6 内存配置
不要在PDB级别配置SHARED_POOL_SIZE, SGA_MIN_SIZE, DB_CACHE_SIZE,容易出现ORA-04031的问题切Shared pool无法释放。详见《数据库管理-第八十三期 炒点冷饭(20230620)》(https://blog.csdn.net/yhw1809/article/details/131305269)。如果因为业务程序造成Shared pool过大挤占db_cache大小,可以在CDB级别配置shared_pool_size和db_cache_size,让PDB去自动争用。
7 555.1
Oracle Database 19c Important Recommended One-off Patches (Doc ID 555.1),这个DOC中包含了19c最近4个版本的重要One-off补丁。还是需要注意一点,Oracle数据库上,不是每一个BUG都会被触发,而且大多数BUG有Workaround。如不是特定情况不建议使用One-off补丁,现在可以使用季度补丁上的月度MRP解决大部分问题。
总结
算是一篇划水,重新整理了下Oracle DB 19c(≥19.20)需要调整的基本参数。
老规矩,知道写了些啥。