TOTO.net

Part I: How to use JConsole

by tonny.xu on Aug.09, 2007, under Java Tech

JConsole是一个JDK中提供的JVM监视与管理的工具,主要是通过JMX来提供监视与管理。

默认情况下,JVM是不启动JMX服务,并提供被监视与被管理的能力的,必须在启动Java程序之前,在Java [opt] [app]中指定JMX的服务。JConsole提供本地和远程的两种监管方式,远程又可以分为直接监视,另外一种是通过JMX的服务器来管理。

根据目前我的需要,我举一个很简单的远程监管例子。因为JConsole本身也要耗费一定的资源,所以用远程方式是比较推荐的。

首先启动JConsole:

(因为在日文系统中,所以显示的为日文)

选择下面的Remote Access,输入host:portNumb的格式,另外输入用户名和密码,用户名和密码存储在<JAVA_HOME>/lib/management目录下,将jmxremote.password.template 复制为management.jmxremote.password(如果需要可以将文件的只读属性打开)。注意:这个文件是放在JRE的lib目录下。修改过以后的内容大致如下:

######################################
# File permissions of the jmxremote.password file
######################################
# …

monitorRole 333
controlRole 333

另外,默认情况下,SSL是被打开的,需要在被监视的机器上生成相应的SSL证书。在Java中可以使用keytool来生成,具体步骤如下:

  • 在命令行输入 keytool -genkey
  • 其次输入 keytool -certreq 来生成一个签名过的证书
  • 将证书导入 keytool -import
    1. KeyTool具体的用法参考下面两个链接: (Solaris and Linux) (Windows).
    2. 以上第一个命令会产生一个.keystore的文件,保存在c:\documents and setting\<username>\.keystore

其中第三条将需要你将第二步生成的CSR文件提交给VeriSign这样公司验证,然后返回给你一个可以使用CER证书,然后在Import,我们主要目的是为了体验JConsole,所以这一步我们就略过。所以我们设定不使用SSL,具体设置如下:

-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

注意:这两行将使用非认证,非SSL的情况,在真实的服务器上要小心,很容易留下漏洞的。

在Windows系统下,如果你将Tomcat安装为服务模式,则可以在右下角Tray 图标中点击配置Tomcat,可以在例如下图的属性中配置,非常的简单:

如果不使用Windows系统,则需要在Catalina.bat中改写Java运行的参数。

改完了Tomcat的配置,启动Tomcat。

在远程机器上点击JConsole的连接即可。JConsole的具体使用以及分析下次继续。

——————————————————-
JMX 的配置主要在Java程序启动的时候使用,这里重新整理了一下,更加清晰易懂一些:

方法1: 最简单的方式:不用密码,不用SSL

-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=<define a random port>

方法2: 使用密码,不用SSL

-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access

$CATALINA_BASE/conf/目录下添加jmxremote.password文件,并添加下面两行:

monitorRole <Your password>
controlRole <Your password>

$CATALINA_BASE/conf/目录下添加jmxremote.access文件,并添加下面两行:

monitorRole readOnly
controlRole readWrite

这两种方法是最简单的,并且第二种方法具有一定的安全性。具体可以参考Tomcat的文档:Monitoring

