温馨提示×

debian怎么优化oracle

小樊
41
2026-10-02 12:40:59
栏目: 云计算

在 Debian 上“优化 Oracle”通常涉及系统层(OS)、内核参数、文件系统、Oracle 实例参数三个层面。下面给你一份实用向的 Debian + Oracle 优化清单(以 Oracle 19c 为例,11g/12c 思路类似)。


一、Debian 系统层优化

1. 关闭不必要的服务

systemctl disable bluetooth
systemctl disable cups
systemctl disable avahi-daemon

2. 使用性能模式(CPU)

apt install linux-tools-common
cpupower frequency-set -g performance

3. 禁用 SELinux / AppArmor(Oracle 不友好)

systemctl disable apparmor

二、内核参数优化(非常重要)

编辑 /etc/sysctl.conf:

# 内存相关
vm.swappiness = 10
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
vm.min_free_kbytes = 524288

# 网络
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 65536 4194304

# Oracle 共享内存
kernel.shmmax = 68719476736
kernel.shmall = 16777216
kernel.shmmni = 4096

# 信号量
kernel.sem = 250 32000 100 128

# 文件句柄
fs.file-max = 6815744

执行:

sysctl -p

三、用户与资源限制

编辑 /etc/security/limits.conf:

oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 32768
oracle hard stack 32768

确保:

/etc/pam.d/common-session

包含:

session required pam_limits.so

四、文件系统优化

推荐

  • ext4 / xfs
  • 挂载选项优化
UUID=xxxx /u01 ext4 defaults,noatime,nodiratime,discard 0 2

Oracle 数据盘建议:

mount -o noatime,nodiratime,barrier=0

五、Oracle 实例参数优化(关键)

1. 内存管理

ALTER SYSTEM SET memory_target=0 SCOPE=SPFILE;
ALTER SYSTEM SET sga_target=16G SCOPE=SPFILE;
ALTER SYSTEM SET pga_aggregate_target=4G SCOPE=SPFILE;

2. 进程与连接

ALTER SYSTEM SET processes=2000 SCOPE=SPFILE;
ALTER SYSTEM SET sessions=2200 SCOPE=SPFILE;

3. 日志与IO

ALTER SYSTEM SET db_writer_processes=4;
ALTER SYSTEM SET log_buffer=16M;

六、Oracle 专属优化

1. 使用 HugePages(强烈推荐)

cat /proc/meminfo | grep Huge

配置:

vm.nr_hugepages = 8192

Oracle 参数:

ALTER SYSTEM SET use_large_pages=TRUE;

2. 关闭不必要的组件

EXEC DBMS_AUTO_TASK_ADMIN.DISABLE;

七、监控与验证

top
iostat -x 1
vmstat 1
sqlplus / as sysdba
SELECT * FROM v$sysstat;

八、Debian 特别注意事项

  • Debian 不是 Oracle 官方支持系统
  • 建议:
    • 用 Oracle Linux / RHEL 生产环境
    • Debian 仅适合测试 / 开发

如果你能告诉我:

  • Oracle 版本(11g / 19c / 21c)
  • 用途(OLTP / 数仓 / 测试)
  • 内存 / CPU / 磁盘类型

我可以给你针对性更强的参数配置。

0 踩