Differences between revisions 4 and 5
Revision 4 as of 2018-11-12 00:36:58
Size: 1102
Editor: PieterSmit
Comment:
Revision 5 as of 2019-03-07 02:54:22
Size: 1392
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 37: Line 37:

 === Slow / Long running queries ==
 * * $ mongo 10.32.2.4 --authenticationDatabase admin --username test --password mypass
 * > db.currentOp()
 * > db.currentOp({"secs_running": {$gte: 3}})

 * Count documents in <db> <collection>
   * use <db>;
   * db.<collection>.count()

MongoDB nosql notes

Login

  • $ mongo 10.32.2.4 --authenticationDatabase admin --username test --password mypass
  • > db

    • test
  • > show dbs

  • > use 9spokes

  • > db.getCollection("")

  • > show collections

  • db.getCollection("config_data").find()

Replicaset

  • View members
    •  mongo admin --host $ip -u root -p $pass  -eval "rs.status()" 

  • Check if current server is the write
    •  mongo admin --host $ip -u root -p $pass --quiet --eval "db.isMaster()['ismaster']"  

Recover password

  • stop the mongod service
  • edit /etc/mongod.conf
    •    :PRIMARY>  use admin
         :PRIMARY> db.createUser({user:"root",pwd:"mongopwd",roles:[{role:"root",db:"admin"}]});
         :PRIMARY> db.changeUserPassword("root","mongopwd")

MongoDb (last edited 2020-07-24 00:29:21 by PieterSmit)