How to Remote Manage » History » Version 4
Henning Blohm, 08.03.2020 11:21
1 | 1 | Henning Blohm | h1. How to Remote Manage |
---|---|---|---|
2 | 2 | Henning Blohm | |
3 | 4 | Henning Blohm | A significant amount of internal state and operations of a z2 system can be accessed via JMX using tools such as jconsole or jvisualvm. In order to access z2 via JMX some JMX related configuration should be applied. |
4 | 2 | Henning Blohm | |
5 | 3 | Henning Blohm | h2. Configuring JMX access in Z2 |
6 | |||
7 | h2. Accessing a Java VM remotely via JMX |
||
8 | |||
9 | It should not be necessary, but unfortunately, as JMX in based on RMI, accessing to a Java VM via JMX remotely can be non-trivial. |
||
10 | |||
11 | Here are two practical approaches: |
||
12 | |||
13 | 1 | Henning Blohm | h3. Accessing a Remote JVM via JMX directly |
14 | 4 | Henning Blohm | |
15 | The tricky thing about JMX over RMI is that knowing the host name and the JMX port is merely sufficient to request RMI access that then uses a different (random) port and a host name defined by the JMX endpoint. That is, when accessing to the JMX endpoint we get a redirect to a different host and port combination that may not make sense from where we are calling, either because the host name is not resolvable or wrong (e.g. localhost), or because the port is not accessible. |
||
16 | |||
17 | However, the following two system properties can be used to solve these problems: |
||
18 | |||
19 | | com.sun.management.jmxremote.rmi.port | Defines the RMI port to use and can be set to be the same as the JMX port | |
||
20 | | java.rmi.server.hostname | Defines the RMI host name to use | |
||
21 | 3 | Henning Blohm | |
22 | TBC |
||
23 | |||
24 | h3. Accessing a Remote JVM via JMX via an SSH tunnel |
||
25 | |||
26 | protected, localhost only, no user name required |
||
27 | |||
28 | TBC |
||
29 | |||
30 | 2 | Henning Blohm | |
31 | h2. Remote Synchronization and Log Streaming |
||
32 | |||
33 | Starting with version 2.8, Z2 offers a built-in command line utility to synchronize (with log output) and provide streaming access to the z2 home log. When in Z2_HOME/bin run: |
||
34 | |||
35 | <pre><code class="bash"> |
||
36 | java -cp z.jar com.zfabrik.launch.Manage -? |
||
37 | </code></pre> |
||
38 | |||
39 | for the usage: |
||
40 | |||
41 | <pre><code class="bash"> |
||
42 | SYNOPSIS |
||
43 | |||
44 | java -cp z.jar Manage <command> <options> |
||
45 | |||
46 | COMMANDS |
||
47 | |||
48 | sync The sync performs a synchronization of a running (remote) z2 Home. |
||
49 | |||
50 | showlog Continuously stream the z2 Home log of a running z2 Home to the current stderr. |
||
51 | |||
52 | OPTIONS |
||
53 | |||
54 | -url <url> |
||
55 | JMX URL identifying the target z2 Home. Defaults to service:jmx:rmi:///jndi/rmi://localhost:7777/jmxrmi |
||
56 | The URL may be shortened to <host>:<port> (e.g. localhost:7777) |
||
57 | |||
58 | |||
59 | -user <username> |
||
60 | |||
61 | Username used for JMX authentication. Optional. |
||
62 | |||
63 | -pass <password> |
||
64 | |||
65 | Password used for JMX authentication. Optional. Mandatory when a username has been set |
||
66 | |||
67 | -b <n> |
||
68 | |||
69 | Number of lines to read before current (if available) when running showlog. |
||
70 | |||
71 | EXAMPLE |
||
72 | |||
73 | java -cp z.jar com.zfabrik.launch.Manage showlog -url host:7777 -user admin -pass admin |
||
74 | </code></pre> |