由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - trick to use JMX on EC2 (转载)
相关主题
how to do this iptables setup?问个firewall(iptables)的问题
help: iptables 问题Mysql无法远程连接,求助 (转载)
linux 网络高手请帮忙,help config OpenWrt请教,如果建立家里电脑和学校电脑的连接。
[求教]: openvpn over http-proxy dns 设置问题 (转载)同一台linux机器port forward应该用啥命令?
how to do this Iptables setting?port
how to build corp projects in ur EC2 boxiptables高手看过来,哪些端口是必需的?
用一台ubuntu做proxy?linux能不能限制一天最多错误登录次数?
service iptables start 咋没反应啊?iptables禁用的ip存在哪里?
相关话题的讨论汇总
话题: jmx话题: ip话题: port话题: iptables话题: ec2
进入Linux版参与讨论
1 (共1页)
c******n
发帖数: 4965
1
【 以下文字转载自 Java 讨论区 】
发信人: creation (努力自由泳50m/45sec !), 信区: Java
标 题: trick to use JMX on EC2
发信站: BBS 未名空间站 (Fri Sep 16 01:46:21 2011, 美东)
many java applications are written as JMX MBeans
but EC2 presents many problems for JMX
1) normally you have only port 22 open, changing security group is a hassle
if you are just debugging for one shot.
2) the second port used by JMX is determined dynamically, so you don't know
which port to open
3) JMX is going to figure out the *internal* ip of EC2 and let your JMX
client to connect to RMI on that IP, which can not be reached.
so to solve these
1) use ssh tunnel, + iptables on client
2) http://blogs.oracle.com/jmxetc/entry/connecting_through_firewall_using_jmx , i.e. setup RMI connector explicitly.
3) http://blogs.oracle.com/jmxetc/entry/connecting_through_firewall_using_jmx , "-Djava.rmi.server.hostname="
note that in 2) you should NOT supply the
-Dcom.sun.management.jmxremote.port=
argument, otherwise JMX will still use the dynamic port selection
for 1), the trick is to forward your tunnel the traffic onto the remote JMX
port through ssh, so your jconsole needs to connect to localhost instead.
another problem is that the remote JMX is going to ask you to connect to the
external_IP instead, not localhost, so you need to use iptables to route
all your packets onto the remote external_IP to localhost, on which the ssh
tunnel is listening.
########### iptables script ###########
EXTERNAL_BOX_IP=1.2.3.4
PORT=7500
sudo iptables -t nat -F
sudo iptables -t nat -A OUTPUT -d $EXTERNAL_BOX_IP -p tcp --dport $PORT -j
DNAT --to-destination 127.0.0.1
sudo iptables -t nat -A POSTROUTING -p tcp --dport $PORT -j MASQUERADE
############################
then creates the tunnel onto remote EC2 (whose ip is 1.2.3.4)
ssh -L7500:1.2.3.4:7500 1.2.3.4
then you can use jconsole to connect to 1.2.3.4:7500
the link above provides an easier trick without using iptables, i.e. let JMX
tell a lie and say -Djava.rmi.server.hostname=localhost . this
would not work if you do not connect through ssh tunnel, but open up
security group.
have fun!
yang
1 (共1页)
进入Linux版参与讨论
相关主题
iptables禁用的ip存在哪里?how to do this Iptables setting?
what's the IPTABLE command to limit the webpage connections ?how to build corp projects in ur EC2 box
SSH弱问用一台ubuntu做proxy?
被攻击了咋办?service iptables start 咋没反应啊?
how to do this iptables setup?问个firewall(iptables)的问题
help: iptables 问题Mysql无法远程连接,求助 (转载)
linux 网络高手请帮忙,help config OpenWrt请教,如果建立家里电脑和学校电脑的连接。
[求教]: openvpn over http-proxy dns 设置问题 (转载)同一台linux机器port forward应该用啥命令?
相关话题的讨论汇总
话题: jmx话题: ip话题: port话题: iptables话题: ec2