0
点赞
收藏
分享

微信扫一扫

jprofiler监控docker部署的jvm服务

兮城 2022-04-14 阅读 81
java

1,官网下载jprofiler,此处我们选择jprofiler9.2.1版本:https://www.ej-technologies.com/download/jprofiler/version_92
在这里插入图片描述
Profiler 9.2 注册码
L-Larry_Lau@163.com#23874-hrwpdp1sh1wrn#0620
L-Larry_Lau@163.com#36573-fdkscp15axjj6#25257
L-Larry_Lau@163.com#5481-ucjn4a16rvd98#6038

2 安装windows版本

3 安装linux版本

docker exec -it 容器名 bash

cd /usr/local
tar -xvf jprofiler_linux_9_2_1.tar.gz
cd jprofiler9/

在这里插入图片描述
4 开启映射端口
宿主机执行脚本(脚本执行有任何问题可以私信我)

sh mapping_port.sh 容器名:8849:8849

#!/bin/bash

##该脚本用于设置容器端口映射到宿主机端口的功能

basepath=$(cd `dirname $0`; pwd)

if [ $# -ne 2 ]
then
  echo "ERROR:格式不正确,应该为: containerName:port fatherIp:port "
  echo -e "例如:将容器 1.node3的端口3306映射到宿主机192.168.30.210上的13306端口,那么命令如下:\n
  $0 1.node3:3306 192.168.30.210:13306"
  exit 1
fi

containerName=`echo $1 | cut -d \: -f 1`
containPort=`echo $1 | cut -d \: -f 2`
fatherIp=`echo $2 | cut -d \: -f 1`
fatherPort=`echo $2 | cut -d \: -f 2`

#根据容器名称获取容器ip地址
containerIp=`docker exec -ti ${containerName} ifconfig eth1 | grep "inet addr:" | awk -F " " '{print $2}' | awk -F ":" '{print $2}'`

iptables -t nat -A DOCKER -p tcp -d 0/0 --dport ${fatherPort} -j DNAT --to-destination ${containerIp}:${containPort}
iptables -t nat -A POSTROUTING -s ${containerIp}/32 -d ${containerIp}/32 -p tcp -m tcp --dport ${containPort} -j  MASQUERADE
iptables -t filter -A DOCKER -d ${containerIp}/32 -p tcp -m tcp --dport ${containPort} -j ACCEPT
iptables -I INPUT -p tcp --dport ${fatherPort} -j ACCEPT


5 使用windows 连接 宿主机

在这里插入图片描述

举报

相关推荐

0 条评论