Walt Stoneburner
Walt Stoneburner

Reputation: 2612

Using --rest with MongoDB's mongos

I've created a small MongoDB v2.6.4 cluster with one mongos router, three config servers, and handful of mongod data servers. It's working fine, I can do CRUD operations just fine from the mongos client, which directs to the appropriate shards.

I'm now wanting to experiment with the rest service.

When I tried this with a single MongoDB data server using mongod, it worked exactly as prescribed.

Even now, I can connect to each shard which is running with --rest and get a web response. But, the results are a little unexpected. I see the overview, clients, dbtop, write lock, log, etc. And if I click on listDatabase, I actually see my database listed. However, any REST attempts I try return with a JSON object showing offest 0, no rows, total of 0 roes, no query, and 0 milliseconds.

At the moment I'm of the opinion that this doesn't matter, as I've directly connected to a shard and would anticipate only seeing just the contents of that shard -- although further experimentation has been unable to produce even that result.

Again, I'll stress that in the current sharded configuration, mongos, NodeJS, and PHP all can see, query, and manipulate the data within my MongoDB collection just fine.

However, what I'm trying to do (if it's even possible) is connect to the mongos shard service via REST, since it does offer the --httpinterface option, figuring it will expose access to the shards and do the right thing.

It delivers the standard status page, but clicking on any links or hand rolling any REST results in a message about --rest not being enabled and that I should enable it.

REST is not enabled, use --rest to turn on.
check that port 28017 is secured for the network too.

Problem is, mongos doesn't allow that as an option!       (mongod, however does)

  1. It is entirely possible this is correct behavior, but I'm not sure how REST services would then work in a sharded configuration.
  2. I'm not using a configuration file, specifying everything by the command line. That said, I tried passing a config file with RESTInterfaceEnabled: true in the yaml, and it didn't help.
  3. mongos is returning a web interface, with the List all commands, db version, and log. It's missing the other diagnostic information (that's usually mongod specific), which I'd perhaps expect. But the links it offers doesn't work -- all requesting me to turn on an option that isn't there.
  4. I've manually checked each shard data server (running mongod with --shardsvr), and directly connecting to them does provide REST access.
  5. Everything else about the sharded cluster is working perfectly. I just can't to REST, like I can in a single-node unsharded solution and access my database or collections.

What might I have missed? Is this even possible? Any ideas?

Upvotes: 0

Views: 1373

Answers (1)

Tug Grall
Tug Grall

Reputation: 3520

AFAIK the REST Interface is inly to do monitoring/management not to access the documents. MongoDB does not provide official REST interface to do CRUD operations. For this you need either to create your own or find a library in the ecosystem to do this, look at http://docs.mongodb.org/ecosystem/tools/http-interfaces/

Do you have specific requirements/needs in mind?

PS : I do not use the --rest parameter in any of my deployment/development.

Upvotes: 2

Related Questions