Why Mongo Auto Restart after Shutdown
MongoDB is installed as a service.
For stop and disable use:
systemctl stop mongod
systemctl disable mongod
How to recover a standalone MongoDB after an unexpected shutdown on k8s
Here is my fix:
First
change k8s deployment.yaml config.
Because we want to repair the data file of mongodb, the first step is to make the mongo pod run, we run the command in the pod.
Now change the startup command of the container:
containers:
- name: mongodb
image: mongo:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: IfNotPresent
ports:
# .......
After apply it.
If I guessed correctly, the mongo pod should be up and running.
Second
Use mongod command to repair data.
kubectl exec -it <YOURPODNAME> -- mongod --dbpath <YOURDBPATH> --repair --directoryperdb
I have to exec it with --directoryperdb
, if you run it error, you can try remove it.
If I guessed correctly, So far everything is fine.
Third
Recover k8s deployment.yaml, back to the way they were.
Now reapply it.
---------- Manual split line
The above is my repair process. Its worked for me. I just record it. You can refer to it to fix your mongodb. Thank you.
mongodb not starting after reboot for my rails3 app
I think the issue is due to mongodb lock.
Try this:
sudo rm -rf /var/lib/mongodb/mongod.lock
and restart your service.
Related Topics
Why Do My Keystrokes Turn into Crazy Characters After I Dump a Bunch of Binary Data into My Terminal
Difference Between The Commands "Gcloud Compute Ssh" and "Ssh"
How to Create a File of Size More Than 2Gb in Linux/Unix
Posix: Pipe Syscall in Freebsd Vs Linux
Sonarqube Does Not Come Back Up After I Enable Postgres and Set Sonar.Properties
Openssl Shows a Different Server Certificate While Browser Shows Correctly
How to Convert Multiline File into a String in Bash with Newline Character
Different Show Between "Cat" and "Vim"
Error While Building Pjsip in Linux
Recursively Listing The Contents of a Tar/Zip Archive
How to Create a Folder with a Folder Name Containing Spaces in Linux
.Rodata Section Loaded in Executable Page