MongoDB集群启动报错,信息如下:
2019-05-18T10:37:28.901+0800 I CONTROL [main] ***** SERVER RESTARTED *****2019-05-18T10:10:40.251+0800 I CONTROL [initandlisten] MongoDB starting : pid=3210 port=7010 dbpath=/data4/mongodb7010 64-bit host=db5
2019-05-18T10:10:40.251+0800 I CONTROL [initandlisten] db version v3.4.15
2019-05-18T10:10:40.251+0800 I CONTROL [initandlisten] git version: 52e5b5fbaa3a2a5b1a217f5e647b5061817475f9
2019-05-18T10:10:40.251+0800 I CONTROL [initandlisten] allocator: tcmalloc
2019-05-18T10:10:40.251+0800 I CONTROL [initandlisten] modules: none
2019-05-18T10:10:40.252+0800 I CONTROL [initandlisten] build environment:
2019-05-18T10:10:40.252+0800 I CONTROL [initandlisten] distarch: x86_64
2019-05-18T10:10:40.252+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-05-18T10:10:40.252+0800 I CONTROL [initandlisten] options: { config: "/data4/mongodb7010/conf/shard7010.conf", net: { http: { enabled: false }, port: 7010 }, operationProfiling: { mode: "slowOp", slowOpThresholdMs: 500 }, processManagement: { fork: true }, replication: { oplogSizeMB: 65535, replSet: "shard7010" }, security: { keyFile: "/data4/mongodb7010/keyFile" }, setParameter: { enableLocalhostAuthBypass: "1" }, sharding: { clusterRole: "shardsvr" }, storage: { dbPath: "/data4/mongodb7010", directoryPerDB: true, engine: "wiredTiger", wiredTiger: { collectionConfig: { blockCompressor: "snappy" }, engineConfig: { cacheSizeGB: 50.0 } } }, systemLog: { destination: "file", logAppend: true, path: "/data4/mongodb7010/log/mongod.log", quiet: true } }
2019-05-18T10:10:40.285+0800 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-7010.sock Operation not permitted
2019-05-18T10:10:40.285+0800 I - [initandlisten] Fatal Assertion 28578 at src/mongo/util/net/listen.cpp 195
2019-05-18T10:10:40.285+0800 I - [initandlisten]
***aborting after fassert() failure
错误很明显:
Failed to unlink socket file /tmp/mongodb-7010.sock,就看这一行就够了。
它既然说没有办法取消/tmp/mongodb-7010.sock的链接,那就找到此文件位置,直接删除它,让mongo重新去生成此文件。
若执行rm命令无法删除时,给命令前添加sudo去删除,如:
sudo rm /tmp/mongodb-7010.sock
注意:删除此文件前,先停止mongo的一切进程,可通过命令去查看mongo的进行:
ps -ef | grep mongo
然后利用kill命令去杀掉相关进程:
kill -2 进程号
切勿使用kill -9 ,可能会造成文件损坏!
然后删除所有的mongo集群中相关日志,重新启动mongo集群,若还是报错,看日志信息,若果还是报类似错误,那就继续按上述方法删除相关文件。
重启后你会很意外,mongo集群可以顺利启动了!!!