When I try to manual start mongod, I get this error: “zsh: bad CPU type in executable: mongod”
and when I check “ps -ef | grep mongo”, it says this: “501 43048 42112 0 11:12PM ttys000 0:00.00 grep mongo”
zsh: bad CPU type in executable: mongod
You’ve somehow installed the wrong executable, it seems.
501 43048 42112 0 11:12PM ttys000 0:00.00 grep mongo
That’s the grep
process itself searching for the string mongo
… it finds itself.
Do you have any suggestions on what I should do next? Thanks
@SM_A maybe you can try this:
- Use
brew
to uninstall. - Update/refresh
brew
… make entirely surebrew
itself is installed correctly for an M1. - Carefully try again to install following the directions and paying special attention to the prerequisites.
If it still doesn’t work, submit a bug report. The Forums here are more and more “community supporting community” and you’ll have better chances of getting serious attention with a well-formatted bug report if there really is a problem.
I feel for you I have a Mac, but not an M1, so I can’t try this myself.
Hmm, searching I find some stuff about using Rosetta during the install.
See this Stack Exchange question @SM_A … it’s long but it may be the answer.
Hi @SM_A,
You will need Rosetta2 emulation installed (a one-off procedure) to run MongoDB 5.0 on M1. NOTE: native M1 binaries are coming with MongoDB 6.0.
However, I expect macOS should automatically prompt you to install Rosetta rather than complaining about a bad CPU type.
Can you confirm the output of:
file $(which mongod)
sw_vers
On my M1 with a brew install of MongoDB 5.0 the file
command returns:
/opt/homebrew/bin/mongod: Mach-O 64-bit executable x86_64
You could try manually installing Rosetta 2:
softwareupdate --install-rosetta
Regards,
Stennie
Thanks @Stennie_X
I installed Rosetta. When checking mongo --version now, it looks correct. But when I check the status after running Mongo, it still shows an error:
What should I do now? Thank you.
Check your mongod.log
use brew --prefix to find your var/log location
Most likely it is failing due to permissions issues on /tmp .sock .lock files
@Ramachandra_Tummala
I see two logs in my /var/log/mongodb folder:
- mongo.log - When I open, it says unable to read the file.
- output.log:
{“t”:{"$date":“2022-06-15T12:55:58.842Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:36:36.829Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:37:26.315Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:39:10.033Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:45:00.497Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:45:55.112Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:57:58.049Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T14:47:17.978Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T15:00:03.140Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
Not sure what to do with this
It is unable to create the logfile
Check the permissions on /opt/homebrew/var/log/mongodb
Your mongod should be able to write to this dir
Also the dbpath directory
@Ramachandra_Tummala
I changed the permissions to this:
But I am still getting the same mongo.log errors and installation errors
Does this directory exist?
Please show contents
Do you have any mongod.log already in that dir with different ownership/permissions
I meant mongo.log only.On other os it is named as mongod.log
So why you are not able to open/read this file?
Can you show file permissions from terminal prompt instead of explorer view
ls -lrt mongod.log
Only root user can access this file
chmod 755 mongo.log and start the service
or move the file
sudo mv mongo.log mongo.log.old
When you start your service a new file should be created owned by mongod
Thank you. I was able to see the mongo.log and see what the error was. I fixed the error and my mongodb is working now
hey , I am also facing same issue .can u plz say how u have corrected it. since I tried a lot but of no use.
Can you open your mongo.log and see the error?