尝试启动MongoDB进程:
mongod -f /mongodb/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 17330
ERROR: child process failed, exited with error number 14
To see additional information in this output, start without the "--fork" option.
查看日志如下:
2021-04-08T14:43:01.206+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617864181:206800][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1617864181:206800][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied
2021-04-08T14:43:01.207+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617864181:207147][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1617864181:207147][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied
2021-04-08T14:43:01.207+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617864181:207537][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1617864181:207537][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied
2021-04-08T14:43:01.207+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617864181:207795][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1617864181:207795][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied
2021-04-08T14:43:01.208+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617864181:208041][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1617864181:208041][17330:0x7f3f33997c40], wiredtiger_open: __posix_open_file, 665: /mongodb/data/WiredTiger.turtle: handle-open: open: Permission denied
2021-04-08T14:43:01.208+0800 W STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2021-04-08T14:43:01.208+0800 F STORAGE [initandlisten] Reason: 13: Permission denied
2021-04-08T14:43:01.208+0800 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 925
2021-04-08T14:43:01.208+0800 F - [initandlisten] \n\n***aborting after fassert() failure\n\n
日志提示data目录下文件/mongodb/data/WiredTiger.turtle权限不足,于是查看权限:
drwx------ 2 mongodb mongodb 212 Mar 30 17:53 admin
drwx------ 2 mongodb mongodb 128 Mar 16 21:24 config
drwx------ 2 mongodb mongodb 90 Mar 30 17:52 db5
drwx------ 2 mongodb mongodb 260 Mar 31 14:04 db6
drwx------ 2 mongodb mongodb 4096 Apr 8 14:39 diagnostic.data
drwx------ 2 mongodb mongodb 110 Apr 8 14:27 journal
drwx------ 2 mongodb mongodb 89 Mar 16 21:24 local
-rw------- 1 mongodb mongodb 36864 Apr 8 14:39 _mdb_catalog.wt
-rw------- 1 mongodb mongodb 0 Apr 8 14:39 mongod.lock
-rw------- 1 mongodb mongodb 36864 Apr 8 14:39 sizeStorer.wt
-rw------- 1 mongodb mongodb 114 Mar 16 21:24 storage.bson
-rw------- 1 mongodb mongodb 46 Mar 16 21:24 WiredTiger
-rw------- 1 root root 4096 Apr 8 14:39 WiredTigerLAS.wt
-rw------- 1 mongodb mongodb 21 Mar 16 21:24 WiredTiger.lock
-rw------- 1 root root 1254 Apr 8 14:39 WiredTiger.turtle
-rw------- 1 mongodb mongodb 94208 Apr 8 14:39 WiredTiger.wt
原因:
上次启动MongoDB时候使用的root用户启动的,所以个别文件用户和组变成了root,于是修改文件的用户和组
drwx------ 2 mongodb mongodb 212 Mar 30 17:53 admin
drwx------ 2 mongodb mongodb 128 Mar 16 21:24 config
drwx------ 2 mongodb mongodb 90 Mar 30 17:52 db5
drwx------ 2 mongodb mongodb 260 Mar 31 14:04 db6
drwx------ 2 mongodb mongodb 4096 Apr 8 14:39 diagnostic.data
drwx------ 2 mongodb mongodb 38 Apr 8 15:14 journal
drwx------ 2 mongodb mongodb 89 Mar 16 21:24 local
-rw------- 1 mongodb mongodb 36864 Apr 8 14:39 _mdb_catalog.wt
-rw------- 1 mongodb mongodb 0 Apr 8 14:39 mongod.lock
-rw------- 1 mongodb mongodb 36864 Apr 8 14:39 sizeStorer.wt
-rw------- 1 mongodb mongodb 114 Mar 16 21:24 storage.bson
-rw------- 1 mongodb mongodb 46 Mar 16 21:24 WiredTiger
-rw------- 1 mongodb mongodb 4096 Apr 8 14:39 WiredTigerLAS.wt
-rw------- 1 mongodb mongodb 21 Mar 16 21:24 WiredTiger.lock
-rw------- 1 mongodb mongodb 1254 Apr 8 14:39 WiredTiger.turtle
-rw------- 1 mongodb mongodb 94208 Apr 8 15:14 WiredTiger.wt
再次尝试启动:
mongod -f /mongodb/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 9160
ERROR: child process failed, exited with error number 14
To see additional information in this output, start without the "--fork" option.
依然报错,我们继续查看日志:
2021-04-08T15:16:00.909+0800 E STORAGE [initandlisten] WiredTiger error (13) [1617866160:909118][10164:0x7f22f9814c40], connection: __posix_open_file, 665: /mongodb/data/journal/WiredTigerLog.0000000016: handle-open: open: Permission denied Raw: [1617866160:909118][10164:0x7f22f9814c40], connection: __posix_open_file, 665: /mongodb/data/journal/WiredTigerLog.0000000016: handle-open: open: Permission denied
还有个文件/mongodb/data/journal/WiredTigerLog.0000000016权限不足。
修改完用户和组,启动成功。
mongod -f /mongodb/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 12032
child process started successfully, parent exiting
我们在搭建和运维相关软件时候,必须有专用用户名和组,避免出现类似的情况。