Install Emqx with docker
Firewall configurations, disable firewalld for quick in this example, you might want add ports through firewall.
systemctl stop firewalld
systemctl disable firewalld
Then make nodes know each other
vim /etc/hosts
192.168.0.227 link1
192.168.0.228 link2
The emqx.conf is config of emqx, content(default ) is huge and you can copy it from flollowing site:
Or you can copy it with docker:
docker run -d --name emqx --rm emqx/emqx
docker cp emqx:/opt/emqx/etc .
docker rm -f emqx
Then start emqx container on each node(change the highlight line according to you nodes):
docker run -tid --name emqx --restart=always --network host \
-e EMQX_NAME=link1 \
-e EMQX_HOST=192.168.0.227 \
-e EMQX_LISTENER__TCP__EXTERNAL=1883 \
-e EMQX_WAIT_TIME=30 \
-e EMQX_JOIN_CLUSTER="link1@192.168.0.227" \
-e EMQX_CLUSTER__NAME=emqxcl \
-e EMQX_CLUSTER__DISCOVERY=static \
-e EMQX_CLUSTER__STATIC__SEEDS="link1@192.168.0.227,link2@192.168.0.228" \
emqx/emqx
Check running status
docker logs -f emqx
cluster.discovery = "static"
cluster.name = "emqxcl"
cluster.static.seeds = "link1@192.168.0.227,link2@192.168.0.228"
listener.ssl.external.acceptors = "32"
listener.ssl.external.max_connections = "102400"
listener.tcp.external = "1883"
listener.tcp.external.acceptors = "64"
listener.tcp.external.max_connections = "1024000"
listener.ws.external.acceptors = "16"
listener.ws.external.max_connections = "102400"
listener.wss.external.acceptors = "16"
listener.wss.external.max_connections = "102400"
log.to = "console"
node.max_ets_tables = "2097152"
node.max_ports = "1048576"
node.name = "link1@192.168.0.227"
node.process_limit = "2097152"
rpc.port_discovery = "manual"
Starting emqx on node link1@192.168.0.227
Start http:management listener on 8081 successfully.
Start http:dashboard listener on 18083 successfully.
Start mqtt:tcp:internal listener on 127.0.0.1:11883 successfully.
Start mqtt:tcp:external listener on 0.0.0.0:1883 successfully.
Start mqtt:ws:external listener on 0.0.0.0:8083 successfully.
Start mqtt:ssl:external listener on 0.0.0.0:8883 successfully.
Start mqtt:wss:external listener on 0.0.0.0:8084 successfully.
EMQ X Broker 4.3.8 is running now!
Check cluster status via
docker exec -it emqx /bin/sh /opt/emqx/bin/emqx_ctl cluster status
Cluster status: #{running_nodes =>
['link1@192.168.0.227','link2@192.168.0.228'],
stopped_nodes => []}
Open webbrowser, access site
http://link1.const.cc:18083
user: admin
password: public