在 Linux 上优化 Oracle 数据库配置,通常从操作系统层、内核参数、文件系统、Oracle 实例参数、资源限制、存储与网络几个方面入手。下面给你一套比较系统、可落地的优化思路(以 Oracle 11g/12c/19c 常见场景为例)。
减少系统开销:
systemctl disable firewalld
systemctl disable chronyd # 如不使用
(生产环境防火墙建议用 iptables 白名单,不要直接关)
/etc/sysctl.conf 示例(常见优化)# 内存与共享内存
kernel.shmmax = 68719476736 # 64GB,建议 ≥ SGA
kernel.shmall = 16777216 # shmmax / page_size
kernel.shmmni = 4096
# 信号量
kernel.sem = 250 32000 100 128
# 文件句柄
fs.file-max = 6815744
# 网络
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 65536 4194304
# 交换行为
vm.swappiness = 10
vm.dirty_ratio = 10
vm.dirty_background_ratio = 5
生效:
sysctl -p
编辑 /etc/security/limits.conf:
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft memlock unlimited
oracle hard memlock unlimited
确保使用 pam_limits.so
挂载参数示例:
/dev/sdb1 /u01 xfs defaults,noatime,nodiratime 0 0
Oracle 默认使用:
DISK_ASYNCH_IO = TRUE
SGA_TARGET = 40G
PGA_AGGREGATE_TARGET = 8G
MEMORY_TARGET = 0 -- 不建议使用自动内存
原则:
PROCESSES = 2000
SESSIONS = 2200
DB_CACHE_SIZE
SHARED_POOL_SIZE
LOG_BUFFER = 64M
OPEN_CURSORS = 1000
numactl --interleave=all
或 GRUB 中:
numa=off
使用 taskset 绑定 Oracle 进程
top / htopiostat -x 1vmstat 1sarsqlplus + AWR 报告@?/rdbms/admin/awrrpt.sql
如果你能告诉我:
我可以给你一套更精确的配置模板。