錯誤:web
啓動mongod ubuntu
root@wangyuyu-Vostro-1440:/usr/bin# ./mongod
錯誤提示:服務器
Sat Aug 17 09:02:02 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 Sat Aug 17 09:02:02 [initandlisten] ERROR: addr already in use
緣由:socket
啓動mongod時端口被佔用。tcp
解決方案:spa
使用命令 firefox
root@wangyuyu-Vostro-1440:/usr/bin# netstat -anp|more
能夠看到客戶端還保持着與服務器的鏈接code
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:28017 0.0.0.0:* LISTEN 953/mongod tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1546/dnsmasq tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 653/cupsd tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 953/mongod tcp 1 0 192.168.5.124:56874 91.189.89.144:80 CLOSE_WAIT 1913/ubuntu-geoip-p tcp 0 1 192.168.5.124:45890 220.181.111.24:80 FIN_WAIT1 - tcp 0 0 192.168.5.124:44867 219.148.35.218:80 ESTABLISHED 2219/firefox
殺死953進程blog
root@wangyuyu-Vostro-1440:/usr/bin# kill -9 953
再次察看服務器連接狀態:dns
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1546/dnsmasq tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 653/cupsd tcp 0 0 192.168.5.124:60805 61.172.207.130:80 TIME_WAIT - tcp 1 0 192.168.5.124:56874 91.189.89.144:80 CLOSE_WAIT 1913/ubuntu-geoip-p tcp 0 0 192.168.5.124:54370 117.79.157.237:80 TIME_WAIT -
OK已經成功殺掉進程。
root@wangyuyu-Vostro-1440:/usr/bin# ./mongod Sat Aug 17 09:32:25 [initandlisten] waiting for connections on port 27017 Sat Aug 17 09:32:25 [websvr] admin web console waiting for connections on port 28017
問題解決。