在 CentOS 环境下对 WebLogic Server 进行调优,通常从 操作系统、JVM、WebLogic 自身、应用、数据库 五个层面入手。下面给你一套比较系统、实战可用的调优思路(适用于 WebLogic 10g/11g/12c,CentOS 6/7/8 通用)。
WebLogic 会大量使用 socket 和文件句柄。
# 查看当前限制
ulimit -n
# 临时修改
ulimit -n 65535
# 永久修改
vi /etc/security/limits.conf
添加:
* soft nofile 65535
* hard nofile 65535
编辑:
vi /etc/sysctl.conf
推荐配置:
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.core.somaxconn = 4096
net.ipv4.ip_local_port_range = 1024 65535
vm.swappiness = 10
生效:
sysctl -p
systemctl disable firewalld
systemctl disable selinux
(生产环境按安全策略调整)
-Xms4g
-Xmx4g
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+DisableExplicitGC
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/logs/heapdump.hprof
-Xms4g
-Xmx4g
-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+HeapDumpOnOutOfMemoryError
编辑:
$DOMAIN_HOME/bin/setDomainEnv.sh
示例:
USER_MEM_ARGS="-Xms4g -Xmx4g -XX:+UseG1GC"
export USER_MEM_ARGS
使用 Work Manager(推荐)
Environment → Work Managers
示例:
| 参数 | 建议 |
|---|---|
| Initial Capacity | 10 |
| Max Capacity | 50~200 |
| Min Capacity | 10 |
| Statement Cache Size | 50 |
| Test Connections On Reserve | 勾选 |
| Test Table | dual / SQL |
示例:
Initial Capacity: 20
Max Capacity: 100
Console → Servers → Configuration → Tuning
建议:
Accept Backlog = 1024
Console → Servers → Configuration → Tuning
✅ 勾选 Use Native IO
Console → Web Applications
建议:
Session Timeout = 30 分钟
WebLogic 中:
Inactive Connection Timeout = 300
jstat -gc pidjstack pidjmap -histo pid-XX:+HeapDumpOnOutOfMemoryError
✅ 内存:Xms = Xmx
✅ GC:JDK8 用 G1
✅ 线程池:不要无限放大
✅ 连接池:根据并发设置
✅ OS:文件句柄 + TCP 参数
✅ 监控:GC + 线程 + 连接池
如果你愿意,可以告诉我:
我可以给你一套 针对你环境的精确调优参数。