数据库管理-第143期 Oracle DB 19c需要调整的基本参数V2(20240202)

数据库管理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)需要调整的基本参数。

老规矩,知道写了些啥。

相关推荐
数智启示录1 分钟前
Flink CDC 机制精讲(四):一条 SQLServer CDC 事件如何保持顺序 【面试宝典】
数据库·面试·sqlserver·flink
张文君18 分钟前
ubuntu26.04从ext4到raid1+lvm启动-最终版-有这个方法系统损坏还焦虑个啥
数据库
今天AI了吗19 分钟前
AI工作流的自动化趋势:从手动实验到自主Agent的研究范式转变
运维·数据库·人工智能·sql·机器学习·自动化·github
Wang's Blog33 分钟前
Vibe Coding一人即团队系列28: 前端、后端与数据库的概念解析
前端·数据库
安全指北针34 分钟前
IDC《中国数据安全技术发展路线图,2025》:数据安全管理平台推荐厂商
大数据·数据库·人工智能
瀚高PG实验室36 分钟前
PostgreSQL CREATE TYPE 未检查 multirange schema 的 CREATE 权限HGVE-2026-E007
数据库·postgresql·瀚高数据库
xfan_me40 分钟前
手机在网状态接口-空号查询-空号过滤API
数据库·人工智能·python·智能手机
会博通·代码搬运工1 小时前
双层PDF技术实现与档案数字化系统的API集成实践
数据库·人工智能·分布式·python·计算机视觉·api集成
Sagittarius_A*1 小时前
【好靶场】报错注入-sql注入-字符型
数据库·sql·web安全·网络安全·sql注入
HwJack201 小时前
鸿蒙ArkData键值型数据库实战:Schema 定义与商品库存同步案例
数据库·华为·harmonyos