1.修改zabbix_java相关选项
[[email protected] zabbix]# cd /usr/local/sbin/zabbix_java [[email protected] zabbix_java]# vim settings.sh [[email protected] zabbix_java]# sed -e ‘/^#/d;/^$/d‘ settings.sh #该文件默认全部注释,启用下面几项即可 LISTEN_IP="0.0.0.0" LISTEN_PORT=10052 PID_FILE="/tmp/zabbix_java.pid" START_POLLERS=5
2.修改zabbix_server文件
[[email protected] zabbix_java]# sed -e ‘/^#/d;/^$/d‘ /usr/local/etc/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix [[email protected] zabbix_java]# vim /usr/local/etc/zabbix_server.conf [[email protected] zabbix_java]# sed -e ‘/^#/d;/^$/d‘ /usr/local/etc/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5
3.执行startup.sh
[[email protected] zabbix_java]# sh startup.sh & [[email protected] ~]# netstat -tnlup | grep 10052 tcp 0 0 :::10052 :::* LISTEN 29326/java
4.tomcat端,安装catalina-jmx-remote.jar
[[email protected] ~]# wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar [[email protected] ~]# mv catalina-jmx-remote.jar /usr/share/java/tomcat6 #yum路径 mv catalina-jmx-remote.jar /usr/local/tomcat/lib/ #源码路径
5.修改catalina.sh文件
[[email protected] tomcat6]# vim /usr/share/tomcat6/bin/catalina.sh [[email protected] tomcat6]# cat /usr/share/tomcat6/bin/catalina.sh CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.16.253 -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" #tomcat端的IP和指定JMX端口,在/bin/sh下面添加此段
7.重启服务
[[email protected] tomcat6]# /etc/init.d/tomcat6 restart [[email protected] tomcat6]# /etc/init.d/zabbix-agent restart
8.服务端测试(jar包在附件)
[[email protected] ~]# java -jar /root/cmdline-jmxclient-0.10.3.jar - 192.168.16.251:12345 java.lang:type=Memory NonHeapMemoryUsage
错误一:
[[email protected] ~]# java -jar /root/cmdline-jmxclient-0.10.3.jar - 192.168.16.251:18090 java.lang:type=Memory NonHeapMemoryUsageException in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.16.251; nested exception is: java.net.ConnectException: Connection refused] at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369) at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270) at org.archive.jmx.Client.execute(Client.java:225) at org.archive.jmx.Client.main(Client.java:154)Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.16.251; nested exception is: java.net.ConnectException: Connection refused] at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:122) at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1955) at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1922) at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287) ... 3 more
解决:
cat /usr/share/tomcat6/bin/catalina.sh CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.16.253 -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
错误二:
解决:
sh startup.sh & #放入后台启动
jar包及tomcat模板在附件
时间: 2024-09-30 21:57:43