Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
APACHE KARAF COOKBOOK

You're reading from   APACHE KARAF COOKBOOK Over 60 recipes to help you get the most out of your Apache Karaf deployments

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783985081
Length 260 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Apache Karaf for System Builders FREE CHAPTER 2. Making Smart Routers with Apache Camel 3. Deploying a Message Broker with Apache ActiveMQ 4. Hosting a Web Server with Pax Web 5. Hosting Web Services with Apache CXF 6. Distributing a Clustered Container with Apache Karaf Cellar 7. Providing a Persistence Layer with Apache Aries and OpenJPA 8. Providing a Big Data Integration Layer with Apache Cassandra 9. Providing a Big Data Integration Layer with Apache Hadoop 10. Testing Apache Karaf with Pax Exam Index

Using JMX to monitor and administer Apache Karaf

By default, Apache Karaf can be administered via Java Management Extensions (JMX). However, systems builders often need to tweak the default configurations to get their deployment integrated into their network. In this recipe, we'll show you how to make these changes.

Getting ready

The ingredients of this recipe include the Apache Karaf distribution kit, access to JDK, and a source code editor. The sample configuration for this recipe is available at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter1/chapter1-recipe5.

Tip

Administrators should take care when exposing JMX access to their Karaf instance. Enabling of SSL and use of strong passwords is recommended.

How to do it…

  1. The first step is editing the management configuration. Apache Karaf ships with a default management configuration. To make our modifications, we update the etc/org.apache.karaf.management.cfg file. Consider the following code:
    #
    # Port number for RMI registry connection
    #
    rmiRegistryPort = 11099
    
    #
    # Port number for RMI server connection
    #
    rmiServerPort = 44445

    The default ports, 1099 and 44444, are usually fine for general deployment. Change these ports only if you are experiencing port conflicts on your deployment. Now, consider the following snippet:

    #
    # Role name used for JMX access authorization
    # If not set, this defaults to the ${karaf.admin.role} configured in etc/system.properties
    #
    jmxRole=admin

    Towards the bottom of the configuration file, there will be a commented-out entry for jmxRole; enable this by removing the hash character.

  2. The next step is updating the user's file. We must now update the etc/users.properties file with the following code:
    karaf = karaf,_g_:admingroup
    _g_\:admingroup = group,admin,manager,viewer,jmxRole
    

    The users.properties file is used to configure users, groups, and roles in Karaf. We append jmxRole to the admin group. The syntax for this file follows the Username = password, groups format.

  3. The last step is testing our configuration. After making the previous configuration changes, we'll need to restart our Karaf instance. Now, we can test our JMX setup. Have a look at the following screenshot:
    How to do it…

    After restarting Karaf, use a JMX-based admin tool of your choice (the previous screenshot shows JConsole) to connect to the container. Due to image size restrictions, the full URL couldn't be displayed. The full URL is service:jmx:rmi://127.0.0.1:44445/jndi/rmi://127.0.0.1:11099/karaf-root. The syntax of the URL is service:jmx:rmi://host:${rmiServerPort}/jndi/rmi://host:${rmiRegistryPort}/${karaf-instance-name}.

You have been reading a chapter from
APACHE KARAF COOKBOOK
Published in: Aug 2014
Publisher:
ISBN-13: 9781783985081
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime