在 CentOS 下优化 WebLogic,通常从 操作系统层、JVM 层、WebLogic 配置层、应用层 四个方面入手。下面给你一套比较实用、可落地的优化思路(以生产环境常见场景为例)。
# 文件句柄
fs.file-max = 655360
# TCP 连接
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 600
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
# 内存
vm.swappiness = 10
执行:
sysctl -p
weblogic soft nofile 65535
weblogic hard nofile 65535
weblogic soft nproc 65535
weblogic hard nproc 65535
systemctl disable firewalld
systemctl stop firewalld
(如安全要求用 iptables 或安全组)
USER_MEM_ARGS="-Xms4g -Xmx4g -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m"
原则:
JDK 8:
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:/opt/logs/gc.log
JDK 11:
-XX:+UseG1GC
-Xlog:gc*:file=/opt/logs/gc.log:time
Initial Capacity = 10
Max Capacity = 50~100
Min Capacity = 10
Statement Cache Size = 50
Test Connections On Reserve = true
/opt/weblogic/user_projects/domains/base_domain/bin/setDomainEnv.sh
确保:
-Dweblogic.nio.EnableDirectByteBuffer=true
Admin Console → Server → Protocols → HTTP
Enable GZIP = true
| 现象 | 可能原因 |
|---|---|
| CPU 高 | GC 频繁 / 死循环 |
| 内存涨 | 内存泄漏 |
| 响应慢 | 连接池不足 |
| TPS 低 | 线程阻塞 |
-Xms8g -Xmx8g
-XX:+UseG1GC
JDBC Max=80
Nginx + WebLogic
GC 日志开启
如果你能提供:
我可以给你 更精准的调优参数。