7 / 26
Jun 2022

I used “brew services start mongodb-community@5.0”

Have you tried the manual start mongod --config /opt/homebrew/etc/mongod.conf --fork
If so, what was the result?

Also, check ps -ef | grep mongo to see if maybe you have some piece of mongo stuck and running despite the error messages.

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:

  1. Use brew to uninstall.
  2. Update/refresh brew … make entirely sure brew itself is installed correctly for an M1.
  3. 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 :slight_smile: I have a Mac, but not an M1, so I can’t try this myself.

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

@Ramachandra_Tummala
I see two logs in my /var/log/mongodb folder:

  1. mongo.log - When I open, it says unable to read the file.
  2. 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

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