개발일기

RabbitMQ - 설치 및 계정 사용법 본문

Messaging Broker/RabbitMQ

RabbitMQ - 설치 및 계정 사용법

Flashback 2023. 3. 1. 18:36
728x90
반응형

1. erlang설치

RabbitMQ는 erlang이라는 언어로 만들어졌기에 먼저 erlang을 설치해야 한다.

wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm

rpm -Uvh erlang-solutions-2.0-1.noarch.rpm

yum install erlang -y

wget을 통해 erlang 패키지를 다운로드 한 후, erlang을 설치한다.

 

2. RabbitMQ 설치

wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.8/rabbitmq-server-3.8.8-1.el6.noarch.rpm

wget으로 RabbitMQ 패키지를 다운로드한다.

 

rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc

Signing key를 추가해준다. 다운로드한 패키지를 신뢰할 수 있도록 하는 키로써, 이를 통해 패키지 설치를 진행할 수 있다.

 

rpm -Uvh rabbitmq-server-3.8.8-1.el6.noarch.rpm

최종적으로 RabbitMQ를 설치한다.

 

2-1. 에러

error: Failed dependencies:
        socat is needed by rabbitmq-server-3.8.8-1.el6.noarch

설치를 진행할 때, 위와 같은 에러가 발생할 수 있다. 이 경우는 socat을 설치하여 해결할 수 있다.

 

yum install socat -y

 

3. RabbitMQ 동작

RabbitMQ 설치를 완료한 후, nginx와 php-fpm과 같이 systemctl을 통해 프로세스를 시작 및 중지할 수 있다.

systemctl restart rabbitmq-server # rabbitmq 재시작

systemctl stop rabbitmq-server # rabbitmq 종료

 

4. Managetment UI 활성화

RabbitMQ가 제공하는 Management UI를 통해 연결과 메시지를 관리할 수 있다.

 

rabbitmq-plugins enable rabbitmq_management
# ui 활성화

이 명령어를 통해 Management UI를 활성화시키면 기본 15672 포트를 통해 해당 관리 페이지에 접속할 수 있다.

만약 로컬에 RabbitMQ를 설치 한 후, 관리 페이지에 접속하려면 localhost:15672를 통해 접속할 수 있다. 또한, 관리 페이지에 접속하려면 먼저 RabbitMQ 서비스가 시작된 상태여야 접속할 수 있다.

 

5. RabbitMQ 계정 관리

처음 설치하면 guest/guest로 로그인하여 사용할 수 있다. 모든 사람들이 사용할 수 있기에 guest 계정은 삭제 후, 따로 계정을 생성하여 사용하는 것이 추천된다.

 

5-1. 계정 추가

# rabbitmqctl add_user [계정명] [비밀번호]

rabbitmqctl add_user fruit 1234
# fruit이라는 계정을 생성하고 비밀번호는 1234로 지정한다

5-2. 계정 태그 추가

계정에 태그를 추가하여 태그별 역할을 부여할 수 있다. 역할의 종류에는 management, policymaker, monitoring, administrator가 있다. administrator는 말그대로 모든 역할을 수행할 수 있다.

# rabbitmqctl set_user_tags [계정명] [태그명]

rabbitmqctl set_user_tags fruit administrator
# fruit이라는 계정에 administrator라는 태그를 부여한다.
  • management : queue와 extension를 확인할 수 있다.
  • policymaker : management의 역할에 더해 virtual host관련 정책을 생성 및 삭제할 수 있다.
  • monitoring : management의 역할에 더해 다른 사용자의 mq 연결을 확인할 수 있다.
  • administrator : 모든 역할을 수행할 수 있다.즉, 위의 3 태그의 역할을 종합한 것이다.

5-3. 계정 권한 부여

메시지를 consume, publish 등 할 수 있는 권한을 부여할 수 있다.

# rabbitmqctl set_permissions -p / [계정명] ".*" ".*" ".*"
# 계정명 뒤에 붙은 ""를 통해 순서대로 configure, write, read 권한 부여 여부를 결정할 수 있다.

rabbitmqctl set_permissions -p / fruit ".*" ".*" ".*"
# fruit이라는 계정에 configure, write, read할 수 있는 권한을 부여한다.
  • 첫번째 configure : queue, extension 등을 생성할 수 있다.
  • 두번째 write : queue를 publish 할 수 있다.
  • 세번째 read : queue를 consume 할 수 있다.
  • ".*"라 입력하면 해당 섹션에 위치한 권한을 부여받는다. 만약 빈 공백을 가진 ""를 입력하면 해당 섹션에 위치한 권한은 부여하지 않는다.

5-4. 계정 삭제

# rabbitmqctl delete_user [계정명]

rabbitmqctl delete_user fruit
# fruit이라는 계정을 삭제한다.

 


참고 사이트 : 

https://www.rabbitmq.com/download.html

 

Downloading and Installing RabbitMQ — RabbitMQ

Downloading and Installing RabbitMQ The latest release of RabbitMQ is 3.11.9. See change log for release notes. See RabbitMQ support timeline to find out what release series are supported. Experimenting with RabbitMQ on your workstation? Try the community

www.rabbitmq.com

 

https://www.rabbitmq.com/management.html

 

Management Plugin — RabbitMQ

Management Plugin The RabbitMQ management plugin provides an HTTP-based API for management and monitoring of RabbitMQ nodes and clusters, along with a browser-based UI and a command line tool, rabbitmqadmin. It periodically collects and aggregates data abo

www.rabbitmq.com

 

https://www.rabbitmq.com/access-control.html

 

Authentication, Authorisation, Access Control — RabbitMQ

Authentication, Authorisation, Access Control This document describes authentication and authorisation features in RabbitMQ. Together they allow the operator to control access to the system. Different users can be granted access only to specific virtual ho

www.rabbitmq.com

 

https://gist.github.com/fernandoaleman/fe34e83781f222dfd8533b36a52dddcc

 

Install RabbitMQ on CentOS 7

Install RabbitMQ on CentOS 7. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

https://www.shellhacks.com/rabbitmq-list-create-users-rabbitmqctl/

 

RabbitMQ: List | Create Users - Rabbitmqctl - ShellHacks

How to list, create, set permissions and delete RabbitMQ users from the command-line using the `rabbitmqctl` command.

www.shellhacks.com

 

https://computingforgeeks.com/installing-rabbitmq-on-centos-6-centos-7/

 

728x90
반응형
Comments