当前位置:文档之家› weblogic学习笔记

weblogic学习笔记

#weblogic节点管理器,集中管理所有weblogic服务器

# 安装jprofiler问题,检查类库
ldd /cpic/sxbqsl/jprofiler/jprofiler6/bin/linux-x64/libjprofilerti.so

#检查服务器可用jvm内存
java -Xmx3290m -version

#weblogic部署标准
weblogic部署平台linux as5u2 64bit os

#得到Linux位数的方法
getconf LONG_BIT


#jvm内存调优经验总结

先从解决bug开始,当Java程序申请内存,超出VM可分配内纯的时候,VM首先可能会GC,如果GC完还是不够,或者申请的直接超够VM可能有的,就会抛出内 存溢出异常。从VM规范中我们可以得到,一下几种异常。

https://www.doczj.com/doc/bd13227578.html,ng.StackOverflowError:(很少)
https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError:heap space(比较常见)
https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError: PermGen space (经常出现)

https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError: GC overhead limit exceeded(某项操作使用大量内存时发生)

以下分别解释一下,从最常见的开始:

https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError: PermGen space 这个异常比较常见,是说JVM里的Perm内 存区的异常溢出,由于JVM在默认的情况下,Perm默认为64M,而很多程序需要大量的Perm区内 存,尤其使用到像Spring等框架的时候,由于需要使用到动态生成类,而这些类不能被GC自动释放,所以导致OutOfMemoryError: PermGen space异常。解决方法很简单,增大JVM的 -XX:MaxPermSize 启动参数,就可以解决这个问题,如过使用的是默认变量通常是64M[5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.],改成128M就可以了,-XX:MaxPermSize=128m。如果已经是128m(Eclipse已经是128m了),就改成 256m。我一般在服务器上为安全起见,改成256m。

https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError:heap space或其它OutOfMemoryError,这个异常实际上跟上面的异常是一个异常,但解决方法不同,所以分开来写。上面那个异常是因为JVM的perm区内 存区分少了引起的(JVM的内 存区分为 young,old,perm三种)。而这个异常是因为JVM堆内 存或者说总体分少了。解决方法是更改 -Xms -Xmx 启动参数,通常是扩大1倍。xms是管理启动时最小内 存量的,xmx是管里JVM最大的内 存量的。
注:OutOfMemoryError可能有很多种原因,根据JVM Specification, 可能有一下几种情况,我先简单列出。stack:stack分区不能动态扩展,或不足以生成新的线程。Heap:需要更多的内 存,而不能获得。Method Area :如果不能满足分配需求。runtime constant pool(从Method Area分配内 存)不足以创建class or interface。native method stacks不能够动态扩展,或生成新的本地线程。

https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError: GC overhead limit exceeded,这个是JDK6新添的错误类型。是发生在GC占用大量时间为释放很小空间的时候发生的,是一种保护机制。我在JSP导大Excel的时候碰到过。最终解决

方案是,关闭该功能,使用—— -XX:-UseGCOverheadLimit

最后说说https://www.doczj.com/doc/bd13227578.html,ng.StackOverflowError,老实说这个异常我也没碰见过,但JVM Specification就提一下,规范上说有一下几种境况可能抛出这个异常,一个是Stacks里的线程超过允许的时候,另一个是当native method要求更大的内 存,而超过native method允许的内 存的时候。根据SUN的文档,提高-XX:ThreadStackSize=512的值。

总的来说调优JVM的内 存,组要目的就是在使用内 存尽可能小的,使程序运行正常,不抛出内 纯溢出的bug。而且要调好最小内 存,最大内 存的比,避免GC时浪费太多时间,尤其是要尽量避免FULL GC。

补充:由于JDK1.4新增了nio,而nio的buffer分配内存比较特殊(读写流可以共享内存)。如果有大量数据交互,也可能导致https://www.doczj.com/doc/bd13227578.html,ng.OutOfMemoryError。相应的JDK新增了一个特殊的参数:-XX:MaxDirectMemorySize 默认是64M,可以改大些如128M。

-XX:MaxDirectMemorySize=
Specifies the maximum amount of memory in bytes that the Java? NIO library can allocate for direct memory buffers. The default is 64 megabytes, which corresponds to
-XX:MaxDirectMemorySize=64m . The use of direct memory buffers can minimize the copying cost when doing I/O operations


#weblogic自启动脚本
nohupstart WEBLOGIC
cd /cpic/sxam
. ./.bash_profile
XPID=`netstat -nlp|grep 7001|awk '{print $7;}'`
SPID=${XPID%/*}
kill -9 $SPID
cd /cpic/sxam/cron
sh /cpic/sxam/cron/startWBL.sh

DATE=`date "+%Y%m%d%H%M"`
NOHUP_LOG="/applog/sxamlog/nohupAdminServ${DATE}"
nohup /cpic/sxam/user_projects/domains/channel/bin/startWebLogic.sh 1> ${NOHUP_LOG} 2>&1 &


#weblogic自动清理脚本
daily_clear
for file in `find /applog/sxamlog/nohup* -type f -mtime +7 `
do
if [ -f $file ]
then
dir=${file%/*}
if [ $dir = "/applog/sxamlog" ]
then
rm -f $file
fi
fi
done

#weblogic自动更新脚本
#!/bin/sh
cd /cpic/sxam

psid=`ps -ef|grep java |grep sxam| grep -v "grep"|awk '{print $2}'`
kill -9 $psid

rm -rf /cpic/sxam/user_projects/domains/channel/servers/AdminServer/tmp/AdminServer.lok
rm -rf /cpic/sxam/user_projects/domains/channel/servers/AdminServer/tmp/WebServiceUtils.ser
rm -rr /cpic/sxam/user_projects/domains/channel/servers/AdminServer/tmp/_WL_user/*

back_date=`date +'%Y%m%d'`
cd /cpic/sxam/user_projects/domains/channel/servers/AdminServer/upload
mv channel.ear channel.ear.$back_date
ftp -i -n << !
open 10.1.34.187
user fabu2 11111
cd 更新
cd $back_date/系统程序/ear
bin
get channel.ear
bye
!
cd /cpic/sxam/user_projects/domains/channel/bin
nohup ./startWebLogic.sh &
tail -f nohup.out






相关主题
文本预览
相关文档 最新文档