In this post, we will build and run the 'edge' version which is more lightweight hence more suitable for Raspberry PI.
Build emqx-edge from source code.
Follow the instructions in README in emqx-rel project.The exact commands I executed
$ git clone -b v4.0.0 https://github.com/emqx/emqx-rel.git emqx-rel
cd emqx-rel && make emqx-edge
Execute this command to test if the broker can start normally:$./_build/emqx-edge/rel/emqx/bin/emqx console
Expected log:EMQ X Edge 4.0.0 is running now!
Start it in systemd
Move rel
to your favourite location.
$ sudo mv _build/emqx-edge/rel/emqx /opt/
Make a systemd unit file for emqx service
There is a system unit file in emqx-rel project. File path:deploy/packages/rpm/emqx.service
To make it simple, update the file to
- Run systemd service with user
pi
- Replace
/usr/bin/
with/opt/emqx/bin
.
$ cat /opt/emqx/emqx.service
[Unit]
Description=emqx daemon
After=network.target
[Service]
User=pi
Group=pi
Type=forking
Environment=HOME=/opt/emqx
ExecStart=/bin/sh /opt/emqx/bin/emqx start
LimitNOFILE=1048576
ExecStop=/bin/sh /opt/emqx/bin/emqx stop
[Install]
WantedBy=multi-user.target
Link it to systemd's directory
$ sudo ln -s /opt/emqx/emqx.service /etc/systemd/system/emqx.service
Start it
$ sudo systemctl start emqx
Check if it's running well
$ systemctl status emqx.service
We should be able to find the expected log line:
MQ X Edge v4.0.0 is started successfully!
Make it auto start
$ sudo systemctl enable emqx.service
No comments:
Post a Comment