We will introduce how to record JFR (Java Flight Recorder) and output a dump file. Here, the state of ** Eclipse GlassFish 5.1.0 ** is recorded.
[glassfish@CENTOS7 ~]$ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[glassfish@CENTOS7 ~]$
[glassfish@CENTOS7 ~]$ java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
[glassfish@CENTOS7 ~]$
[glassfish@CENTOS7 ~]$ /opt/glassfish5/glassfish/bin/asadmin version
Version string could not be obtained from Server [localhost:4848].
(Turn debugging on e.g. by setting AS_DEBUG=true in your environment, to see the details.)
Using locally retrieved version string from version class.
Version = GlassFish Server Open Source Edition 5.1.0 (build default-private)
Command version executed successfully.
[glassfish@CENTOS7 ~]$
For ** GlassFish 5.1.0 ** installation, see the previous post How to install Eclipse GlassFish 5.1.0 on CentOS 7. Please give me.
Add the following to the JVM options when starting Glassfish.
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
-XX:FlightRecorderOptions=<..>
Specifically, "domain / configs / java-config" of domain.xml
under" / opt / glassfish5 / glassfish / domains / domain1 / config
" (java-config tag in the configs tag in the domain tag) Add the following 3 lines to (inside).
/opt/glassfish5/glassfish/domains/domain1/config/domain.Add to xml
<jvm-options>-XX:+UnlockCommercialFeatures</jvm-options>
<jvm-options>-XX:+FlightRecorder</jvm-options>
<jvm-options>-XX:FlightRecorderOptions=defaultrecording=true,disk=true,repository=/var/log/jvm/repositories,maxsize=2048m,maxage=25h,dumponexit=true,dumponexitpath=/var/log/jvm/dump.jfr</jvm-options>
Here, / var / log / jvm
is used as the temporary directory, so create a jvm
directory under / var / log
, and the glassfish user can create files and files under / var / log / jvm
. Make sure you can create the directory.
Execution result
[glassfish@CENTOS7 ~]$ su
password:
[root@CENTOS7 glassfish]# cd /var/log
[root@CENTOS7 log]#
[root@CENTOS7 log]# mkdir jvm
[root@CENTOS7 log]# chown glassfish:glassfish jvm
[root@CENTOS7 log]# exit
exit
[glassfish@CENTOS7 ~]$
Start Glassfish with the following command.
/opt/glassfish5/glassfish/bin/asadmin start-domain domain1
Execution result
[glassfish@CENTOS7 config]$ /opt/glassfish5/glassfish/bin/asadmin start-domain domain1
Waiting for domain1 to start ......
Successfully started the domain : domain1
domain Location: /opt/glassfish5/glassfish/domains/domain1
Log File: /opt/glassfish5/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
[glassfish@CENTOS7 config]$
First, check the process ID of glassfish with the following command.
ps -ef | grep glassfish | grep -v grep
Execution result
[glassfish@CENTOS7 config]$ ps -ef | grep glassfish | grep -v grep
glassfi+ 26302 1 5 19:54 pts/0 00:00:16 /usr/java/jdk1.8.0_241-amd64/bin/java -cp /opt/glassfish5/glassfish/modules/glassfish.jar -XX:+UnlockCommercialFeatures -XX:+UnlockDiagnosticVMOptions -XX:NewRatio=2 -XX:FlightRecorderOptions=defaultrecording=true,disk=true,repository=/var/log/jvm/repositories,maxsize=2048m,maxage=25h,dumponexit=true,dumponexitpath=/var/log/jvm/dump.jfr -XX:+FlightRecorder -XX:MaxPermSize=192m -Xmx512m -javaagent:/opt/glassfish5/glassfish/lib/monitor/flashlight-agent.jar -client -Djavax.xml.accessExternalSchema=all -Djavax.net.ssl.trustStore=/opt/glassfish5/glassfish/domains/domain1/config/cacerts.jks -Djdk.tls.rejectClientInitiatedRenegotiation=true -Djdk.corba.allowOutputStreamSubclass=true -Dfelix.fileinstall.dir=/opt/glassfish5/glassfish/modules/autostart/ -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall -Dcom.sun.aas.installRoot=/opt/glassfish5/glassfish -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/opt/glassfish5/glassfish/modules/endorsed:/opt/glassfish5/glassfish/lib/endorsed -Djava.security.policy=/opt/glassfish5/glassfish/domains/domain1/config/server.policy -Dosgi.shell.telnet.maxconn=1 -Dfelix.fileinstall.bundles.startTransient=true -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Dfelix.fileinstall.log.level=2 -Djavax.net.ssl.keyStore=/opt/glassfish5/glassfish/domains/domain1/config/keystore.jks -Djava.security.auth.login.config=/opt/glassfish5/glassfish/domains/domain1/config/login.conf -Dfelix.fileinstall.disableConfigSave=false -Dfelix.fileinstall.bundles.new.start=true -Dcom.sun.aas.instanceRoot=/opt/glassfish5/glassfish/domains/domain1 -Dosgi.shell.telnet.port=6666 -Dgosh.args=--nointeractive -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Dosgi.shell.telnet.ip=127.0.0.1 -DANTLR_USE_DIRECT_CLASS_LOADING=true -Djava.awt.headless=true -Dcom.ctc.wstx.returnNullForDefaultNamespace=true -Djava.ext.dirs=/usr/java/jdk1.8.0_241-amd64/lib/ext:/usr/java/jdk1.8.0_241-amd64/jre/lib/ext:/opt/glassfish5/glassfish/domains/domain1/lib/ext -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Djava.library.path=/opt/glassfish5/glassfish/lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib com.sun.enterprise.glassfish.bootstrap.ASMain -upgrade false -domaindir /opt/glassfish5/glassfish/domains/domain1 -read-stdin true -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--watchdog=false,,,--debug=false,,,--domaindir,,,/opt/glassfish5/glassfish/domains,,,domain1 -domainname domain1 -instancename server -type DAS -verbose false -asadmin-classpath /opt/glassfish5/glassfish/lib/client/appserver-cli.jar -debug false -asadmin-classname com.sun.enterprise.admin.cli.AdminMain
[glassfish@CENTOS7 config]$
You can see that the process ID is 26302
.
Output the JFR (Java Flight Recorder) record to a dump file with the following command.
jcmd <process ID> JFR.dump recording = 0 filename = <path of output dump file>
Execution result
[glassfish@CENTOS7 ~]$ jcmd 26302 JFR.dump recording=0 filename=/home/glassfish/perf/test_$(date "+%Y%m%d_%H%M%S").jfr
26302:
Dumped recording 0, 2.5 MB written to:
/home/glassfish/perf/test_20200726_200546.jfr
[glassfish@CENTOS7 ~]$
Check the output dump file.
Execution result
[glassfish@CENTOS7 ~]$ cd /home/glassfish/perf
[glassfish@CENTOS7 perf]$ ls -l
2600 in total
-rw-rw-r--.1 glassfish glassfish 2660207 July 26 20:05 test_20200726_200546.jfr
[glassfish@CENTOS7 perf]$
Transfer the output jfr dump file (test_20200726_200546.jfr) to the Windows PC on which jdk1.8 is installed.
Start "jmc.exe" (Java Mission Contorol) under " C: \ Program Files \ Java \ jdk1.8.0_231 \ bin
".
Open the jfr dump file (test_20200726_200546.jfr) output by selecting "File"-"Open File" from the menu.
You can refer to the jfr dump file output by "jmc.exe" (Java Mission Contorol).
Recommended Posts