当前位置:首页 > 云计算 > 正文内容

mongodb端口占用怎么解决

2022-05-04 03:12:29云计算1

启动mongod:

root@wangyuyu-Vostro-1440:/usr/bin#./mongod

错误提示:

SatAug1709:02:02[initandlisten]ERROR:listen():bind()failederrno:98Addressalreadyinuseforsocket:
0.0.0.0:27017
SatAug1709:02:02[initandlisten]ERROR:addralreadyinuse

原因是启动mongod时端口被占用。

解决办法:

使用命令:root@wangyuyu-Vostro-1440:/usr/bin# netstat -anp|more

可以看到客户端还保持着与服务器的连接。

ProtoRecv-QSend-QLocalAddressForeignAddressState
PID/Programname
tcp00127.0.0.1:280170.0.0.0:*LISTEN
953/mongod
tcp00127.0.0.1:530.0.0.0:*LISTEN
1546/dnsmasq
tcp00127.0.0.1:6310.0.0.0:*LISTEN
653/cupsd
tcp00127.0.0.1:270170.0.0.0:*LISTEN
953/mongod
tcp10192.168.5.124:5687491.189.89.144:80CLOSE_WAIT
1913/ubuntu-geoip-p
tcp01192.168.5.124:45890220.181.111.24:80FIN_WAIT1
-
tcp00192.168.5.124:44867219.148.35.218:80ESTABLISHED
2219/firefox

杀死953进程:root@wangyuyu-Vostro-1440:/usr/bin# kill -9 953

再次查看服务器连接状态:

ProtoRecv-QSend-QLocalAddressForeignAddressState
PID/Programname
tcp00127.0.0.1:530.0.0.0:*LISTEN
1546/dnsmasq
tcp00127.0.0.1:6310.0.0.0:*LISTEN
653/cupsd
tcp00192.168.5.124:6080561.172.207.130:80TIME_WAIT
-
tcp10192.168.5.124:5687491.189.89.144:80CLOSE_WAIT
1913/ubuntu-geoip-p
tcp00192.168.5.124:54370117.79.157.237:80TIME_WAIT
-

OK,已经成功杀掉进程。

root@wangyuyu-Vostro-1440:/usr/bin#./mongod
SatAug1709:32:25[initandlisten]waitingforconnectionsonport27017
SatAug1709:32:25[websvr]adminwebconsolewaitingforconnectionsonport28017

问题解决。

python学习网,大量的免费MongoDB入门教程,欢迎在线学习!

本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.

本文链接:https://www.xibujisuan.cn/9204.html

标签: Python