発生した問題
RabbitMQをインストールし、起動まではうまく行ったが、ユーザー追加の処理でエラーが発生した。
[手順]
- RabbitMQ公式ドキュメントを元にerlang, RabbitMQをインストールした
インストール先: Downloading and Installing RabbitMQ — RabbitMQ
C:\Program Files\RabbitMQ Server\rabbitmq_server-xxx\sbin
に移動し、add_userコマンドを実行したが、エラーが出てユーザー追加できなかった。
$ rabbitmqctl.bat add_user username password
ログを見てみると...
その時でたログはこんな感じ。
Error: unable to perform an operation on node 'rabbit@xxxx'. Please see diagnostics information and suggestions below. Most common reasons for this are: - Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues) - CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server) - Target node is not running In addition to the diagnostics info below: - See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more - Consult server logs on node rabbit@xxxx ### DIAGNOSTICS attempted to contact: [rabbit@xxxx] rabbit@xxxx: - connected to epmd (port 4369) on xxxx - epmd reports node 'rabbit' uses port 43253 for inter-node and CLI tool traffic - TCP connection succeeded but Erlang distribution failed - Authentication failed (rejected by the remote node), please check the Erlang cookie Current node details: - node name: rabbitmqxxx@xxxx - effective user's home directory: C:\Users\xxx - Erlang cookie hash: xxxxxxxxxx
なんだか色々書いててよくわからん...けど、気になったのはこの部分
TCP connection succeeded but Erlang distribution failed
TCP通信には成功したけど、Erlangのディストリビューションに失敗した? なんか、RabbitMQ自体ではなくErlangに問題がありそう...
そして、次の行にこんなことが書いている。
Authentication failed (rejected by the remote node), please check the Erlang cookie
原因と解決方法
RabbitMQのページを読み込んでみるとこんな記述が。
If the Windows service is used, the cookie should be copied from C:\Windows\system32\config\systemprofile.erlang.cookie to the expected location for users running commands like rabbitmqctl.bat.
Windowsを使用している場合は、CookieをC:\Windows\system32\config\systemprofile\.erlang.cookie
からコマンドを実行するユーザーが参照できる場所にコピーする必要があるらしい。
ただ、ユーザーフォルダの直下とadminフォルダの直下をそれぞれ確認してみたけど、.erlang.cookie
自体は既に存在している...どうやら、必要な場所にcookie自体はあるんだけれども、各所のcookieが異なっていることが問題みたい。
というわけで、下記の手順を踏んだところ問題が解消されました。
[手順]
- C:\Windows\system32\config\systemprofile.erlang.cookie をコピーして、下記の場所にペースト。
- C:\Users\現在使用中のユーザーフォルダ
- C:\Users\admin
- rabbitmqのサービスを再起動する