4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Apache ActiveMQ のインストール

Last updated at Posted at 2020-03-14

メモ

前提

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

手順

  1. ActiveMQ の実行用ユーザを作成する

    # useradd activemq
    
  2. 必要なディレクトリを作成する

    # mkdir -p /var/log/activemq /var/lib/activemq
    
  3. ActiveMQ のバイナリをあらかじめダウンロードしておくか、次のコマンドでダウンロードする

    # curl -LkvOf https://archive.apache.org/dist/activemq/5.15.14/apache-activemq-5.15.14-bin.tar.gz
    
  4. 展開する

    # tar zxvf apache-activemq-5.15.14-bin.tar.gz -C /opt/
    
  5. シンボリックリンクをはっておく

    # ln -s /opt/apache-activemq-5.15.14 /opt/activemq
    
  6. ログファイルの出力先を変更します。

    # 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
    
  7. 設定ファイルを編集

    # 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  #作成したディレクトリ内に配置するように変更

...
```
  1. 環境変数を一部変更

    # 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" #作成したディレクトリ内に配置するように変更
    
  2. 各種ファイルなどの所有者を実行用ユーザに変更する

    # chown -R activemq:activemq /opt/activemq/ /var/log/activemq/ /var/lib/activemq/
    
  3. 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
    
  4. サービスファイルを読み込んで起動する

    # systemctl daemon-reload \
    

&& systemctl start activemq
```

参考

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?