RabbitMQ - Join_Cluster - no function clause matching - rabbitmq

I have 2 RabbitMQ servers and trying to cluster as per this link https://haptik.ai/tech/rabbitmq-cluster-failover/. Done all the required settings in server1 and in the server2 when i execute the below statement. I am getting the error
rabbitmqctl join_cluster rabbit#server1.domain.com
Please find below the detailed error message
Clustering node rabbit#INCHNACCWAS01 with rabbit#server1.domain.com
** (FunctionClauseError) no function clause matching in RabbitMQCtl.format_error/3
The following arguments were given to RabbitMQCtl.format_error/3:
# 1
{:badmatch, {:error, {:node_name, :short}}}
# 2
%{disc: false, longnames: false, node: :rabbit#INCHNACCWAS01, ram: false, timeout: :infinity}
# 3
RabbitMQ.CLI.Ctl.Commands.JoinClusterCommand
(rabbitmqctl) lib/rabbitmqctl.ex:367: RabbitMQCtl.format_error/3
(rabbitmqctl) lib/rabbitmqctl.ex:124: anonymous fn/5 in RabbitMQCtl.exec_command/2
(rabbitmqctl) lib/rabbitmqctl.ex:45: RabbitMQCtl.main/1
(elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2

This is a known bug in that version of RabbitMQ. Please upgrade to the latest version.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

You can use rabbitmqctl status for more information.
[root#node1 ~]# rabbitmqctl status
Status of node rabbit#node1 ...
Which means you current node name is node1, and you should use
rabbitmqctl join_cluster rabbit#node1 command. Sometimes the RABBITMQ nodename is NOT the same as HOSTNAME.
According to this method, you can doublecheck EXACT node name of both this and target instance and then create correct adding-cluster command.

When I used
rabbitmqctl join_cluster rabbit#ip
I got this error,then I use
rabbitmqctl join_cluster rabbit#hostname
the problem sloved.Maybe you could use hostname.

Related

RabbitMQ cluster on a single machine

I want to create a three node RabbitMQ cluster on a single RHEL8 machine for testing purposes. I tried instructions given in RabbitMQ official guide and also tried to follow this guide.
The first node works fine and it's running. However, the second node cannot be started and throws up an error.
I used below commands as mentioned in the guide.
RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit rabbitmq-server -detached
RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=hare rabbitmq-server -detached
rabbitmqctl -n hare stop_app
This command throws up below error.
DIAGNOSTICS
attempted to contact: [hare#localhost]
hare#localhost:
connected to epmd (port 4369) on localhost
epmd reports: node 'hare' not running at all
other nodes on localhost: [rabbit]
On further inspection of logs, it seems like that this node tries to use the same ports used by the first node (e.g. MQTT port 1883).
I think I might have to use the other option of declaring /etc/rabbitmq/rabbitmq.conf. Mainly because it seems to give more options to change ports etc.
A sample config file resembling the one needed in my case or a link to a proper guide is highly appreciated.
You didn't specify, but you must have the MQTT plugin enabled for there to be a conflict on that port, correct?
The easiest work-around would be to have two configuration files specifying different ports for MQTT, AMQP and anything else. Then, use the RABBITMQ_CONFIG_FILE environment variable to point to the appropriate file:
RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit0 \
RABBITMQ_CONFIG_FILE=/path/to/rabbitmq-0.conf rabbitmq-server -detached
RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=rabbit1 \
RABBITMQ_CONFIG_FILE=/path/to/rabbitmq-1.conf rabbitmq-server -detached
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Health checks for rabbitmq

What kind of health checks can be configured for rabbitmq in openshift?
I wasn't able to configure rabbitmqctl as suggested in [1] or [2] as it delivers errors when used with the images registry.centos.org/centos/rabbitmq or luiscoms/openshift-rabbitmq
Example:
$ rabbitmqctl cluster_status
Error: could not recognise command
...
Only root or rabbitmq should run rabbitmqctl
[1] https://github.com/docker-library/rabbitmq/pull/174#issuecomment-452002696
[2] https://github.com/rabbitmq/rabbitmq-peer-discovery-k8s/blob/master/examples/k8s_statefulsets/rabbitmq_statefulsets.yaml

Can't enable rabbitmq-management plugin on Windows 7

I had installed Erlang and RabbitMQ. After I started RabbitMQ service. All those step were done without errors. But when I ran: C:...\rabbitmq-server-3.5.6\sbin>rabbitmq-plugins.bat enable rabbitmq_management
I got following error:
Applying plugin configuration to rabbit#AZE-PC05478... failed. *
Could not contact node rabbit#AZE-PC05478. Changes will take effect
at broker restart. * Options: --online - fail if broker cannot be
contacted.
--offline - do not try to contact broker.
I copied .erlang.cookie from /Windows to C:. But I still have the same result.
Is anything I missed? Thank you for help.
More infos: When I added : rabbitmqctl.bat status. I got:
Status of node 'rabbit#AZE-PC05478'
Error: unable to connect to node 'rabbit#AZE-PC05478': nodedown
DIAGNOSTICS
===========
attempted to contact: ['rabbit#AZE-PC05478']
rabbit#AZE-PC05478:
* connected to epmd (port 4369) on AZE-PC05478
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* Authentication failed (rejected by the remote node), please check the Erlang cookie
current node details:
- node name: 'rabbitmq-cli-74#AZE-PC05478'
- home dir: C:\
- cookie hash: 1jjD3t2FUFyx/xXyPe0s4w==
On Windows, RabbitMQ had issues with hostnames being reported sometimes in lowercase, sometimes in uppercase, and this doesn't play well with Erlang distribution.
It was fixed in RabbitMQ 3.6.0:
https://github.com/rabbitmq/rabbitmq-server/commit/1fb451090a2557f35a2800f9d04c476ff1ad6a22
I suppose you're hitting this problem, because the output of rabbitmqctl shows that RabbitMQ is running:
epmd reports node 'rabbit' running on port 25672
It's just that rabbitmqctl fails to contact it. You can check this by specifying the lowercase version of your node name on rabbitmqctl command line:
rabbitmqctl -n rabbit#aze-pc05478 status

Create vHost on Windows RabbitMQ node using command line

I have a RabbitMQ node on windows operating system. I want to create vhost on that node from command line of using a script with minimal pre-requisites.
EDIT: I tried to use the rabbitmqctl add_vhost but I always get an error.
rabbitmqctl add_vhost my_vhost
and
rabbitmqctl set_permissions -p my_vhost guest ".*" ".*" ".*"
I suggest to read this: https://www.rabbitmq.com/man/rabbitmqctl.1.man.html
So you have another error, about the node down read here
RabbitMQ has Nodedown Error

rabbtimqadmin - Could not connect: [Errno -2] Name or service not known

I have RabbitMQ installed on a CentOS 5.x server which I use for message passing between my programs. I've installed rabbitmqadmin following the directions on https://www.rabbitmq.com/management-cli.html and have used it on my servers in the past.
From what I can tell it looks like this particular server is misconfigured. My web-searches have failed me on trying to get more information on how to troubleshoot this issue.
The error:
[root#server ~]# python26 /usr/local/bin/rabbitmqadmin list nodes
*** Could not connect: [Errno -2] Name or service not known
[root#server ~]#
I have tried several different rabbitmqadmin commands and they give the same result. If I run the command without the extra params it displays the normal help dialog. I have this setup and working on several other servers.
Any idea on what the root issue is? If not, anyway to get more details, like verbose?
Update:
I just tried to check the version of rabbitmq and its yielding an error too:
[root#server ~]# rabbitmqctl status
Status of node rabbit#server ...
Error: unable to connect to node rabbit#server: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit#server]
rabbit#server:
* connected to epmd (port 4369) on server
* epmd reports node 'rabbit' running on port 25672
* TCP connection succeeded but Erlang distribution failed
* suggestion: hostname mismatch?
* suggestion: is the cookie set correctly?
current node details:
- node name: rabbitmqctl25451#server
- home dir: /var/lib/rabbitmq
- cookie hash: WXaeZT7XXm13naagfRX5cg==
[root#server ~]#
I'm going to see if I can find something from this... I find this weird because the server is passing messages fine and can be monitored through the web console.
Erlang version:
[root#server rabbitmq]# erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
"R14B04"
[root#server rabbitmq]#
Rabbitmq Version:
[root#server rabbitmq]# python26 /usr/local/bin/rabbitmqadmin --version
rabbitmqadmin 3.3.5
[root#server rabbitmq]#
After much digging and frustration, I found my problem... I'm posting the solution in case anyone else has a similar experience
Previously, I found that if you setup RabbitMQ on a linux server then change the hostname that it can break some of the rabbit configuration.
The awesome part about this problem is that someone changed the name of the server from all capital letters to lowercase...
I've solve this one of two ways:
Solution 1:
Revert the host name back to the previous name. So that rabbitmq references with the appended server name work again.
Solution 2:
If you want to keep the server name change, then you can create a rabbitmq-env.conf files in /etc/rabbitmq like:
NODENAME=rabbit#OLDHOSTNAME
If you aren't sure what your previous name was, you can reference it by doing an ls in your /var/lib/rabbitmq/mnesia/ folder. You'll then see a folder that matches the nodename you need to specify.
Reference: https://www.rabbitmq.com/man/rabbitmq-env.conf.5.man.html
UPDATE:
Host name is CaSE SeNSiTIve... had someone change a hostname on me and the only difference was the case... so took a while to notice...
Yesterday I've lost a few hours with this same problem and it was in a fresh install, so the problem was that the erlang cookie from my user and root user was different than the one from rabbitmq user.
Find out the HOME for the user rabbitmq:
# cat /etc/passwd | grep rabbitmq
Check if the cookies differs from each other:
# vimdiff /var/lib/rabbitmq/.erlang.cookie ~/.erlang.cookie
If they are different, copy the cookie from rabbitmq for the user that you want to have access to the server:
# cp /var/lib/rabbitmq/.erlang.cookie ~/.erlang.cookie
References:
rabbitmqctl status says "TCP connection succeeded but Erlang distribution failed"
How Nodes (and CLI tools) Authenticate to Each Other: the Erlang Cookie