Centos6配置JMX监控
1、相关环境描述
1)服务端(被监控端):115.159.94.225
2)客户端(监控端) :118.89.109.24
注:这个是在同一个VPC子网的两台主机,系统都是centos6.8_x64
2、相关软件描述
1)apache-tomcat-7.0.73.tar.gz:tomcat7主程序包
2)jdk-7u45-linux-x64.tar.gz:java主程序包
3、案例实施
1)服务端(115.159.94.225)上配置tomcat7和java环境
[root@VM_0_46_centos ~]# tar zxf apache-tomcat-7.0.73.tar.gz
[root@VM_0_46_centos ~]# tar zxf jdk-7u45-linux-x64.tar.gz
[root@VM_0_46_centos ~]# mv jdk1.7.0_45/ /usr/local/java
[root@VM_0_46_centos ~]# mv apache-tomcat-7.0.73 /usr/local/tomcat7
[root@VM_0_46_centos ~]# cat /etc/profile #标颜色的为需添加部分
...
export JAVA_HOME="/usr/local/java"
export CATALINA_BASE="/usr/local/tomcat7"
export PATH="$JAVA_HOME/bin:$PATH:$CATALINA_BASE/bin"
[root@VM_0_46_centos ~]# source /etc/profile
[root@VM_0_46_centos ~]# vim /usr/local/tomcat7/bin/catalina.sh #在Execute部分前面添加标颜色部分内容
.....
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=115.159.94.225 -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# ----- Execute The Requested Command -----------------------------------------
.....
注:“hostname”和“port”根据实例情况修改
[root@VM_0_46_centos ~]# startup.sh
[root@VM_0_46_centos ~]# netstat -anpt | grep java
tcp 0 0 0.0.0.0:41502 0.0.0.0:* LISTEN 3471/java
tcp 0 0 0.0.0.0:36994 0.0.0.0:* LISTEN 3471/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 3471/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 3471/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 3471/java
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 3471/java
注: JMX 的监听端口必须是在监听状态,这里是“ 8888 ”
2)服务端本地测试连接
打开一个命令行输入“jconsole”
![](https://static.oschina.net/uploads/img/201706/18135059_TVHZ.jpg)
输入被监控端的地址和端口,然后单击“Connect”
![](https://static.oschina.net/uploads/img/201706/18135059_9NGo.jpg)
在提示窗口中单击“Insecure”
如下图表示能够正常连接
3)客户端(118.89.109.24)配置java环境
[root@VM_0_241_centos ~]# tar zxf jdk-7u45-linux-x64.tar.gz
[root@VM_0_241_centos ~]# mv jdk1.7.0_45/ /usr/local/java
[root@VM_0_241_centos ~]# cat /etc/profile #标颜色部分为需添加部分
.....
export JAVA_HOME="/usr/local/java"
export PATH="$JAVA_HOME/bin:$PATH"
[root@VM_0_241_centos ~]# source /etc/profile
20170131201710661?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzQ4NTcyNTA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Cent
4)客户端上测试连接
打开一个命令行输入“jconsole”
![](https://static.oschina.net/uploads/img/201706/18135100_lsSA.jpg)
输入被监控端的地址和端口,然后单击“Connect”
在提示窗口中单击“Insecure”
成功连接后,如下图所示