解决mongo 端口占用问题

执行mongod报错

 mongod
2016-08-03T14:31:15.691+0800 I CONTROL  [initandlisten] MongoDB starting : pid=13659 port=27017 dbpath=/data/db 64-bit host=yishiyaonie.local
2016-08-03T14:31:15.691+0800 I CONTROL  [initandlisten] db version v3.2.8
2016-08-03T14:31:15.691+0800 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-03T14:31:15.691+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2h  3 May 2016
2016-08-03T14:31:15.691+0800 I CONTROL  [initandlisten] allocator: system
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten] modules: none
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten] build environment:
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten] options: {}
2016-08-03T14:31:15.692+0800 E NETWORK  [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2016-08-03T14:31:15.692+0800 E NETWORK  [initandlisten]   addr already in use
2016-08-03T14:31:15.692+0800 E STORAGE  [initandlisten] Failed to set up sockets during startup.
2016-08-03T14:31:15.692+0800 I CONTROL  [initandlisten] dbexit:  rc: 48

原因是端口被占用了
咋办呢?

yishiyaonie:~ liuhanlin$ ps aux | grep mongod
liuhanlin       13664   1.3  0.0  2454296    824 s000  S+    2:32下午   0:00.01 grep mongod
liuhanlin       73199   0.4  0.1  2588148  10240   ??  S    四10上午  17:12.81 mongod

然后杀掉进程:

yishiyaonie:~ liuhanlin$ kill -9 73199

然后重启ok了:

yishiyaonie:~ liuhanlin$ mongod
2016-08-03T14:33:50.997+0800 I CONTROL  [initandlisten] MongoDB starting : pid=13681 port=27017 dbpath=/data/db 64-bit host=yishiyaonie.local
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] db version v3.2.8
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2h  3 May 2016
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] allocator: system
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] modules: none
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] build environment:
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-08-03T14:33:50.998+0800 I CONTROL  [initandlisten] options: {}
2016-08-03T14:33:50.999+0800 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-03T14:33:50.999+0800 W -        [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
2016-08-03T14:33:50.999+0800 W STORAGE  [initandlisten] Recovering data from the last clean checkpoint.
2016-08-03T14:33:51.000+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-08-03T14:33:51.876+0800 I CONTROL  [initandlisten] 
2016-08-03T14:33:51.876+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2016-08-03T14:33:51.883+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-08-03T14:33:51.883+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-08-03T14:33:51.884+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-08-03T14:33:52.009+0800 I FTDC     [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
2016-08-03T14:33:52.243+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64066 #1 (1 connection now open)
2016-08-03T14:33:52.243+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64065 #2 (2 connections now open)
2016-08-03T14:33:52.243+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64064 #3 (3 connections now open)
2016-08-03T14:33:52.243+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64063 #4 (4 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64062 #5 (5 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64061 #6 (6 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64060 #7 (7 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64059 #8 (8 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64058 #9 (9 connections now open)
2016-08-03T14:33:52.244+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64056 #10 (10 connections now open)
2016-08-03T14:33:52.245+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64057 #11 (11 connections now open)
2016-08-03T14:33:52.245+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:64055 #12 (12 connections now open)

你可能感兴趣的:(解决mongo 端口占用问题)