After creating a Sales Demonstration system for an industry trade show using Ubuntu 10.10, I decided to create a personal development system based on one of my personal favorite free operating systems, Ubuntu. An old laptop was pressed into service as a meager server on which I could refresh my admin skills and provide a target for testing prototype concepts rambling around my brain. One of the first services this little laptop will host is Apache Active MQ 5.4.2 which was released December of 2010. (Authors Note: This article has been updated to support Ubuntu 11 and ActiveMQ 5.5)
Although Ubuntu has a large collection of software available in many repositories, there is no way, currently, to perform an
apt-get for Active MQ. It has to be installed by hand. Fortunately, this is a relatively simple matter. There are a couple of stumbling blocks which prevented a smooth install for me so I thought this article might help others avoid them.
Ensure you have Java installed
I prefer to have have the
sun-java6-jre packages for this purpose. I’m currently testing the free versions which come with Ubuntu. I have a separate link which describes installing sun-java on Ubuntu. It’s like 5 commands; no big deal.
Go to the download page for Apache Active MQ and select the latest available release tarball and extract it on your server.
Move it to
/opt where optional software package are intended to be placed.
activemq scripts expect to find Active MQ installed in
/opt/activemq. I personally do not like having a non-versioned directory like that. Moving the package to
/opt/activemq as would be expected by the scripts can make it difficult months down the line to upgrade. What version is installed? Will you remember? Now, this is a personal preference, but I like to know at any time what versions of software I have installed so I generally create a sym-link so the script finds things where it expects and I can see what version is installed. It is also easier to switch versions by simply linking
/opt/activemq to another directory containing a different version. If it works fine, I can delete the old version, if not, I can switch the like back all this happens without changing any of the scripts. Here is how I did it:
Add Non-Privileged Account
It’s never a good idea to run a service as root, so it is a common practice to add a dedicated user account which doesn’t have much authority and run the service as this account. This will have the added benefit of making the process easier to identify with tools such as
Some (many?, most?) systems will give a system user a false login shell. This will keep the
activemq script from running so you will have to make sure the account uses the
bash shell. First, open the
/etc/passwd file in your favorite editor. Don’t forget to use
sudo as it is a privileged file. Here is the line when using
Go to the end of the list of accounts and make sure the shell for this account looks something like the following line. Don’t worry about the numbers and such, but make sure the last argument contains
/bin/bash and not something like
/bin/false, for example, the line should look something like the following:
Recursively change the ownership of the entire
activemq directory to the
activemq user you just added.
Next, sym-link the init script provided by Active MQ to
Tell Ubuntu to start Active MQ on boot:
At this point you will probably get a warning about missing LSB information. LSB information is a block of information which directs how the links are made. See http://wiki.debian.org/LSBInitScriptsfor more details.
Now, let’s build a default configuration file:
Change the owner and group of the config file:
Change the file permissions so its read-write by root only:
Editing the Configuration
Unfortunately, this is where you will have to begin searching through your configuration file and make changes specific to your version of software and setup. There have been some changes between releases of Active MQ so the instructions may not match what you see in your files.
Edit the newly generated
/etc/default/activemq file. I’ll use
You’re looking for
ACTIVEMQ_USER="". Enter the name of your
activemq user name between the quotes.
Now we will configure the Active MQ broker to listen for JMX connections. Further down the file, un-comment the JMX configuration lines:
The above configuration lines enable JMX on port 11099 and use two file to control access through JMX.
The next section will specify how the shutdown script will connect to the broker (via JMX) and log into the management console to issue the shutdown command. This line will connect to broker via port 11099 and log in as
controlRole with a password of
abcd1234. Keep these values (or whatever you change them to) in mind as you will need to make sure they are registered in the
data/jmx.access files in the next steps.
# Specify the queue manager URL for using “browse” option of sysv initscript
Save your changes to the configuration file and exit the editor.
Now, you must edit the
conf/jmx.access files. Use the sample data they provide in the comments immediately above the lines. Remember to use the values you specified (or left alone) int the
--jmxpassword of the
ACTIVEMQ_SUNJMX_CONTROL configuration line above.
Ensure that these JMX access control files are readable by only the
activemq user account!
sudo chmod 600 /opt/apache-activemq-5.5.0/conf/jmx.access
Doing that enables the init script to connect to the locally running software via JMX, a management console. Without this configured correctly you’re looking at issuing a shutdown command and seeing a ton of Java errors followed by thirty seconds (configurable) of timeout before the script finally issues a
KILL on the process.
Now run the service
Then look in the
/opt/activemq/data directory for the PID and log files. You can
tail the log file to see what is happening:
The Active MQ broker should be running. You can test this in a variety of ways including using the
telnet command to connect to the broker on 61616, the JMX port on 11099 or more simply by opening a browser connection to the HTTP management port: http://localhost:8161