docker tomcat jvm 使用 visualVM监控
生活随笔
收集整理的這篇文章主要介紹了
docker tomcat jvm 使用 visualVM监控
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.? 建立基礎鏡像
FROM centosMAINTAINER fengjian <fengjian@senyint.com> ENV TZ "Asia/Shanghai" ENV TERM xtermENV JAVA_HOME /data/jdk ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /data/tomcat ENV CATALINA_BASE /data/tomcat ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/binRUN rm /etc/yum.repos.d/* -rf ADD Centos-7.repo /etc/yum.repos.d/ ADD epel.repo /etc/yum.repos.d/ RUN yum clean all RUN yum -y install unzip net-tools bind-utils sysstat kde-l10n-Chinese telnet reinstall glibc-commonRUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 ENV LC_ALL "zh_CN.UTF-8" ADD localtime /etc/ ADD jdk.tar.gz /data ADD tomcat.tar.gz /data ADD profile /etc ADD 20-nproc.conf /etc/security/limits.d/ ADD limits.conf /etc/security/ RUN mkdir -p /data/webserver RUN mkdir -p /data/logs?
2. tomcat/conf/catalina.sh 添加初始堆參數
JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -server -Xms4096M -Xmx4096M -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:-UseCounterDecay -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:MaxTenuringThreshold=6 -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=18999 -Dcom.sun.management.jmxremote.rmi.port=18999 -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.200.10"**其中?Djava.rmi.server.hostname= 192.168.200.10 為宿主機的IP地址。
?
3. 加入應用
FROM 192.168.200.10/source/tomcat8_jdk1.8_testMAINTAINER fengjian <fengjian@senyint.com.com>ADD webserver.tar.gz /data/webserver/EXPOSE 80 18999CMD ["/data/tomcat/bin/catalina.sh","run"]?
?
4. 運行應用docker
docker run -d --name 1111 -p 50001:80 -p 18999:18999 192.168.200.10/source/gateway_test_jvm?
5. 使用visualVM監控
?
?
?
二,
?
2. tomcat/conf/catalina.sh 添加初始堆參數
JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -server -Xms4096M -Xmx4096M -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:-UseCounterDecay -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:MaxTenuringThreshold=6 -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=18999 -Dcom.sun.management.jmxremote.rmi.port=18999 -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=192.168.20.174"**其中?Djava.rmi.server.hostname= 192.168.20.174 為宿主機的IP地址。
?
部署在k8s中,使用nodePort 指定端口,端口與jmxremote.port 相同
apiVersion: apps/v1beta2 kind: Deployment metadata:name: gatewaynamespace: senyint spec:selector:matchLabels:app: gatewayreplicas: 1template:metadata:labels:app: gatewayspec:nodeName: node1 #指定部署到 node1 上 containers:- name: gatewayimage: 192.168.200.10/source/gateway_test_jvmresources:limits:cpu: 2memory: 8192Mirequests:cpu: 100mmemory: 512Miports:- name: webportcontainerPort: 80- name: jvmportcontainerPort: 31999--- apiVersion: v1 kind: Service metadata:name: gatewaynamespace: senyint spec:type: NodePortports:- name: webportport: 80targetPort: 80protocol: TCP- name: jvmportport: 31999targetPort: 31999protocol: TCPnodePort: 31999selector:app: gateway?
或者使用標簽
kubectl label nodes??node1? ? jvmmonitor=test
apiVersion: apps/v1beta2 kind: Deployment metadata:name: gatewaynamespace: senyint spec:selector:matchLabels:app: gatewayreplicas: 1template:metadata:labels:app: gatewayspec:nodeSelector:jvmmonitor: testcontainers:- name: gatewayimage: 192.168.200.10/source/gateway_test_jvmresources:limits:cpu: 2memory: 8192Mirequests:cpu: 100mmemory: 512Miports:- name: webportcontainerPort: 80- name: jvmportcontainerPort: 31999--- apiVersion: v1 kind: Service metadata:name: gatewaynamespace: senyint spec:type: NodePortports:- name: webportport: 80targetPort: 80protocol: TCP- name: jvmportport: 31999targetPort: 31999protocol: TCPnodePort: 31999selector:app: gateway?
?
?
轉載于:https://www.cnblogs.com/fengjian2016/p/9547790.html
總結
以上是生活随笔為你收集整理的docker tomcat jvm 使用 visualVM监控的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 87-区间线段树(板子)--那个苑区的人
- 下一篇: vue组件调用(用npm安装)