在 CentOS 上优化 WebLogic Server(WLS) 性能,通常从 操作系统、JVM、WebLogic 参数、应用架构 四个层面入手。下面给你一套 实战型优化清单,适用于生产环境常见场景。
编辑 /etc/sysctl.conf:
# 网络连接优化
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# TCP 连接复用
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
# 文件句柄
fs.file-max = 1000000
生效:
sysctl -p
编辑 /etc/security/limits.conf:
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
WebLogic 用户(如 weblogic)必须重新登录生效。
减少系统资源占用:
systemctl disable firewalld
systemctl disable postfix
(生产环境防火墙建议用硬件或 iptables)
-Xms4g
-Xmx4g
✅ 建议 Xms = Xmx,避免动态扩容
JDK 8(推荐):
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
JDK 11+:
-XX:+UseG1GC
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=512m
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/data/logs/heapdump
-Xloggc:/data/logs/gc.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
在 setDomainEnv.sh 中修改:
export USER_MEM_ARGS="-Xms4g -Xmx4g -XX:+UseG1GC"
Console 路径:
Environment → Servers → your_server → Configuration → Threads
推荐:
Console:
Services → Data Sources → your_ds → Connection Pool
推荐配置:
SQL SELECT 1WebLogic 9+ 已废弃,使用 Work Manager 替代。
确保使用 Linux Native IO:
$WL_HOME/server/native/linux/x86_64
WebLogic 自动启用,日志中确认:
Using native I/O
在 weblogic.xml:
<gzip-compression>true</gzip-compression>
生产环境:
INFO 或 WARNING
避免:
DEBUG
| 项目 | 配置 |
|---|---|
| 内存 | 8G 服务器:Xms4g Xmx4g |
| GC | G1GC |
| CPU | 8 核 |
| 线程池 | 200 |
| JDBC | 100 |
| OS | CentOS 7/8 |
| 反向代理 | Nginx |
# CPU 高
top -H -p <pid>
# 内存
jmap -heap <pid>
# GC
jstat -gc <pid> 1000
# 线程
jstack <pid> > thread.txt
CentOS + WebLogic 性能优化的核心是:JVM 参数 + 线程池 + 连接池 + 操作系统限制 + 架构拆分。
如果你愿意,可以告诉我:
我可以给你一套 完全定制化的参数配置。