Apache ActiveMQ is a free open source message broker and integrated server mode. It supports clients and protocols from JAVA, c ++, C, Python, Perl, PHP and other languages. It offers many features, such as message group, the virtual destinations, destinations and combinations wildcards. It can be easily integrated into the spring application.
Before 工欲善其事必先利其器, then re-use this mq, we have to install activemq, then we look at how to install activemq. Since activemq is a java-based development, so you have to install jdk on the environment.
installation steps
1, the system update
Centos software system some updates or upgrades to time during installation can quickly find the installation package.
sudo yum install epel-release -y
sudo yum update -y
2, install jdk
Jdk installed in two ways, a way to install oracle jdk have to download the installation package, the second way without having to download the installation package, execute the command directly to complete the installation, the installation is openjdk.
(1) installation of a first embodiment jdk
First to Oracle official website to download jdk, jdk download address is: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html uploaded to the centos After the download, and then perform a local installation jdk.
After the download is complete upload centos, then enter the following command to install it.
sudo yum -y localinstall jdk-8u241-linux-x64.rpm
After the installation is complete, then check the jdk is installed successfully.
(2) A second embodiment of the installation jdk
Use the following manner was installed, do not download the installation package, enter the command directly in centos to complete the installation. Enter the command is:
sudo yum install -y java-1.8.0-openjdk
After the installation is complete, check whether the installation was successful.
java -version
Since the implementation of activemq need to configure jdk environment variable, then let's look at how to configure jdk variables.
3, configuration variables jdk
How to configure jdk variables? First we have to check if species are jdk environment variable.
echo $JAVA_HOME
Configuration is not checked, then we configure the environment variable, the installation path jdk find, this path is assigned to JAVA_HOME, written to the .bash_profile in the user's home directory or into / etc / profile in. To be configured by the following command.
echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile
Then let the configuration file to take effect.
source /etc/profile
Once configured, it is next activemq installation.
4, activeMq installation
ActiveMQ provides precompiled binaries for Unix systems, it can be used directly. The only dependency is JAVA installed on your system. Since we have a JAVA installed, we can further download ActiveMQ. You can always get the latest stable version from the official release of Apache ActiveMQ page. This version is installed using the following command to download 5.15.5.
wget http://archive.apache.org/dist/activemq/5.15.5/apache-activemq-5.15.5-bin.tar.gz
After the download is complete, we then decompress, to decompress the archive to the / opt directory.
sudo tar -zvxf apache-activemq-5.15.12-bin.tar.gz -C /opt
Next For convenience, you can create a soft link with version-independent, point to the directory where the current version of Apache ActiveMQ. This approach is helpful for future updates. In this case, the follow-up to install a new version, only need to modify the software connected to the corresponding version, do not upgrade every time a file is moved to all specified folder.
sudo ln -s /opt/apache-activemq-5.15.12/ /opt/activemq
Then After creating soft connection, we proceed to the next corresponding / opt / activemq directory, to boot mq. And view the boot state, as well as how to stop mq.
Although ActiveMQ can easily run the above command, but it is recommended to use ActiveMQ systemd services to manage the process. Use Systemd service will ensure that ActiveMQ is automatically started when the start-up and failure.
5, create a system service to start
To create a system service through the following command in the / usr / lib / systemd / system / activemq.service create a file.
south you /usr/lib/systemd/system/activemq.service
Enter the following to a file.
[Unit] Description=activemq message queue After=network.target [Service] PIDFile=/opt/activemq/data/activemq.pid ExecStart=/opt/activemq/bin/activemq start ExecStop=/opt/activemq/bin/activemq stop User=root Group=root Restart=always RestartSec=9 StandardOutput=syslog StandardError=syslog SyslogIdentifier=activemq [Install] WantedBy=multi-user.target
Been saved, then we can start to test to see if successful, and whether to stop.
sudo systemctl enable activemq sudo systemctl start activemq sudo systemctl status activemq sudo systemctl stop activemq
6, configuration via web show
After the installation is complete, start mq, mq then we can access the control panel through the web, in the address bar of the browser, type:http://xxxxxx:8161/admin.在访问之前得打开一下端口。通过以下命令。
sudo firewall-cmd --zone=public --permanent --add-port=8161/tcp sudo firewall-cmd --reload
Then we have to access it through a browser. The default user name and password is admin, you can be modified after entering.
Finally, I heard the above steps have been completed installation activemq.