5 web端tomcat服务器的配置调整
在tomcat/conf/server.xml 里面添加如下:
<Service>
<Connector port="9444" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
<Engine defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host appBase="webapps"
unpackWARs="false" autoDeploy="false"
xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="admin_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"
fileDateFormat="yyy-MM-dd"/>
<Context path="/manager" cookies="false"
docBase="server/webapps/manager" debug="0"
privileged="true" reloadable="false" />
</Host>
</Engine>
</Service>
然后在tomcat/conf/tomcat-users.xml里面 添加
<role rolename="manager-gui"/>
<user username="tomcat" password="9ssspw " roles="manager-gui"/>
passwords 为连接密码 可自行更改,然后重启tomcat 服务
去cacti服务器端执行perl tomcatstats.pl 10.xx.3.xx:9444 'tomcat' '9ssspw ' http-9444,
check统计脚本是否能取到tomcat的数据,有数据即正常,如下所示:
[root@squid-2 scripts]# /usr/bin/perl tomcatstats.pl 10.xx.3.xx:9444 'tomcat' 'xxx’ http-9444
:tomcat0401@10.254.3.29:9444/manager/status?XML=true jvm_memory_free:3409129096 jvm_memory_max:3892314112 jvm_memory_total:3892314112 connector_max_time:131 connector_error_count:2 connector_bytes_sent:20241 connector_processing_time:168 connector_request_count:5 connector_bytes_received:0 connector_current_thread_count:4 connector_min_spare_threads: connector_max_threads:150 connector_max_spare_threads: connector_current_threads_busy:1
[root@squid-2 scripts]#
记录debug期间的报错信息如下:
[root@squid-2 scripts]# perl tomcatstats.pl 10.xx.3.xx:9300 admin 9ssspw http-9300
Can't locate XML/Simple.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at tomcatstats.pl line 7.
BEGIN failed--compilation aborted at tomcatstats.pl line 7.
需要安装XML::Simple
[root@squid-2 ~]# find / -name cpan
/usr/bin/cpan
[root@squid-2 ~]# /usr/bin/cpan XML::Simple
……
Prepending /root/.cpan/build/XML-Simple-2.20-7zpaOY/blib/arch /root/.cpan/build/XML-Simple-2.20-7zpaOY/blib/lib to PERL5LIB for 'install'
Installing /usr/local/share/perl5/XML/Simple.pm
Installing /usr/local/share/perl5/XML/Simple/FAQ.pod
Installing /usr/local/share/man/man3/XML::Simple.3pm
Installing /usr/local/share/man/man3/XML::Simple::FAQ.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
GRANTM/XML-Simple-2.20.tar.gz
/usr/bin/make install -- OK
Warning (usually harmless): 'YAML' not installed, will not store persistent state
继续报错File does not exist: at tomcatstats.pl line 20
[root@squid-2 scripts]# /usr/bin/perl tomcatstats.pl 10.254.3.29:9300 tomcat xxx http-9300
File does not exist: at tomcatstats.pl line 20
需要安装如下组件:
[root@squid-2 scripts]#yum install perl-HTML-Parser.i386 perl-HTML-Tagset.noarch perl-libwww-perl.noarch perl-URI.noarch
之后启动tomcat报错如下:
[tomcat@web-9 logs]$ cat catalina.out
2014-6-6 15:11:15 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.6.0_45/jre/lib/amd64/server:/usr/java/jdk1.6.0_45/jre/lib/amd64:/usr/java/jdk1.6.0_45/jre/../lib/amd64:/usr/local/lib::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2014-6-6 15:11:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property.
跟踪后发现是连接池的配置问题:
<Context path="/n" docBase="server/webapps/manager " debug="0" reloadable="true" crossContext="false">
把debug="0"去除即可。
分析:tomcat的6.0.37这个版本中可能用别的属性替代了debug功能。
Cacti监控Tomcat服务器实现过程(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/3df03f166fc5b09da3ddad9cb1049521.html