mongoDB宕机修复

1.删除mongo路径下/data/mongod.lock
2.删除mongo路径下/data/storage.bson
3.加载数据库文件路径,或者使用配置文件 --config xxx/config.conf
/www/server/mongodb/bin/mongod --bind_ip 0.0.0.0 --dbpath /www/server/mongodb/data

加入systemctl
1./usr/lib/systemd/system
2.vim mongo.service
```
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target

[Service]
# Type=forking mongo 不能开这个
ExecStart=/www/server/mongodb/bin/mongod --bind_ip 0.0.0.0 --dbpath /www/server/mongodb/data
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/www/server/mongodb/bin/mongod --shutdown

PrivateTmp=true

[Install]
WantedBy=multi-user.target
```

3.systemctl enable mongo.service
4.systemctl daemon-reload
5.systemctl start mongo.service

posted @ 2024-04-11 15:57  rm-rf*  阅读(14)  评论(0编辑  收藏  举报