安装Apache ActiveMQ

记事本 (jì shì

前提

    Java がインストール済みである

步骤

    1. 创建ActiveMQ的执行用户

# useradd activemq

创建必要的目录

# mkdir -p /var/log/activemq /var/lib/activemq

预先下载ActiveMQ二进制文件,或使用以下命令进行下载

# curl -LkvOf https://archive.apache.org/dist/activemq/5.15.14/apache-activemq-5.15.14-bin.tar.gz

解压文件

# tar zxvf apache-activemq-5.15.14-bin.tar.gz -C /opt/

创建符号链接

# ln -s /opt/apache-activemq-5.15.14 /opt/activemq

更改日志文件的输出位置

# vi /opt/activemq/conf/log4j.properties

执行vim命令
:%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

编辑配置文件

# 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 #更改为创建的目录
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 #放置在创建的目录中

更改环境变量的一部分

# 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” #更改为创建的用户

# location of the pidfile
ACTIVEMQ_PIDFILE=”/opt/activemq/data/activemq.pid” #放置在创建的目录中

将各种文件的所有者更改为执行用户

# chown -R activemq:activemq /opt/activemq/ /var/log/activemq/ /var/lib/activemq/

创建ActiveMQ服务文件

# vi /etc/systemd/system/activemq.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

加载服务文件并启动

# systemctl daemon-reload \
&& systemctl start activemq

请提供以下内容的中国本土人的表述:
参考

    Introduction – Using ActiveMQ > Getting Started
广告
将在 10 秒后关闭
bannerAds