在 CentOS 下对 IBM Informix 进行优化,通常从 操作系统层、数据库实例参数、SQL 与索引、存储与 I/O、监控与维护 几个方面入手。下面给你一套比较实用的优化思路(以 CentOS 7/8 + Informix 11/12/14 为例)。
编辑 /etc/sysctl.conf:
# 共享内存
kernel.shmmax = 68719476736
kernel.shmall = 16777216
# 信号量
kernel.sem = 250 32000 100 128
# 文件句柄
fs.file-max = 655360
# 网络
net.core.somaxconn = 1024
net.ipv4.tcp_tw_reuse = 1
执行:
sysctl -p
/etc/security/limits.conf
informix soft nofile 65536
informix hard nofile 65536
informix soft nproc 16384
informix hard nproc 16384
systemctl stop firewalld
systemctl disable firewalld
(生产环境可用 iptables 精细控制)
/dev/sdb /informix xfs noatime,nodiratime 0 0
BUFFERS 100000 # 数据缓冲区(重要)
LOGBUFF 1024
PHYSBUFF 1024
RESIDENT 1 # 常驻内存
SHMVIRTSIZE 32768
SHMADD 8192
BUFFERS 一般设为物理内存的 20%~40%
NUMCPUVPS 8
MULTIPROCESSOR 1
VPCLASS cpu,num=8
VPCLASS aio,num=4
RA_PAGES 64
RA_THRESHOLD 32
CKPTINTVL 300
oncheck -pe
oncheck -cI database:table
update statistics for table customer;
update statistics high for table orders;
SET EXPLAIN ON;
查看执行计划:
cat sqexplain.out
LOGFILES 20
LOGSIZE 10000
LTXHWM 70
LTXEHWM 80
onstat -g ses # 会话
onstat -g sql # SQL
onstat -p # 性能
onstat -g ioq # I/O
onstat -g ntt # 网络
oncheckupdate statistics如果你能告诉我:
我可以给你 更针对性的 onconfig 参数和 SQL 示例。