然后就出现
[root@server1 jiangji]# service mongod start
Starting mongod (via systemctl): Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
tail -f /var/log/mongodb/mongod.log
rm /var/log/mongodb/mongod.log -rf
chown -R mongod:mongod /var/log/mongodb
chown -R mongod /data/mongo
然后/data/mongo目录下的
rm -rf mongod.lock
rm -rf WiredTiger.lock
依然还是报刚刚的错误,中间还有经历一些如
llegalOperation: Attempted to create a lock file on a read-only directory MongoDB in Windows之类的报错。
最后送上绝招:
rm /var/run/mongodb/mongod.pid
好了,systemctl start mongod正常启动了。mongo也正常连接上了。
附注:chown -R mongod /data/mongo这里的mongod这个名称是来自于检查如下的归属用户才知道的。
解决方案参考:
https://blog.csdn.net/sinat_38385185/article/details/82699948