summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Lazu <gerhard@users.noreply.github.com>2019-08-12 17:59:23 +0100
committerGitHub <noreply@github.com>2019-08-12 17:59:23 +0100
commit2845f4eeedbbf17394e29e9eef9f6b52481cf79a (patch)
treef81879271ca73462dcba9c01a5e5fefc96a16647
parentf47a339b8e528eaaa8b84e5be146a92ee687b99f (diff)
parent107bd08a1222d47bcf81891d832cb1fd039cb25b (diff)
downloadrabbitmq-server-git-2845f4eeedbbf17394e29e9eef9f6b52481cf79a.tar.gz
Merge pull request #2075 from rabbitmq/configure-cluster-name
Make it possible to pre-configure cluster name via config
-rw-r--r--docs/rabbitmq.conf.example6
-rw-r--r--priv/schema/rabbit.schema8
-rw-r--r--src/rabbit.erl6
-rw-r--r--src/rabbit_nodes.erl21
4 files changed, 36 insertions, 5 deletions
diff --git a/docs/rabbitmq.conf.example b/docs/rabbitmq.conf.example
index 988fb62467..44ded7c737 100644
--- a/docs/rabbitmq.conf.example
+++ b/docs/rabbitmq.conf.example
@@ -200,6 +200,10 @@
# ssl_handshake_timeout = 5000
+## Cluster name
+##
+# cluster_name = dev3.eng.megacorp.local
+
## Password hashing implementation. Will only affect newly
## created users. To recalculate hash for an existing user
## it's necessary to update her password.
@@ -512,7 +516,7 @@
# net_ticktime = 60
## Inter-node communication port range.
-## The parameters inet_dist_listen_min and inet_dist_listen_max
+## The parameters inet_dist_listen_min and inet_dist_listen_max
## can be configured in the classic config format only.
## Related doc guide: https://www.rabbitmq.com/networking.html#epmd-inet-dist-port-range.
diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema
index 44c199ff4d..8c951cbecb 100644
--- a/priv/schema/rabbit.schema
+++ b/priv/schema/rabbit.schema
@@ -383,7 +383,7 @@ end}.
{datatype, {enum, [distinguished_name, common_name]}}
]}.
-%% SSL handshake timeout, in milliseconds.
+%% TLS handshake timeout, in milliseconds.
%%
%% {ssl_handshake_timeout, 5000},
@@ -391,6 +391,12 @@ end}.
{datatype, integer}
]}.
+%% Cluster name
+
+{mapping, "cluster_name", "rabbit.cluster_name", [
+ {datatype, string}
+]}.
+
%% Default worker process pool size. Used to limit maximum concurrency rate
%% of certain operations, e.g. queue initialisation and recovery on node boot.
diff --git a/src/rabbit.erl b/src/rabbit.erl
index fdf2138515..3dd963b813 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -226,6 +226,12 @@
[{description, "ready to communicate with peers and clients"},
{requires, [core_initialized, recovery, routing_ready]}]}).
+-rabbit_boot_step({cluster_name,
+ [{description, "sets cluster name if configured"},
+ {mfa, {rabbit_nodes, boot, []}},
+ {requires, pre_flight}
+ ]}).
+
-rabbit_boot_step({direct_client,
[{description, "direct client"},
{mfa, {rabbit_direct, boot, []}},
diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl
index bfe5f271fd..2167610fcc 100644
--- a/src/rabbit_nodes.erl
+++ b/src/rabbit_nodes.erl
@@ -19,18 +19,28 @@
-export([names/1, diagnostics/1, make/1, parts/1, cookie_hash/0,
is_running/2, is_process_running/2,
- cluster_name/0, set_cluster_name/2, ensure_epmd/0,
+ cluster_name/0, set_cluster_name/1, set_cluster_name/2, ensure_epmd/0,
all_running/0, name_type/0, running_count/0,
- await_running_count/2]).
+ await_running_count/2,
+ boot/0]).
-include_lib("kernel/include/inet.hrl").
+-include_lib("rabbit_common/include/rabbit.hrl").
-define(SAMPLING_INTERVAL, 1000).
%%----------------------------------------------------------------------------
-%% Specs
+%% API
%%----------------------------------------------------------------------------
+boot() ->
+ case application:get_env(rabbit, cluster_name) of
+ undefined -> ok;
+ {ok, Name} ->
+ rabbit_log:info("Setting cluster name to '~s' as configured", [Name]),
+ set_cluster_name(rabbit_data_coercion:to_binary(Name))
+ end.
+
name_type() ->
case os:getenv("RABBITMQ_USE_LONGNAME") of
"true" -> longnames;
@@ -80,6 +90,11 @@ cluster_name_default() ->
FQDN = rabbit_net:hostname(),
list_to_binary(atom_to_list(make({ID, FQDN}))).
+-spec set_cluster_name(binary()) -> 'ok'.
+
+set_cluster_name(Name) ->
+ set_cluster_name(Name, ?INTERNAL_USER).
+
-spec set_cluster_name(binary(), rabbit_types:username()) -> 'ok'.
set_cluster_name(Name, Username) ->