ps aux和grep的使用查询进程
root@ubuntu:/opt/emqx# ps aux|grep emqx
root 8386 0.0 0.0 21292 936 pts/3 S+ 11:11 0:00 grep --color=auto emqx
启动emq,结果报错
2020-05-22 11:06:54.126 [error] mqtt:tcp failed to listen on 1883 - eaddrinuse (address already in use)
2020-05-22 11:06:54.127 [error] [Bridge Connect] Failed to connect with module=emqx_bridge_mqtt
原因是1883端口被占用,那么把占用1883的进程杀掉就行了
端口号查询:netstat |grep 端口号
1、
root@ubuntu:/opt/emqx# netstat |grep 1883
tcp 0 1 192.168.205.128:52420 192.168.3.109:1883 SYN_SENT
tcp 0 0 localhost:1883 localhost:37251 TIME_WAIT
可以看到有进程在使用1883端口,但是查看不到具体PID
2、lsof -i:端口号
root@ubuntu:/opt/emqx# lsof -i:1883
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mosquitto 936 mosquitto 4u IPv4 27170 0t0 TCP *:1883 (LISTEN)
mosquitto 936 mosquitto 5u IPv6 27171 0t0 TCP *:1883 (LISTEN)
mosquitto 936 mosquitto 6u IPv4 48420 0t0 TCP 192.168.205.128:52422->192.168.3.109:1883 (SYN_SENT)
可以看到936这个进程在使用1883端口,一般来说mosquitto默认使用的端口号就是1883.
之后kill掉mosquitto这个进程就好了
杀死进程方式: kill 或者 kill -9
root@ubuntu:/opt/emqx# kill -9 936
然后emqx程序就可以正常启动了
root@ubuntu:/opt/emqx# ./bin/emqx console
Exec: /opt/emqx/erts-10.7.1/bin/erlexec -boot /opt/emqx/releases/v4.0.6/emqx -mode embedded -boot_var ERTS_LIB_DIR /opt/emqx/erts-10.7.1/../lib -mnesia dir "/opt/emqx/data/mnesia/emqx@127.0.0.1" -config /opt/emqx/data/configs/app.2020.05.22.11.18.40.config -args_file /opt/emqx/data/configs/vm.2020.05.22.11.18.40.args -vm_args /opt/emqx/data/configs/vm.2020.05.22.11.18.40.args -start_epmd false -epmd_module ekka_epmd -proto_dist ekka -- console
Root: /opt/emqx
/opt/emqx
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:8] [async-threads:4] [hipe]
Starting emqx on node emqx@127.0.0.1
Start http:management listener on 8081 successfully.
Start http:dashboard listener on 18083 successfully.
Start mqtt:tcp listener on 127.0.0.1:11883 successfully.
Start mqtt:tcp listener on 0.0.0.0:1883 successfully.
Start mqtt:ws listener on 0.0.0.0:8083 successfully.
Start mqtt:ssl listener on 0.0.0.0:8883 successfully.
Start mqtt:wss listener on 0.0.0.0:8084 successfully.
EMQ X Broker 4.0.6 is running now!
Eshell V10.7.1 (abort with ^G)
(emqx@127.0.0.1)1>
给自己做下笔记