Databases Reference
In-Depth Information
connecting to: localhost:30001
localhost:30001
Then, we can use mongos , shard0 , or shard1 as the db variable is usually used. (Although
special helpers, such as use foo or show collections , will not work.)
Shell Utilities
There are a number of useful shell functions that were not covered earlier.
For administrating multiple databases, it can be useful to have multiple database var-
iables, not db . For example, with sharding, you may want to maintain a separate variable
pointing to your config database:
> config = db.getSisterDB("config")
config
> config.shards.find()
...
You can even connect to multiple servers within a single shell using the connect
function:
> shard_db = connect("shard.example.com:27017/mydb")
connecting to shard.example.com:27017/mydb
mydb
>
The shell can also run shell commands:
> runProgram("echo", "Hello", "world")
shell: started mongo program echo Hello world
0
> sh6487| Hello world
(The output looks strange because the shell is running.)
 
Search WWH ::




Custom Search