Skip to content

TProfiler配置部署

jlusdy edited this page Apr 17, 2012 · 8 revisions

配置

下载源码,在根目录运行package.bat脚本或者执行mvn assembly:assembly命令,将生成的包含依赖的jar包重命名为tprofiler.jar即可

profile.properties作为tprofiler.jar的配置文件,需要和Jar包放在相同的目录(/home/admin/tprofiler/),根据实际情况调整配置;如果不显式配置这个文件,将使用默认配置

其中

startProfTime = 9:00:00 开始profile的时间点

endProfTime = 11:00:00 结束profile的时间点

eachProfUseTime = 5 profile时间长度(单位秒)

eachProfIntervalTime = 50 两次profile的时间间隔(单位秒)

samplerIntervalTime = 10 两次采样的时间间隔(单位秒)

needNanoTime = false 是否需要用纳秒记录时间

ignoreGetSetMethod = true 是否忽略采集get/set方法

logFilePath = /home/admin/logs/tprofiler.log profile log的存放位置

methodFilePath = /home/admin/logs/tmethod.log method log的存放位置

samplerFilePath = /home/admin/logs/tsampler.log sampler log的存放位置

includePackageStartsWith = com.taobao 进行profile的类包名(分号分割)

excludePackageStartsWith = com.alibaba;com.taobao.forest.domain.dataobject 不进行profile的类包名(分号分割)

部署

tprofiler.jar放在固定目录,例如/home/admin/tprofiler/, profile.properties放在相同目录中

在 jvm 启动参数中添加-javaagent:/home/admin/tprofiler/tprofiler.jar (Jar包需要配置为绝对路径),然后重启应用

重启后就会在logFilePath设置的路径下出现log文件,共有3个:

  1. tsampler.log
  2. tprofiler.log
  3. tmethod.log

为了提升性能将method单独输出,此一项改进使log减小为原来的1/8

endProfTime时间到了后才会输出tmethod.log(因为在这个时间之前有些类和方法没有被load,所以选择profile结束后一次性输出method)

远程操作

远程查看状态操作:

java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient 10.232.*.* status

远程开始操作:

java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient 10.232.*.* start

远程关闭操作:

java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient 10.232.*.* stop

卸载

在 jvm 启动参数中去掉相关参数 -javaagent:/home/admin/tprofiler/tprofiler.jar, 重启应用即可卸载此工具

Clone this wiki locally