Support autocluster with IP Multicast
This commit is contained in:
parent
0a7ca2cdb3
commit
a23df7f16e
54
etc/emq.conf
54
etc/emq.conf
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
##===================================================================
|
##===================================================================
|
||||||
## EMQ Configuration R2.2
|
## EMQ Configuration R2.3
|
||||||
##===================================================================
|
##===================================================================
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
|
@ -8,32 +8,28 @@
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
|
|
||||||
## Cluster name
|
## Cluster name
|
||||||
cluster.name = ekka
|
cluster.name = emqcluster
|
||||||
|
|
||||||
## Cluster Cookie
|
## Cluster discovery strategy: manual | static | mcast | dns | etcd
|
||||||
cluster.cookie = ekkaclustercookie
|
cluster.discovery = mcast
|
||||||
|
|
||||||
## Cluster Discovery: static | epmd | multicast | gossip | etcd | consul
|
|
||||||
cluster.discovery = static
|
|
||||||
|
|
||||||
## Cluster Autoheal: on | off
|
## Cluster Autoheal: on | off
|
||||||
cluster.autoheal = on
|
cluster.autoheal = off
|
||||||
|
|
||||||
## Clean down node of the cluster
|
## Clean down node of the cluster
|
||||||
cluster.clean_down = 1h
|
cluster.clean_down = 1h
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Cluster with epmd
|
## Cluster with static node list
|
||||||
|
|
||||||
cluster.epmd.seeds = a@127.0.0.1,b@127.0.0.1
|
## cluster.static.seeds = emq1@127.0.0.1,emq@127.0.0.1
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Cluster with multicast
|
## Cluster with multicast
|
||||||
|
|
||||||
## 1 second
|
cluster.mcast.addr = 239.192.0.1
|
||||||
cluster.mcast.period = 1s
|
|
||||||
|
|
||||||
cluster.mcast.addr = 239.192.0.1:4369
|
cluster.mcast.ports = 4369,4370,4371
|
||||||
|
|
||||||
cluster.mcast.iface = 0.0.0.0
|
cluster.mcast.iface = 0.0.0.0
|
||||||
|
|
||||||
|
@ -42,46 +38,30 @@ cluster.mcast.ttl = 1
|
||||||
cluster.mcast.loop = on
|
cluster.mcast.loop = on
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Cluster with Gossip
|
## Cluster with DNS
|
||||||
|
|
||||||
cluster.gossip.seeds = 127.0.0.1:4369
|
## cluster.dns.name = localhost
|
||||||
|
|
||||||
cluster.gossip.protocol_period = 1s
|
## cluster.dns.app = emqx
|
||||||
|
|
||||||
cluster.gossip.suspicion_factor = 3
|
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Cluster with Etcd
|
## Cluster with Etcd
|
||||||
|
|
||||||
cluster.etcd.addr = 127.0.0.1:2367
|
## cluster.etcd.addr = http://127.0.0.1:2367
|
||||||
|
|
||||||
cluster.etcd.prefix = emq
|
## cluster.etcd.prefix = ekkacluster
|
||||||
|
|
||||||
cluster.etcd.node_ttl = 30m
|
## cluster.etcd.node_ttl = 1h
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
|
||||||
## Cluster by Consul
|
|
||||||
|
|
||||||
cluster.consul.addr = 127.0.0.1:8500
|
|
||||||
|
|
||||||
cluster.consul.acl_token = example-acl-token
|
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
|
||||||
## Discover by Kubernetes
|
|
||||||
|
|
||||||
## cluster.k8s.selector = app=emq
|
|
||||||
|
|
||||||
## cluster.k8s.node_basename = emq
|
|
||||||
|
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
## Node Args
|
## Node Args
|
||||||
##--------------------------------------------------------------------
|
##--------------------------------------------------------------------
|
||||||
|
|
||||||
## Node name
|
## Node name
|
||||||
node.name = emqttd@127.0.0.1
|
node.name = emq@127.0.0.1
|
||||||
|
|
||||||
## Cookie for distributed node
|
## Cookie for distributed node
|
||||||
## node.cookie = emqsecretcookie
|
node.cookie = emqsecretcookie
|
||||||
|
|
||||||
## SMP support: enable, auto, disable
|
## SMP support: enable, auto, disable
|
||||||
node.smp = auto
|
node.smp = auto
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-*- mode: erlang -*-
|
%%-*- mode: erlang -*-
|
||||||
%% EMQ config mapping
|
%% EMQ R2.3 config mapping
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Cluster
|
%% Cluster
|
||||||
|
@ -7,15 +7,10 @@
|
||||||
|
|
||||||
%% @doc Cluster name
|
%% @doc Cluster name
|
||||||
{mapping, "cluster.name", "ekka.cluster_name", [
|
{mapping, "cluster.name", "ekka.cluster_name", [
|
||||||
{default, emqcl},
|
{default, emqcluster},
|
||||||
{datatype, atom}
|
{datatype, atom}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Secret cookie for the cluster
|
|
||||||
{mapping, "cluster.cookie", "vm_args.-setcookie", [
|
|
||||||
{default, "emqclustercookie"}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
%% @doc Cluster discovery
|
%% @doc Cluster discovery
|
||||||
{mapping, "cluster.discovery", "ekka.cluster_discovery", [
|
{mapping, "cluster.discovery", "ekka.cluster_discovery", [
|
||||||
{default, manual},
|
{default, manual},
|
||||||
|
@ -28,7 +23,6 @@
|
||||||
{default, on}
|
{default, on}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
||||||
%% @doc Clean down node from the cluster
|
%% @doc Clean down node from the cluster
|
||||||
{mapping, "cluster.clean_down", "ekka.cluster_clean_down", [
|
{mapping, "cluster.clean_down", "ekka.cluster_clean_down", [
|
||||||
{datatype, {duration, ms}},
|
{datatype, {duration, ms}},
|
||||||
|
@ -36,9 +30,9 @@
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Cluster with epmd
|
%% Cluster with static node list
|
||||||
|
|
||||||
{mapping, "cluster.epmd.seeds", "ekka.cluster_discovery", [
|
{mapping, "cluster.static.seeds", "ekka.cluster_discovery", [
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -46,12 +40,13 @@
|
||||||
%% Cluster with IP Multicast
|
%% Cluster with IP Multicast
|
||||||
|
|
||||||
{mapping, "cluster.mcast.addr", "ekka.cluster_discovery", [
|
{mapping, "cluster.mcast.addr", "ekka.cluster_discovery", [
|
||||||
{datatype, ip}
|
{default, "239.192.0.1"},
|
||||||
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "cluster.mcast.period", "ekka.cluster_discovery", [
|
{mapping, "cluster.mcast.ports", "ekka.cluster_discovery", [
|
||||||
{datatype, {duration, ms}},
|
{default, "4369"},
|
||||||
{default, "1s"}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "cluster.mcast.iface", "ekka.cluster_discovery", [
|
{mapping, "cluster.mcast.iface", "ekka.cluster_discovery", [
|
||||||
|
@ -84,22 +79,19 @@
|
||||||
{default, "32KB"}
|
{default, "32KB"}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "cluster.gossip.seeds", "ekka.cluster_discovery", [
|
%%--------------------------------------------------------------------
|
||||||
|
%% Cluster with DNS
|
||||||
|
|
||||||
|
{mapping, "cluster.dns.name", "ekka.cluster_discovery", [
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "cluster.gossip.protocol_period", "ekka.cluster_discovery", [
|
{mapping, "cluster.dns.app", "ekka.cluster_discovery", [
|
||||||
{datatype, {duration, ms}},
|
{datatype, string}
|
||||||
{default, "1s"}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
{mapping, "cluster.gossip.suspicion_factor", "ekka.cluster_discovery", [
|
|
||||||
{datatype, integer},
|
|
||||||
{default, 3}
|
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Cluster with Etcd
|
%% Cluster with etcd
|
||||||
|
|
||||||
{mapping, "cluster.etcd.addr", "ekka.cluster_discovery", [
|
{mapping, "cluster.etcd.addr", "ekka.cluster_discovery", [
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
|
@ -114,17 +106,6 @@
|
||||||
{default, "1m"}
|
{default, "1m"}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Cluster with Consul
|
|
||||||
|
|
||||||
{mapping, "cluster.consul.addr", "ekka.cluster_discovery", [
|
|
||||||
{datatype, ip}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
{mapping, "cluster.consul.acl_token", "ekka.cluster_discovery", [
|
|
||||||
{datatype, string}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
{translation, "ekka.cluster_discovery", fun(Conf) ->
|
{translation, "ekka.cluster_discovery", fun(Conf) ->
|
||||||
Strategy = cuttlefish:conf_get("cluster.discovery", Conf),
|
Strategy = cuttlefish:conf_get("cluster.discovery", Conf),
|
||||||
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||||
|
@ -134,39 +115,27 @@
|
||||||
{Ip, Port}
|
{Ip, Port}
|
||||||
end,
|
end,
|
||||||
Options = fun(static) ->
|
Options = fun(static) ->
|
||||||
[{seeds, cuttlefish:conf_get("cluster.epmd.seeds", Conf)}];
|
[{seeds, [list_to_atom(S) || S <- string:tokens(cuttlefish:conf_get("cluster.static.seeds", Conf, ""), ",")]}];
|
||||||
(mcast) ->
|
(mcast) ->
|
||||||
{Addr, Port} = cuttlefish:conf_get("cluster.mcast.addr", Conf),
|
{ok, Addr} = inet:parse_address(cuttlefish:conf_get("cluster.mcast.addr", Conf)),
|
||||||
{ok, Ip} = inet:parse_address(Addr),
|
|
||||||
{ok, Iface} = inet:parse_address(cuttlefish:conf_get("cluster.mcast.iface", Conf)),
|
{ok, Iface} = inet:parse_address(cuttlefish:conf_get("cluster.mcast.iface", Conf)),
|
||||||
[{addr, Ip}, {port, Port}, {iface, Iface},
|
Ports = [list_to_integer(S) || S <- string:tokens(cuttlefish:conf_get("cluster.mcast.ports", Conf), ",")],
|
||||||
{period, cuttlefish:conf_get("cluster.mcast.period", Conf)},
|
[{addr, Addr}, {ports, Ports}, {iface, Iface},
|
||||||
{ttl, cuttlefish:conf_get("cluster.mcast.ttl", Conf, 1)},
|
{ttl, cuttlefish:conf_get("cluster.mcast.ttl", Conf, 1)},
|
||||||
{loop, cuttlefish:conf_get("cluster.mcast.loop", Conf, true)}];
|
{loop, cuttlefish:conf_get("cluster.mcast.loop", Conf, true)}];
|
||||||
|
(dns) ->
|
||||||
|
[{name, cuttlefish:conf_get("cluster.dns.name", Conf)},
|
||||||
|
{app, cuttlefish:conf_get("cluster.dns.app", Conf)}];
|
||||||
(etcd) ->
|
(etcd) ->
|
||||||
[{seeds, cuttlefish:conf_get("cluster.epmd.seeds", Conf)},
|
[{addr, string:tokens(cuttlefish:conf_get("cluster.etcd.addr", Conf), ",")},
|
||||||
{clean_down, cuttlefish:conf_get("cluster.epmd.clean_down", Conf, undefined)}];
|
|
||||||
(gossip) ->
|
|
||||||
[{seeds, [IpPort(S) || S <- string:tokens(",", cuttlefish:conf_get("cluster.gossip.seeds", Conf))]},
|
|
||||||
{protocol_period, cuttlefish:conf_get("cluster.gossip.protocol_period", Conf)},
|
|
||||||
{suspicion_factor, cuttlefish:conf_get("cluster.gossip.suspicion_factor", Conf, 3)}];
|
|
||||||
(etcd) ->
|
|
||||||
[{addr, cuttlefish:conf_get("cluster.etcd.addr", Conf)},
|
|
||||||
{prefix, cuttlefish:conf_get("cluster.etcd.prefix", Conf, "emq")},
|
{prefix, cuttlefish:conf_get("cluster.etcd.prefix", Conf, "emq")},
|
||||||
{node_ttl, cuttlefish:conf_get("cluster.etcd.node_ttl", Conf, 60)}];
|
{node_ttl, cuttlefish:conf_get("cluster.etcd.node_ttl", Conf, 60)}];
|
||||||
(consul) ->
|
|
||||||
[{addr, cuttlefish:conf_get("cluster.consul.addr", Conf)},
|
|
||||||
{acl_token, cuttlefish:conf_get("cluster.consul.acl_token", Conf)}];
|
|
||||||
(k8s) ->
|
|
||||||
[{host, cuttlefish:conf_get("cluster.k8s.selector", Conf)},
|
|
||||||
{acl_token, cuttlefish:conf_get("cluster.k8s.node_basename", Conf)}];
|
|
||||||
(manual) ->
|
(manual) ->
|
||||||
[ ]
|
[ ]
|
||||||
end,
|
end,
|
||||||
{Strategy, Filter(Options(Strategy))}
|
{Strategy, Filter(Options(Strategy))}
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Erlang Node
|
%% Erlang Node
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -177,9 +146,9 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% @doc Secret cookie for distributed erlang node
|
%% @doc Secret cookie for distributed erlang node
|
||||||
%% {mapping, "node.cookie", "vm_args.-setcookie", [
|
{mapping, "node.cookie", "vm_args.-setcookie", [
|
||||||
%% {default, "emqsecretcookie"}
|
{default, "emqsecretcookie"}
|
||||||
%%]}.
|
]}.
|
||||||
|
|
||||||
%% @doc SMP Support
|
%% @doc SMP Support
|
||||||
{mapping, "node.smp", "vm_args.-smp", [
|
{mapping, "node.smp", "vm_args.-smp", [
|
||||||
|
|
Loading…
Reference in New Issue