Note
Create a user to run ActiveMQ
# useradd activemq
Create the required directories
# mkdir -p /var/log/activemq \
&& mkdir -p /var/lib/activemq ```
Download the ActiveMQ binary in advance or download it with the following command
# curl -LkvOf https://archive.apache.org/dist/activemq/5.15.11/apache-activemq-5.15.11-bin.tar.gz
Deploy
# tar zxvf apache-activemq-5.15.11-bin.tar.gz -C /opt/
Make a symbolic link
# ln -s /opt/apache-activemq-5.15.11 /opt/activemq
Change the output destination of the log file.
# vi /opt/activemq/conf/log4j.properties
:%s/${activemq.data}/\/var\/log\/activemq/g
# File appender
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.file=/var/log/activemq/activemq.log
log4j.appender.logfile.maxFileSize=1024KB
log4j.appender.logfile.maxBackupIndex=5
log4j.appender.logfile.append=true
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
###########
# Audit log
###########
log4j.additivity.org.apache.activemq.audit=false
log4j.logger.org.apache.activemq.audit=INFO, audit
log4j.appender.audit=org.apache.log4j.RollingFileAppender
log4j.appender.audit.file=/var/log/activemq/audit.log
log4j.appender.audit.maxFileSize=1024KB
log4j.appender.audit.maxBackupIndex=5
log4j.appender.audit.append=true
log4j.appender.audit.layout=org.apache.log4j.PatternLayout
log4j.appender.audit.layout.ConversionPattern=%-5p | %m | %t%n
Edit the configuration file
# vi /opt/activemq/bin/linux-x86-64/wrapper.conf
#******************************************************************** # Wrapper Properties #********************************************************************
#wrapper.debug=TRUE
set.default.ACTIVEMQ_HOME=../..
set.default.ACTIVEMQ_BASE=../..
set.default.ACTIVEMQ_CONF=%ACTIVEMQ_BASE%/conf
set.default.ACTIVEMQ_DATA=/var/lib/activemq #Change to the created directory
wrapper.working.dir=.
...
#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=/var/log/activemq/wrapper.log #Changed to place in the created directory
...
```
Partially changed environment variables
# vi /opt/activemq/bin/env
# Configure a user with non root privileges, if no user is specified do not change user
# (the entire activemq installation should be owned by this user)
ACTIVEMQ_USER="activemq" #Change to the created user
# location of the pidfile
ACTIVEMQ_PIDFILE="/opt/activemq/data/activemq.pid" #Changed to place in the created directory
Change the owner of various files to the execution user
# chown -R activemq:activemq /opt/activemq/ /var/log/activemq/ /var/lib/activemq/
Create a service file for ActiveMQ
```sh
# vi /etc/systemd/system/activemq.service
```
```service
[Unit]
Description=ActiveMQ message queue service
After=network.target
[Service]
User=activemq
Group=activemq
PIDFile=/opt/activemq/data/activemq.pid
ExecStart=/opt/activemq/bin/activemq start
ExecStop=/opt/activemq/bin/activemq stop
[Install]
WantedBy=multi-user.target
```
```sh
# systemctl daemon-reload \
&& systemctl start activemq ```
Recommended Posts