Home  >  Blog  >   JBoss

Managing Mod Cluster With CLI In JBoss

Rating: 4
  
 
4978

There are a couple of options that can be used to manage and retrieve runtime information from your cluster. Your first option is the command-line management interface, which can be used to trigger a set of commands available in the mod_cluster subsystem.

Get ahead in your career by learning JBoss through Mindmajix JBoss Training.

The first command you need to learn is list-proxies , which returns merely the hostnames (and port) of the connected proxies:

[standalone@localhost:9999 subsystem=modcluster] :list-proxies
{
“outcome” => “success”,
“result” => [
“CP11-010:8888”,
“CP12-010:8888”
]
}

While this can be useful for a quick inspection of your cluster members, you can get detailed info with the read-proxies-info command that actually sends an INFO message to the httpd server:

[standalone@localhost:9999 subsystem=modcluster] :read-proxies-info
{
“outcome” => “success”,
“result” => [
“CP11-010:8888”,
“Node: [1],Name: de6973fe-b63d-31dc-a806-
04ec16870cfa,Balancer: mycluster,LBGroup: ,Host: 192.168.10.1,Port:
8080,Type: http,Flushpackets: Off,Flushwait:
10,Ping: 10,Smax: 65,Ttl: 60,Elected: 0,Read: 0,Transfered:
0,Connected: 0,Load
: 1
Vhost: [1:1:1], Alias: default-host
Vhost: [1:1:2], Alias: localhost
Vhost: [1:1:3], Alias: example.com
Context: [1:1:1], Context: /, Status: ENABLED

“CP12-010:8888”,
“Node: [1],Name: re5673ge-c83d-25dv-y104-
02rt16456cfa,Balancer: mycluster,LBGroup: ,Host: 192.168.10.2,Port:
8080,Type: http,Flushpackets: Off,Flushwait:
10,Ping: 10,Smax: 65,Ttl: 60,Elected: 0,Read: 0,Transfered:
0,Connected: 0,Load
: 1
Vhost: [1:1:1], Alias: default-host
Vhost: [1:1:2], Alias: localhost

Vhost: [1:1:3], Alias: example.com
Context: [1:1:1], Context: /, Status: ENABLED

]
}

Note

The mod_cluster subsystem also provides the read-proxies-configuration command, which can provide slightly more verbose information about your cluster. For the sake of brevity, we will omit printing its output. The list of proxies that are part of your cluster can also be modified with the CLI. For example, you can use the add-proxy command to add a proxy that has not been “captured” by the mod cluster’s httpd configuration.

Related Article: Testing Mod Clutser

MindMajix Youtube Channel

[standalone@localhost:9999 subsystem=modcluster] :add-proxy(host=
CP15-022, port=9999)
{“outcome” => “success”}

At the same time, you can remove proxies from the list using the corresponding removeproxy command:

[standalone@localhost:9999 subsystem=modcluster] :removeproxy(
host=CP15-022, port=9999)
{“outcome” => “success”}

Managing your web contexts with CLI

You can use the CLI to manage your web contexts. For example, the enable-context command can be used to tell Apache that a particular web context is able to receive requests:

[standalone@localhost:9999 subsystem=modcluster] :enablecontext(
context=/myapp, virtualhost=default-host)
{“outcome” => “success”}

The corresponding disable-context command can be used to prevent Apache from sending new requests:

[standalone@localhost:9999 subsystem=modcluster] :disablecontext(
context=/myapp, virtualhost=default-host)
{“outcome” => “success”}

Rather, if you want to stop Apache from sending requests from a web context, you can use the stop-context command:

[standalone@localhost:9999 subsystem=modcluster] :stopcontext(
context=/myapp, virtualhost=default-host, waittime=50)
{“outcome” => “success”}

Adding native management capabilities

If you are not able (or simply don’t want) to use the CLI, then you can alternatively configure Apache web server to provide some native management capabilities through the browser. In order to do that, all you need to add is the mod_cluster_manager application context:

You can test your mod_cluster manager application by pointing to the mod_cluster_manager web context at:

https://192.168.10.1:8888/mod_cluster_manager.

In our example, the mod_cluster manager displays information about all the JBoss AS 7 nodes that have been discovered through multicast announcements.

JBoss AS 7 nodes

As you can see, in the mod_cluster manager page you have plenty of useful information, such as the number of hosts that are currently active (in our example, two nodes) and the web context that are available.

Frequently asked Jboss Interview Questions

By default, all web contexts are mounted automatically (not requiring an explicit mount as for mod_jk), but you can, at any time, exclude or include them by clicking on the Disable/Enable link, which is placed next to the web context.

Managing web contexts using the configuration file

For the sake of completeness, we will add one more option that can be used to manage your web context, by using your application server configuration file. By default, all web contexts are enabled; however, you can exclude web contexts from the main configuration file using the excluded-contexts directive:

Troubleshooting mod_cluster

Installing mod_cluster requires just a few steps on the httpd side to get working; however, just in case you cannot get ahead with it, you can find some clues by allowing a verbose output on the administration console:

AllowDisplay On

When setting this directive, you can get some information about the single modules loaded into httpd:

Allow Display On

Should you find any module that exhibits an OK in the display page, you have at least a clue to investigate.

One more possible cause of errors is advertising messages that could potentially hit a firewall. Remember that advertisement messages use UDP port 23364 and multicast address 224.0.1.105. In order to verify if advertising is an issue, you could try to turn it off by setting the following in the httpd side:

ServerAdvertise Off

This directive should be matched on the application server side by the proxy-list element, which defines the list of httpd servers with which the AS will initially communicate:

Finally, don’t forget to check the httpd logs directory for the error.log file and see if it contains any descriptive error. For example, a common source of errors that can be found on a Windows machine is triggered by Apache’s Dynamic Shared Objects (DSO):

[Tue Aug 23 10:29:24 2011] [warn] proxy: No protocol handler was valid for the URL /balancedemo. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

This kind of error can be solved by loading the additional proxy module used for your protocol, in this case, the proxy_http_module module:

LoadModule proxy_http_module ./modules/mod_proxy_http.so

Explore Jboss Sample Resumes! Download & Edit, Get Noticed by Top Employers! Downlaod Now

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
JBoss TrainingMar 23 to Apr 07View Details
JBoss TrainingMar 26 to Apr 10View Details
JBoss TrainingMar 30 to Apr 14View Details
JBoss TrainingApr 02 to Apr 17View Details
Last updated: 03 Apr 2023
About Author

Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read more