1 环境准备
通过arch 、lscpu、lsb_release -a
查看环境配置
[root@centos7 ~]# arch
x86_64
[root@centos7 ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Model name: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Stepping: 10
CPU MHz: 3192.003
CPU max MHz: 0.0000
CPU min MHz: 0.0000
BogoMIPS: 6384.00
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 12288K
NUMA node0 CPU(s): 0,1
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb invpcid_single fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
[root@centos7 ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core
2 拉取Emqx包
wget https://www.emqx.com/zh/downloads/broker/4.2.14/emqx-centos7-4.2.14-x86_64.rpm
执行结果:
--2022-10-10 22:04:34-- https://www.emqx.com/zh/downloads/broker/4.2.14/emqx-centos7-4.2.14-x86_64.rpm
Resolving www.emqx.com (www.emqx.com)... XXx
Connecting to www.emqx.com (www.emqx.com)|xx|:443... connected.
HTTP request sent, awaiting response...
302 Found
Location: https://packages.emqx.net/emqx-ce/v4.2.14/emqx-centos7-4.2.14-x86_64.rpm [following]
--2022-10-10 22:04:35-- https://packages.emqx.net/emqx-ce/v4.2.14/emqx-centos7-4.2.14-x86_64.rpm
Resolving packages.emqx.net (packages.emqx.net)... xxx
Connecting to packages.emqx.net (packages.emqx.net)|xxx|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20747068 (20M) [application/x-redhat-package-manager]
Saving to: ‘emqx-centos7-4.2.14-x86_64.rpm’
100%[=================================================================>] 20,747,068 19.2MB/s in 1.0s
2022-10-10 22:04:37 (19.2 MB/s) - ‘emqx-centos7-4.2.14-x86_64.rpm’ saved [20747068/20747068]
[root@centos7 ~]#
3 安装服务
sudo yum install emqx-centos7-4.2.14-x86_64.rpm
Loaded plugins: fastestmirror
Examining emqx-centos7-4.2.14-x86_64.rpm: emqx-4.2.14-1.el7.x86_64
Marking emqx-centos7-4.2.14-x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package emqx.x86_64 0:4.2.14-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
emqx x86_64 4.2.14-1.el7 /emqx-centos7-4.2.14-x86_64 37 M
Transaction Summary
===========================================================================================================
Install 1 Package
Total size: 37 M
Installed size: 37 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : emqx-4.2.14-1.el7.x86_64 1/1
Created symlink from /etc/systemd/system/multi-user.target.wants/emqx.service to /usr/lib/systemd/system/emqx.service.
Verifying : emqx-4.2.14-1.el7.x86_64 1/1
Installed:
emqx.x86_64 0:4.2.14-1.el7
Complete!
4 运行服务
sudo emqx start
EMQ X Broker 4.2.14 is started successfully!
[root@centos7 ~]#
5 配置开机自启
5.1 查找开机自启服务
systemctl list-unit-files |grep emq
5.2 设备为开机自启
systemctl enable emqx
6 开放端口
sudo firewall-cmd --zone=public --add-port=18083/tcp --permanent
sudo firewall-cmd --zone=public --add-port=1883/tcp --permanent
7 重启防火墙
sudo systemctl reload firewalld
8 界面验证
http://localhost:18083,localhost可以替换为你的云服务器公网IP或者虚拟机IP。登录账号:admin,密码:public。