jdk下载页面
脚本
[root@NFS-WEB1 latest]# vim /etc/profile.d/java
export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin/:$PATH
APache-tomcat安装
下载tomcat
wget -C /usr/local/
cd /usr/local/
tar xf apache-tomcat-7.0.69.tar.gz
ln -sv apache-tomcat-7.0.69 tomcat
`tomcat' -> `apache-tomcat-7.0.67'
查看帮助:
[root@NFS-WEB1 tomcat]# bin/catalina.sh --help
启动:
[root@mysql-master local]# cd tomcat/
[root@mysql-master tomcat]# bin/catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@mysql-master tomcat]# ss -tlnp|grep java
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",7498,51))
LISTEN 0 100 :::8009 :::* users:(("java",7498,47))
LISTEN 0 100 :::8080 :::* users:(("java",7498,46))
[root@mysql-master tomcat]# jps
7794 Jps
7498 Bootstrap
[root@mysql-master tomcat]#
zabbix安装参考直达
zabbix配置文件修改如下:
[root@localhost zabbix_java]# egrep -v "^$|^%|^#" /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
ListenIP=127.0.0.1
Timeout=4
AlertScriptsPath=${datadir}/zabbix/alertscripts
ExternalScripts=${datadir}/zabbix/externalscripts
LogSlowQueries=3000
设置zabbix监控tomcat的java
[root@localhost zabbix_java]# grep -E -v "^$|^#|^%" settings.sh
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/tmp/zabbix_java.pid"
START_POLLERS=5
[root@localhost zabbix_java]# pwd
/usr/local/zabbix/sbin/zabbix_java
设置zabbix客户端连接zabbix服务端
[root@hanye147 zabbix_java]# egrep -v "^$|^%|^#" /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Timeout=8
修改catalina.sh,添加一条如下:
/usr/local/tomcat/bin/catalina.sh
CATALINA_OPTS="
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=12345"
启动所有服务
[root@localhost zabbix]# /etc/init.d/zabbix_server restart
Shutting down Zabbix server: [ OK ]
Starting Zabbix server: [ OK ]
[root@localhost zabbix]# /etc/init.d/zabbix_agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
[root@localhost zabbix]#
[root@hanye147 tomcat]# /usr/local/zabbix/sbin/zabbix_java/startup.sh
[root@localhost zabbix]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@localhost zabbix]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
确保10052和12345端口成功启动
[root@localhost zabbix]# ss -tlnp|grep java
LISTEN 0 50 :::10052 :::* users:(("java",55501,11))
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",55572,57))
LISTEN 0 50 :::58855 :::* users:(("java",55572,21))
LISTEN 0 100 :::8009 :::* users:(("java",55572,50))
LISTEN 0 100 :::8080 :::* users:(("java",55572,49))
LISTEN 0 50 :::12345 :::* users:(("java",55572,20))
LISTEN 0 50 :::48922 :::* users:(("java",55572,19))
[root@localhost zabbix]#
下载jmxcmd.jar测试
[root@localhost local]# java -jar jmxcmd.jar - 127.0.0.1:12345 java.lang:type=Memory NonHeapMemoryUsage
10/23/2016 06:26:24 +0800 de.layereight.jmxcmd.Client NonHeapMemoryUsage:
committed: 24576000
init: 24576000
max: 224395264
used: 17869232
[root@localhost local]#
wget -P /usr/local/tomcat/lib/
密码:onyt