Mac OSX MongoDB在启动期间无法设置套接字

时间:2016-10-24 15:05:08

标签: macos mongodb

我的Mac上的MongoDB突然无法启动。这些是消息:

2016-10-24T11:13:04.080-0500 I CONTROL  [initandlisten] MongoDB starting : pid=365 port=27017 dbpath=/Users/user1/mongodb/data/db 64-bit host=Mac1.attlocal.net
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] db version v3.2.6
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] allocator: system
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] modules: none
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] build environment:
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten]     distarch: x86_64
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten]     target_arch: x86_64
2016-10-24T11:13:04.081-0500 I CONTROL  [initandlisten] options: { config: "mongod.conf", storage: { dbPath: "/Users/user1/mongodb/data/db" } }
2016-10-24T11:13:04.082-0500 E NETWORK  [initandlisten] listen(): bind() failed errno:1 Operation not permitted for socket: /tmp/mongodb-27017.sock
2016-10-24T11:13:04.082-0500 E STORAGE  [initandlisten] Failed to set up sockets during startup.
2016-10-24T11:13:04.083-0500 I CONTROL  [initandlisten] dbexit:  rc: 48

我试过了:

Mac1:mongodb user1$ ls -ld /tmp
lrwxr-xr-x@ 1 root  wheel  11 Feb 23  2016 /tmp -> private/tmp

任何建议?

1 个答案:

答案 0 :(得分:0)

正如当天早些时候发现的那样,我的机器为OS X El Capitan 2016-002自动更新了安全性。此更新将/ tmp label和/ private / tmp文件夹的标志更改为“restricted”。因此,在该位置无法创建任何内容(请参阅上面的评论)。

解决此问题:

  1. 将Mac重新启动到安全模式
  2. 转到终端并发出:csrutil disable
  3. 将Mac重新启动到正常模式
  4. 将限制标记更改为该位置的非限制标记。在终端:sudo chflags norestricted / private / tmp。和sudo chflags norestricted / tmp(不确定是否需要这个)
  5. 如果需要,还可以更改权限:sudo chmod 1777 / tmp和sudo chmod 1777 / private / tmp
  6. 再次重新启动到安全模式,并执行csrutil enable back
  7. 这解决了我的问题。