aws에서 Rabbitmq를 클러스터링하는 방법

aws에서 Rabbitmq를 클러스터링하는 방법

AWS 환경에서 Rabbitmq를 클러스터링하기 위해 가능한 모든 조합을 시도했습니다. 그러나 요약하자면:

  1. 내 로컬 우분투 14에서 Erlang 및 Rabbit 배포판을 종료하고 제거했습니다.
  2. 웹에서 자동 구성 모듈을 사용해 보았습니다.
  3. 기본적으로 설치된 우분투 14 버전은 문제가 되지 않습니다.
  4. Erlang 쿠키가 일치합니다. 아래에 설명되어 있습니다.

호스트 이름 불일치가 유일한 퍼즐입니다. 노드 자체는 호스트 이름이 각각 'q1' 또는 'q2'라고 생각합니다. 컨테이너의 호스트 이름을 호스트의 개인 DNS 이름으로 설정하려고 하면(다른 노드에 연결할 수 있음) 컨테이너의 토끼 인스턴스가 충돌합니다. 아래는 hostname생산 방법이 아니지만 q2Amazon 개인 DNS에 껍질을 벗겼습니까?

root@q2:~# hostname
q2
root@q2:~# exit
christian@q2:~$ logout
Connection to ip-10-0-3-101.us-west-2.compute.internal closed.

최신 RabbitMQ 도커 이미지를 사용하고 있습니다.

docker run -d --restart always --hostname q1 --name rabbitmq -p 4369:4369 -p 15671:15671 -p 25672:25672 -p 15672:15672 -p 5672:5672 -e RABBITMQ_HIPE_COMPILE=1 -e RABBITMQ_ERLANG_COOKIE='ilikecookies' rabbitmq:3-management

서비스가 잘 시작됩니다

root@q1:~# curl -I localhost:15672
HTTP/1.1 200 OK
Content-Length: 1419
Content-Type: text/html
Date: Fri, 20 Jan 2017 22:46:12 GMT
last-modified: Fri, 20 Jan 2017 22:38:45 GMT
Server: MochiWeb/1.0 (Any of you quaids got a smint?)

그리고 여기 q1 호스트의 쿠키가 있습니다.

root@q1:~# docker exec -it rabbitmq /bin/bash
root@q1:/# cat /var/lib/rabbitmq/.erlang.cookie                                                                               
ilikecookies
root@q1:/# 

이제 클러스터링을 시도합니다(q1이 마스터인 호스트 q2에서).

root@q2:~# docker exec -it rabbitmq /bin/bash
root@q2:/# rabbitmqctl stop_app
Stopping node rabbit@q2 ...
root@q2:/# rabbitmqctl join_cluster [email protected]
Clustering node rabbit@q2 with '[email protected]' ...
Error: unable to connect to nodes ['[email protected]']: nodedown

DIAGNOSTICS
===========

attempted to contact: ['[email protected]']

[email protected]:
  * connected to epmd (port 4369) on ip-10-0-3-56.us-west-2.compute.internal
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed
  * suggestion: hostname mismatch?
  * suggestion: is the cookie set correctly?
  * suggestion: is the Erlang distribution using TLS?

current node details:
- node name: 'rabbitmq-cli-41@q2'
- home dir: /var/lib/rabbitmq
- cookie hash: quN0y0GUm2Zxv8VYc2eX9A==

root@q2:/# cat /var/lib/rabbitmq/.erlang.cookie
ilikecookies
root@q2:/# 

질문이러한 것들을 어떻게 클러스터링합니까? 누락된 성분은 무엇입니까? 오류 메시지는 웹에서는 아무 의미가 없습니다. 누구든지 이것에 대한 경험이 있습니까?

업데이트 다음 인스턴스에 대한 AWS 보안 그룹:

Custom TCP Rule
TCP
1024 - 65535
0.0.0.0/0

답변1

알겠습니다. 알겠습니다!

각 노드의 호스트 이름은 컨테이너 내부에 정렬되어야 합니다.

호스트 머신(q2)의 호스트 파일에서 어떤 호스트를 알고 있는지 확인했습니다.

# This file was generated by OpsWorks
# any manual changes will be removed on the next update.

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

# OpsWorks Layer State
127.0.0.1 localhost.localdomain localhost
127.0.1.1 q2.localdomain q2

10.0.3.56 q1.localdomain q1
10.0.3.101 q2.localdomain q2


root@q2:/# ping q1
PING q1.local (10.0.3.56): 56 data bytes
^C--- q1.local ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

그러다가 호스트 머신이 무엇을 알고 있는지는 전혀 중요하지 않고 도커 컨테이너가 무엇을 알고 있는지가 중요하다는 생각이 들었습니다. 그래서 저는 컨테이너에 들어가 같은 작업을 수행했습니다.

root@q2:/# cat /etc/hosts
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2  q2.local

이제 우리는 뭔가를 진행 중입니다! 그래서 노드 마스터에 대한 항목을 추가했습니다.

root@q2:/# echo "10.0.3.56    q1.local q1" >> /etc/hosts
root@q2:/# which ping
/bin/ping
root@q2:/# ping q1
PING q1.local (10.0.3.56): 56 data bytes

그리고 컨테이너 안에서 또 한 번 스윙을 했습니다.

root@q2:/# rabbitmqctl stop_app
Stopping node rabbit@q2 ...
root@q2:/# rabbitmqctl join_cluster rabbit@q1                                     
Clustering node rabbit@q2 with rabbit@q1 ...
root@q2:/#

이제 각 노드는 클러스터링되었음을 인식합니다! 우웩!

나는 docker를 사용한 클러스터링을 위해 docker 명령을 수정하여 호스트 /etc/hosts파일을 docker 이미지에 마운트할 것이라고 생각합니다. -v /etc/hosts:/etc/hosts:ro그러면 이것이 마술처럼 작동해야 합니다.

제가 언급하는 것을 잊은 또 다른 단계: 로컬 우분투 상자에는 제거해야 했던 고대 버전의 erlang이 실행되어 있었습니다(그리고 토끼도 있었습니다).

관련 정보