Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getMongoData.js - Support for mongosh and MongoDB v6.X #119

Open
TravWill-Mongo opened this issue Dec 2, 2022 · 3 comments
Open

getMongoData.js - Support for mongosh and MongoDB v6.X #119

TravWill-Mongo opened this issue Dec 2, 2022 · 3 comments

Comments

@TravWill-Mongo
Copy link

The legacy "mongo" shell is no longer available for download, and officially deprecated as of MongoDB 6.0. As the "getMongoData.js" exists today, it breaks under two known conditions:

  1. "hostname()" is no longer a supported command in mongosh. Use "os.hostname()" instead.
  2. MDB 6.0 has deprecated "db.printSlaveReplicationInfo()". Use "db.printSecondaryReplicationInfo()" instead.

I have cloned and modified the existing script to support mongosh and MDB 6.0, you can find it and the revisions here:
https://gist.github.com/TravWill-Mongo/1bb4fdbac8a4491cb2f1d76c77afba9a

For this to be properly integrated, we would need to have some conditional logic to use the right commands based upon version.

For what it's worth, I have only tested this on the following setup:

  • mongosh 1.6.1
  • mongod - 6.0.1
  • Operating System: Mac OS X 12.6.1

Thanks!

@hendritjipto
Copy link

hendritjipto commented Dec 18, 2022

@TravWill-Mongo How to run your the command ? I still having the error running the code using mongo 5.0.14.

MongoServerError: not authorized on local to execute command { aggregate: "replset.oplogTruncateAfterPoint"

@TravWill-Mongo
Copy link
Author

@hendritjipto That looks like a permission issue. I have not run into that specific error myself. You could consider editing the script to skip the "local" db if needed.

@gnawhnehpets
Copy link

gnawhnehpets commented Mar 8, 2023

@TravWill-Mongo took your suggestion and skipped the local db entirely @line 304: https://github.com/gnawhnehpets/mongodb/blob/main/support-tools/getMongoDatav6.0.3.js

I got it working with the root role. FWIW, I have only tested this locally with the following setup:

  • mongosh 1.8.0
  • mongod 6.0.4
  • Operating System: Mac OS X 13.2.1

Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants