在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
等命令驗證配置效果,確保資源限制合理且服務正常運行。注意:設置需結合服務器資源,避免過度限制導致服務異常,生產環境建議提前測試。