RabbitMQ 설치 방법
RabbitMQ 는 AMQP(Advanced Message Queuing Protocol) 를 지원하는 메시징 큐 브로커 입니다. 큐(Queue) 자료구조의 동작방법 그대로 서버로서 역활을 하도록 만든 서버 입니다.
RabbitMQ는 Erlang 이라는 언어로 작성되었습니다. 따라서 이 패키지가 설치되어 있어야 하는데,
별도의 tar ball 형태를 지원하지 않고, rpm 형태로 설치합니다.
1. EPEL(Extra Packages for Enterprise Linux) 설치하기
yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm |
2. Erlang 설치 (root 권한으로 실행)
yum install erlang |
3. RabbitMQ 설치
A. 설치 버전 Version : 3.6.6-1
B.
C. Download : https://www.rabbitmq.com/install-rpm.html
https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
D. 설치 Process
yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm |
4. RabbitMQ 설정
A. Data folder 생성
mkdir /ccdata/rabbitmq/dbfiles chown –R rabbitmq.rabbitmq /ccdata/rabbitmq/dbfiles
mkdir /ccdata/logs/platform/rabbitmq chown –R rabbitmq.rabbitmq /ccdata/logs/platform/rabbitmq |
B. Rabbitmq Configuration
vi /etc/rabbitmq/rabbitmq-env.conf |
#rabbitmq-env.conf #Host Name HOSTNAME=cl-xxx-linux01 #Node Name NODENAME=rabbit@cl-xxx-linux01 RABBITMQ_NODE_PORT=5672 RABBITMQ_MNESIA_BASE=/ccdata/rabbitmq/dbfiles RABBITMQ_LOG_BASE=/ccdata/logs/platform/rabbitmq |
5. RabbitMQ 기동 / 중지
A. service rabbitmq-server start / stop / status
6. Management plugin 설치
A. rabbitmq-plugin list
B. rabbitmq-plugins enable rabbitmq_management
7. RabbitMQ Admin 설치
A. Download rabbitmqadmin
cd /usr/local/bin/ wget http://127.0.0.1:15672/cli/rabbitmqadmin chmod 755 rabbitmqadmin |
8. Exchange & Queue 생성 Script
A. vi rabbitmq-init.sh
sleep 5
# Permission chown -R rabbitmq.rabbitmq /ccdata/logs/platform/rabbitmq chown -R rabbitmq.rabbitmq /ccdata/rabbitmq
# Plugin install rabbitmq-plugins enable rabbitmq_management
# Create user rabbitmqctl add_user rabbitmq rabbitxxxx rabbitmqctl set_user_tags rabbitmq administrator rabbitmqctl set_permissions -p / rabbitmq ".*" ".*" ".*"
rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all"}'
# Install rabbitmqadmin cd /usr/local/bin/ wget http://127.0.0.1:15672/cli/rabbitmqadmin chmod 775 rabbitmqadmin mv rabbitmqadmin /usr/local/bin
# Insert init data # make exchange ./rabbitmqadmin delete exchange name=File.Processing ./rabbitmqadmin declare exchange name=File.Processing type=direct
#make Queue ./rabbitmqadmin declare queue name=File.DocConvertQueue durable=true # make relation exchange & queue ./rabbitmqadmin declare binding source=File.Processing destination_type=queue destination=File.DocConvertQueue routing_key=all
rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all"}'
|
B. chmod 755 rabbitmq-init.sh
C. ./rabbitmq-init.sh
D. Running 상태 확인
i. rabbitmqctl status
9. Rabbitmq Clustering
A. /etc/host에 server, host 등록
B. cookie 복제 (1번 서버 vi.erlang.cookie 내용을 2번 서버에 복제
(/var/lib/rabbitmq/.erlang.cookie)
C. 2번 서버에서 실행
rabbitmqctl stop_app rabbitmqctl join_cluster rabbit@cl-xxx-linux2 rabbitmqctl start_app |
10.
[참조]
http://linux.systemv.pe.kr/centos-7-rabbitmq-%EC%84%A4%EC%B9%98/
https://dl.fedoraproject.org/pub/epel/7/x86_64/e/
https://www.rabbitmq.com/download.html
https://www.rabbitmq.com/install-rpm.html