在CentOS上限制WebLogic资源使用,可从以下方面操作:
$DOMAIN_HOME/bin/setDomainEnv.sh,设置内存参数(单位:字节):export MEM_ARGS="-Xms512m -Xmx1024m" # 初始堆和最大堆(Java 8及之前需设置MaxPermSize,之后由元空间自动管理)
/etc/security/limits.conf,为WebLogic用户设置进程和文件句柄限制:weblogic soft nproc 2048 # 最大进程数(软限制)
weblogic hard nproc 4096 # 最大进程数(硬限制)
weblogic soft nofile 65536 # 最大打开文件数(软限制)
weblogic hard nofile 65536 # 最大打开文件数(硬限制)
sudo sysctl -w fs.file-max=6815744
/etc/sysctl.conf,添加fs.file-max=6815744,执行sudo sysctl -p生效。config.xml配置线程池参数(如最小/最大线程数):<thread-pool-params>
<min-threads-constraint>
<name>MyThreadPool</name>
<min-threads>10</min-threads>
</min-threads-constraint>
<max-threads-constraint>
<name>MyThreadPool</name>
<max-threads>100</max-threads>
</max-threads-constraint>
</thread-pool-params>
top、ulimit、lsof等命令验证配置效果,确保资源限制合理且服务正常运行。注意:设置需结合服务器资源,避免过度限制导致服务异常,生产环境建议提前测试。