Apache ActiveMQ 설치 및 서비스 등록 간단 설정.

2023. 12. 4. 16:03개인노트

반응형

ActiveMQ, RabbitMQ, Kafka 등 여러가지 선택지가 존재하므로 자세한 내용은 다음 블로그에 잘 설명이 되어있다.

https://twowinsh87.github.io/etc/2018/08/07/etc-kafka-8/

 

[Kafka]Kafka vs RabbitMQ vs ActiveMQ

이 글은 카프카, 데이터 플랫폼의 최강자 고승범/공용준 님의 책을 공부하며 정리하는 글입니다.

twowinsh87.github.io

 

현 회사의 서버환경에서 API간의 통신이 많아지면서 MQ가 도입되어있다고 한다.

신규 환경 구성을 잡을경우 ActiveMQ를 설치해야 할 일이 발생할테니 해당부분에 대해서 간략하게 확인 및 설치 테스트를 해 보았다.(+port및 환경설정)

 

ActiveMQ 5.15.15버전을 기준으로 설치했다.

1. 파일다운로드 및 압축해제

wget https://archive.apache.org/dist/activemq/5.15.15/apache-activemq-5.15.15-bin.tar.gz
tar -xzf apache-activemq-5.15.15-bin.tar.gz

2.ActiveMQ를 간단하게 모니터링 할 수 있는 어드민페이지를 제공한다.

users.properties에서 어드민 정보를 확인 할 수 있다.  만약 여기를 사용하는경우 특정 IP만 접근가능하도록 하거나 보안상의 관리를 잘 처리해야한다.

 

3. 기본 통신포트 설정

압축을 해제한 activemq 내부 conf 폴더의 activemq.xml 파일내부에 port를 수정하면된다.(아래는 기본포트 및 기본설정)

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

4. 어드민 포트번호를 변경하고자 한다면

압축을 해제한 activemq 내부 conf 폴더의 jetty.xml 파일내부에 port를 수정하면된다.(아래는 기본포트 및 기본설정)

<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
     <!-- the default port number for the web console -->
    <property name="host" value="0.0.0.0"/>
    <property name="port" value="8161"/>
</bean>

5. 서비스 등록 전 activemq용 사용자 등록

sudo groupadd activemq
sudo useradd -M -s /bin/nologin -g activemq -d /usr/local/activemq activemq
sudo chown -R activemq:activemq /usr/local/activemq

 

6. 서비스 파일 생성

vi /etc/systemd/system/activemq.service

파일 내용

[Unit]
Description=Apache ActiveMQ
After=network.target
[Service]
Type=forking
User=activemq
Group=activemq
 
ExecStart=/usr/local/activemq/bin/activemq start
ExecStop=/usr/local/activemq/bin/activemq stop
 
[Install]
WantedBy=multi-user.target

 

7. 서비스 등록 및 실행

sudo systemctl daemon-reload
sudo systemctl enable activemq
sudo systemctl start activemq
sudo systemctl stop activemq
sudo systemctl status activemq

 

반응형