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

老规矩,知道写了些啥。

相关推荐
Database_Cool_1 小时前
云原生多租户隔离 + 近实时分析怎么选型?阿里云 AnalyticDB MySQL 资源隔离方案
数据库·mysql·阿里云
小马爱打代码7 小时前
Redis 集群方案详解:主从复制、哨兵、脑裂、分片集群和哈希槽
数据库·redis·哈希算法
海南java第二人9 小时前
ClickHouse 稀疏索引深度解析:为什么 OLAP 数据库不用 B-Tree?
数据库·clickhouse
Litluecat9 小时前
信创迁移:Oracle切换海量数据库,慢sql扫描
数据库·sql·oracle·信创·海量
消失在人海中9 小时前
Oracle的CURRENT REDO丢失,数据丢失风险分析
数据库·oracle
喵了几个咪9 小时前
选择第三方IAM还是自建权限体系?中小型后台系统权限架构决策指南
数据库·oracle·架构
Elastic 中国社区官方博客10 小时前
Kibana:使用 AI Chat 及 MCP 轻松创建 AI 原生仪表板
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·信息可视化
杨云龙UP11 小时前
Oracle Health Check巡检脚本使用SOP V2.0:从HTML原始报告→生成Word专业巡检报告→交付客户_2026-06-03
linux·运维·数据库·sql·oracle·报告·巡检
Database_Cool_11 小时前
Hudi 湖仓一体架构:阿里云 AnalyticDB MySQL 原生集成最佳实践
数据库·mysql·阿里云