运行“mongod”时出错

时间:2016-07-08 13:38:58

标签: node.js mongodb express mongoose

我正在使用node.js和express.js创建一个应用程序。当我运行mongo工作时,当我尝试运行mongod时出现此错误并且不输入localhost:28017

  

蒙戈

MongoDB shell version: 3.0.12
connecting to: test
Server has startup warnings: 
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] 
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] 
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-07-08T07:19:25.309-0300 I CONTROL  [initandlisten] 

运行时

  

的mongod

> 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten] MongoDB
> starting : pid=9761 port=27017 dbpath=/data/db 64-bit host=lucaspc
> 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten] db version
> v3.0.12 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten] git
> version: 33934938e0e95d534cebbaff656cde916b9c3573
> 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten] build info:
> Linux ip-10-229-66-2 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10
> 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
> 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten] allocator:
> tcmalloc 2016-07-08T10:29:01.459-0300 I CONTROL  [initandlisten]
> options: {} 2016-07-08T10:29:01.500-0300 E NETWORK  [initandlisten]
> listen(): bind() failed errno:98 Address already in use for socket:
> 0.0.0.0:27017 2016-07-08T10:29:01.500-0300 E NETWORK  [initandlisten]   addr already in use 2016-07-08T10:29:01.532-0300 I JOURNAL 
> [initandlisten] journal dir=/data/db/journal
> 2016-07-08T10:29:01.532-0300 I JOURNAL  [initandlisten] recover : no
> journal files present, no recovery needed 2016-07-08T10:29:01.624-0300
> I JOURNAL  [durability] Durability thread started
> 2016-07-08T10:29:01.624-0300 I JOURNAL  [journal writer] Journal
> writer thread started 2016-07-08T10:29:01.682-0300 I CONTROL 
> [initandlisten]  2016-07-08T10:29:01.682-0300 I CONTROL 
> [initandlisten] ** WARNING:
> /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
> 2016-07-08T10:29:01.682-0300 I CONTROL  [initandlisten] **        We
> suggest setting it to 'never' 2016-07-08T10:29:01.682-0300 I CONTROL 
> [initandlisten]  2016-07-08T10:29:01.682-0300 I CONTROL 
> [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag
> is 'always'. 2016-07-08T10:29:01.682-0300 I CONTROL  [initandlisten]
> **        We suggest setting it to 'never' 2016-07-08T10:29:01.682-0300 I CONTROL  [initandlisten] 
> 2016-07-08T10:29:01.688-0300 I CONTROL  [initandlisten] now exiting
> 2016-07-08T10:29:01.688-0300 I NETWORK  [initandlisten] shutdown:
> going to close listening sockets... 2016-07-08T10:29:01.688-0300 I
> NETWORK  [initandlisten] shutdown: going to flush diaglog...
> 2016-07-08T10:29:01.688-0300 I NETWORK  [initandlisten] shutdown:
> going to close sockets... 2016-07-08T10:29:01.689-0300 I STORAGE 
> [initandlisten] shutdown: waiting for fs preallocator...
> 2016-07-08T10:29:01.689-0300 I STORAGE  [initandlisten] shutdown:
> final commit... 2016-07-08T10:29:01.732-0300 I JOURNAL 
> [initandlisten] journalCleanup... 2016-07-08T10:29:01.732-0300 I
> JOURNAL  [initandlisten] removeJournalFiles
> 2016-07-08T10:29:01.794-0300 I JOURNAL  [initandlisten] Terminating
> durability thread ... 2016-07-08T10:29:01.894-0300 I JOURNAL  [journal
> writer] Journal writer thread stopped 2016-07-08T10:29:01.894-0300 I
> JOURNAL  [durability] Durability thread stopped
> 2016-07-08T10:29:01.894-0300 I STORAGE  [initandlisten] shutdown:
> closing all files... 2016-07-08T10:29:01.895-0300 I STORAGE 
> [initandlisten] closeAllFiles() finished 2016-07-08T10:29:01.895-0300
> I STORAGE  [initandlisten] shutdown: removing fs lock...
> 2016-07-08T10:29:01.896-0300 I CONTROL  [initandlisten] dbexit:  rc:
> 48

并且不连接localhost:28017

1 个答案:

答案 0 :(得分:0)

您已经在端口28017上实例化了一个mongo实例。该错误表明该端口已在使用中。你需要杀死任何正在运行的实例。

尝试ps -ef | grep mongo找到mongo实例的pid。

运行默认端口mongo是27017.您也可以使用

lsof -n -i TCP | grep 27017获取运行mongo的端口列表。