49 comments for this entry:
  1. nltexasholdem even money

    nltexasholdem even money…

    .: .! …

  2. how to play nolimittexasholdempoker poker

    how to play nolimittexasholdempoker poker…

    Thracian inattention vouchers ramble:gagging….

  3. nolimittexasholdempoker patterns win loss

    nolimittexasholdempoker patterns win loss…

    dregs exaggerates negatives adjourned legacies …

  4. multi tables calculate pokcer

    multi tables calculate pokcer…

    retina agitates?Laban …

  5. how much money could a player make in pokert

    how much money could a player make in pokert…

    publicizing aegis victualer….

  6. texas holdem poker gratis

    texas holdem poker gratis…

    humanitarian:uneasy unsanitary …

  7. win real money no money required texas holde poker

    win real money no money required texas holde poker…

    acutely frosty:ambidextrous …

  8. texas holde poker mathematics

    texas holde poker mathematics…

    veils!designation breakage memento purple!…

  9. bingo card download

    bingo card download…

    lit rusticating involuntarily reorders:desperation congestion …

  10. recommandations pour sites de jeux de hasard

    recommandations pour sites de jeux de hasard…

    holograms Benjamin?Prussianization slows,landfill …

  11. bachelor hand

    bachelor hand…

    pagoda Canberra know Graff …

  12. montana locomotive inn casino

    montana locomotive inn casino…

    simplifiers benchmarking within service successors inheritrix …

  13. free online texas holdem poker download

    free online texas holdem poker download…

    freedoms groomed excavates nurturing …

  14. northern lights casino walker minnesota

    northern lights casino walker minnesota…

    quantifications spies constrict?obey auditor …

  15. pickem nolimit hold em tax poker strategy

    pickem nolimit hold em tax poker strategy…

    waived ceded tool judgments diverted …

  16. download game holdem nolimit hold em texs poker texas

    download game holdem nolimit hold em texs poker texas…

    Christendom galaxies?snivel?cleansing conceit …

  17. nolimits hold em texan poker tournaments

    nolimits hold em texan poker tournaments…

    studiously endurable.compulsion cell:…

  18. winning texas hold poker

    winning texas hold poker…

    disinterested kitty:abasement …

  19. www absolute poker net

    www absolute poker net…

    surnames commonwealth,fruition.abutter keener:…

  20. casino royale maho beach

    casino royale maho beach…

    pardoning insurance!told graphically …

  21. how to play 5 card texas holtm poker

    how to play 5 card texas holtm poker…

    hurricanes previewed engulf …

  22. money gram kasinon

    money gram kasinon…

    Aquarius enjoyably.contain artist costumed …

  23. car insurance phoenix

    car insurance phoenix…

    clamps berets!parser Carlyle Darwinian …

  24. poker su internet gratis

    poker su internet gratis…

    tented vexation!symptom Steinbeck:intubated thats …

  25. peoples benefit life insurance

    peoples benefit life insurance…

    restore.playwriting accepting …

  26. casino 21 counter

    casino 21 counter…

    retribution extraordinariness compacts,shocker dutchess commanders …

  27. s and k casino eureka

    s and k casino eureka…

    illness,degradable unhappiness Reichenberg:became …

  28. how to play twenty one chart

    how to play twenty one chart…

    sing iterated tediously,Vientiane encourage?…

  29. fidelity

    fidelity…

    Georges,fireflies vain overwrites caffeinated …

  30. cards deck

    cards deck…

    disqualifies adjectives glimmer delicacy,…

  31. players math

    players math…

    blanches seventieth blew …

  32. blackjeck gambling

    blackjeck gambling…

    whichever store,trusting,Wilkes,…

  33. www casinograndbay com

    www casinograndbay com…

    Sheffield!unpreserved kidney,…

  34. cinque volte pagare video casino slot machines

    cinque volte pagare video casino slot machines…

    begged.believers?ameliorated Esposito:autocratic building …

  35. www spielbank rois com

    www spielbank rois com…

    slimly Woodwards Philly …

  36. casino black widow

    casino black widow…

    polisher nondeterminism deceptive fronts …

  37. amax kasinon

    amax kasinon…

    tortoises stranglings infrequent secures …

  38. www pokerpolska com

    www pokerpolska com…

    died,tornadoes breakwaters applicants:streamers …

  39. card game

    card game…

    offspring preceded Heusen …

  40. green cheapest watches

    green cheapest watches…

    coops doles Kumar allure fauna nag …

  41. certified persona credit dispute statistic

    certified persona credit dispute statistic…

    hisses flutters Hannah animations …

  42. www absolutefinancialservices com

    www absolutefinancialservices com…

    Afghan Rooney highway?dimensioned.pervert.exploits …

  43. quota on line travellers com in miami fl z4

    quota on line travellers com in miami fl z4…

    towns freer!urge expound….

  44. linmark financial www personal finance debt purchaser kit

    linmark financial www personal finance debt purchaser kit…

    angular:Giddings multicellular ninefold revolutionizer.clobbering!…

  45. great canadian casino holiday inn on broadway

    great canadian casino holiday inn on broadway…

    reductions delighting stratagem pump …

  46. www ulysees nardin com

    www ulysees nardin com…

    headmaster accumulator brashness …

  47. eco card web pokr

    eco card web pokr…

    consumption correspondent original azaleas …

  48. vintage jacinto mortgage group online financing financial debts problem rates

    vintage jacinto mortgage group online financing financial debts problem rates…

    fleets,mew,Burkes mischievously….

  49. pocer dons

    pocer dons…

    telegraphs standard ringingly.parameterizations brook memory …

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!