我尝试MongoDB
在 Ubuntu 14.04 上运行 3.2.4:
sudo service mongod start
并得到结果:
mongod start/running, process 67725
但当我检查状态时,我得到了:
mongod stop/waiting
我尝试重新安装MongoDB
或将 Mongo 文件夹 ( lib
& log
) 的权限定义为root
或mongodb
。我还尝试修复,mongod.conf
但毫无效果。
日志内容:
2016-04-09T23:56:28.349+0300 I CONTROL [main] ***** SERVER RESTARTED *****
2016-04-09T23:56:28.359+0300 I CONTROL [initandlisten] MongoDB starting : pid=69120 port=27017 dbpath=/var/lib/mongodb 64-bit host=is-infomedia
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] db version v3.2.4
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] allocator: tcmalloc
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] modules: none
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] build environment:
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] distmod: ubuntu1404
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] distarch: x86_64
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] target_arch: x86_64
2016-04-09T23:56:28.360+0300 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-04-09T23:56:28.393+0300 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-04-09T23:56:28.393+0300 I - [initandlisten] Fatal Assertion 28578
2016-04-09T23:56:28.393+0300 I - [initandlisten]
***aborting after fassert() failure
更新:
编辑后/etc/mongod.conf
:
#security:
authorization: enabled
enableEncryption: true
javascriptEnabled: false
并保存文件,然后尝试重新启动mongod
,我收到相同的错误,但 MongoDB 不会写入任何日志文件。我检查了的权限/etc/mongod.conf
,它被分配给组。编辑其配置文件后mongodb
如何重新启动?mongod
我的问题:
- 如何
MongoDB
在 Ubuntu 中作为服务运行? - 我错过了什么或者做错了什么?
答案1
这看起来像是权限问题,请执行以下操作:
sudo chown whoami /tmp/mongodb-27017.sock
这将根据您的需要直接设置权限。
答案2
我必须更改mongodb
中整个文件夹的权限/var/lib/
。赋予它所有读写权限,现在我的服务已启动。