Recently read the <<mongodb authoritative guide to the second edition of >>, and found that this book is better than the first version of the previous, a lot of places to explain in detail. The following is the translation of this document.
First, when you start the shell, the Mongorc.js file will be loaded and run automatically, and if some scripts are loaded frequently, it is a good idea to add them to the file.
If you want to display a welcome word when you start the shell, add a script to the file.
1 var com = ["Goodluck", "Happy"]; 2 var index = Math.floor (Math.random ()); 3 print ("Hello, you Are" +com[index]+ "!");
When you start the MONGO script,
?
1 2 3 |
MongoDB shell version: 2.4.9 connecting to: xxxxxxx Hello,you are happy ! |
At present, the more practical is to Rs.slaveok (); or Db.getmongo (). Setslaveok (); A percent of percent allows this connection to be read from the replica
This allows the shell to be loaded automatically when it is started, without the need to manually enter it.
If you start the MONGO script with the--NORC parameter, you can disable the load. Mongorc.js