Specify RabbitMQ node name to use your own prefix or particular hostname.

Prefix can be anything within reason, but hostname part needs to be resolvable from all cluster nodes. Node names in a cluster must be unique.

Edit /etc/rabbitmq/rabbitmq-env.conf to alter default settings for RabbitMQ AMQP server.
I will modify RABBITMQ_LONGNAME and RABBITMQ_NODENAME variables,
but notice that I will skip RABBITMQ_ part as it is not required in configuration file and clearly obvious.

Default node name

Use hostname utility to display short hostname.

$ hostname
buster

Default environment configuration file.

$ cat /etc/rabbitmq/rabbitmq-env.conf
# Defaults to rabbit. This can be useful if you want to run more than one node
# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
# combination. See the clustering on a single machine guide for details:
# http://www.rabbitmq.com/clustering.html#single-machine
#NODENAME=rabbit
# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if
# available. Set this if you only want to bind to one network interface or#
# address family.
#NODE_IP_ADDRESS=127.0.0.1
# Defaults to 5672.
#NODE_PORT=5672

Default node name consists of rabbit prefix and short hostname.

$ sudo rabbitmqctl eval "node()."
rabbit@buster

Use long hostname

Use hostname utility to display long hostname.

$ hostname --long
buster.localdomain

Set RABBITMQ_USE_LONGNAME variable to true.

$ cat /etc/rabbitmq/rabbitmq-env.conf
# Defaults to rabbit. This can be useful if you want to run more than one node
# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
# combination. See the clustering on a single machine guide for details:
# http://www.rabbitmq.com/clustering.html#single-machine
#NODENAME=rabbit
# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if
# available. Set this if you only want to bind to one network interface or#
# address family.
#NODE_IP_ADDRESS=127.0.0.1
# Defaults to 5672.
#NODE_PORT=5672
USE_LONGNAME=true

Restart rabbitmq-server.

$ sudo systemctl restart rabbitmq-server

Verify that current node name uses long hostname.

$ sudo rabbitmqctl eval "node()."
'rabbit@buster.localdomain'

Use custom prefix

Set RABBITMQ_NODENAME to define prefix, but skip hostname part.

$ cat /etc/rabbitmq/rabbitmq-env.conf
# Defaults to rabbit. This can be useful if you want to run more than one node
# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
# combination. See the clustering on a single machine guide for details:
# http://www.rabbitmq.com/clustering.html#single-machine
NODENAME=fox
# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if
# available. Set this if you only want to bind to one network interface or#
# address family.
#NODE_IP_ADDRESS=127.0.0.1
# Defaults to 5672.
#NODE_PORT=5672

Restart rabbitmq-server.

$ sudo systemctl restart rabbitmq-server

Verify that current node name uses specified prefix.

$ sudo rabbitmqctl eval "node()."
fox@buster

Do not set RABBITMQ_USE_LONGNAME variable as it will prevent RabbitMQ from starting, because it will append short hostname to node name.

2019-09-09 21:10:53.258 [info] <0.43.0> Application rabbit exited with reason: {{failed_to_cluster_with,[fox@buster],"Mnesia could not connect to any nodes."},{rabbit,start,[normal,[]]}}

Use custom node name

Set RABBITMQ_NODENAME to define prefix and hostname part.

$ cat /etc/rabbitmq/rabbitmq-env.conf
# Defaults to rabbit. This can be useful if you want to run more than one node
# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
# combination. See the clustering on a single machine guide for details:
# http://www.rabbitmq.com/clustering.html#single-machine
NODENAME=fox@localhost
# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if
# available. Set this if you only want to bind to one network interface or#
# address family.
#NODE_IP_ADDRESS=127.0.0.1
# Defaults to 5672.
#NODE_PORT=5672

Restart rabbitmq-server.

$ sudo systemctl restart rabbitmq-server

Verify that current node name uses specified prefix and hostname.

$ sudo rabbitmqctl eval "node()."
fox@localhost

Using localhost will prevent clustering from working, because distinct servers needs to exchange data between each other using node names.

Hostname part needs to be resolvable, it will prevent RabbitMQ from starting if it is not.

ERROR: epmd error for host nonexistent.domain: nxdomain (non-existing domain)