在 CentOS 环境下优化 WebLogic,通常可以从 操作系统层面、JVM 层面、WebLogic 自身配置、应用层面 四个维度来做。下面给你一套比较系统、可落地的优化思路(适用于生产环境)。
WebLogic 并发高时容易报 too many open files
# 查看
ulimit -n
# 修改(永久)
vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
vi /etc/sysctl.conf
建议参数:
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.ip_local_port_range = 1024 65535
vm.swappiness = 10
生效:
sysctl -p
systemctl disable firewalld
systemctl stop firewalld
(如业务需要,用 iptables 或安全组代替)
路径示例:
/u01/weblogic/user_projects/domains/base_domain/bin/setDomainEnv.sh
export MEM_ARGS="-Xms8g -Xmx8g -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m"
JDK 8:
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:/u01/weblogic/logs/gc.log
JDK 11:
-XX:+UseG1GC
-XX:+UseStringDeduplication
WebLogic 默认自调节线程池,一般不要写死
如果并发极高:
Administration Console
-> Servers -> Configuration -> Threads
-> 增加 Minimum Threads Constraint
Services -> Data Sources -> Connection Pool
建议:
Servers -> Configuration -> General
-> 勾选 "Enable Native IO"
Servers -> Protocols -> HTTP
-> 启用 KeepAlive
Timeout: 30s
推荐:
top
vmstat 1
iostat -x 1
netstat -an | grep 7001 | wc -l
jstat -gcutil <pid> 1000
| 项目 | 优化前 | 优化后 |
|---|---|---|
| TPS | 200 | 800+ |
| GC 停顿 | 1s+ | <200ms |
| 并发连接 | 1000 | 5000+ |
如果你能告诉我:
我可以给你一套 更精准的参数模板。