Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is it true that by default mongos and monod uses the same port 27017?

I had to pick a different port for one of these two. For example --port 37017 for mongos.

Did anyone have the same confusion?

Thanks,

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Yes, they have the same default port. Generally, the most common production set up is to have the mongos running on the application server, not the same host as the mongod, hence it is rare for this to cause a problem once you go beyond a development environment - if you are running a replica set on a single host for testing you similarly have to alter the ports for each mongod process.

There are a few reasons to run as you suggest (security policy, certain data distribution patterns), but as you have discovred, if you alter the port appropriately there is no issue running mongos and mongod on the same host.

share|improve this answer
    
My understanding is without sharding, mongo client/shell will connect to mongod at port 27017. With sharding, mongo client/shell will connect to mongos at port 27017. Is that correct? –  johnsam Jul 8 '13 at 13:28
    
I can see it's value to seperate the two. However, if I set up all mongo stuff on the db nodes which means mongos and mongod are on the same nodes. And leave application node which only contains mongo client, I think that's more cleaner. In case my mongo i/o is not too heavy, I mix mongodb with application in the same node, that should be allowed too? I hope such flexibility is not unacceptable? –  johnsam Jul 8 '13 at 13:32
1  
It's not that its unacceptable or acceptable (unless you hit resource issues), you just need to change ports if you run everything on the same host. The mongo shell will connect to localhost on port 27017 by default, it does not care whether the mongod or the mongos is running on that port - it can talk to either. You need to use the --port argument for the mongo shell to talk to the appropriate process as needed –  Adam C Jul 8 '13 at 15:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.