Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
MongoDB High Availability

You're reading from  MongoDB High Availability

Product type Book
Published in Jul 2014
Publisher
ISBN-13 9781783986729
Pages 164 pages
Edition 1st Edition
Languages
Author (1):
Afshin Mehrabani Afshin Mehrabani
Profile icon Afshin Mehrabani

Table of Contents (17) Chapters

MongoDB High Availability
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Understanding the MongoDB Architecture and Processes Understanding MongoDB's Failures and Limitations Clustering in MongoDB Utilizing a Replica Set Replica Set in Action Understanding the Concept of Sharding Sharding in Action Analyzing and Improving Database Performance Migrating Instances and Reducing Downtime Monitoring and Troubleshooting the Database Index

Adding shards to mongos


After connecting to the mongos instance, you can add shards to sharding. Basically, you can add two types of endpoints to the mongos as a shard; a replica set or a standalone mongod instance.

MongoDB has a sh namespace and a function called addShard(), which is used to add a new shard to an existing sharding network. Here is the example of a command to add a new shard. This is shown in the following screenshot:

To add a replica set to mongos you should follow this scheme:

setname/server:port

For instance, if you have a replica set with the name of rs1, hostname mongod1.replicaset.com, and port number 27017, the command will be as follows:

sh.addShard("rs1/mongod1.replicaset.com:27017")

Using the same function, we can add standalone mongod instances. So, if we have a mongod instance with the hostname mongod1.sharding.com listening on port 27017, the command will be as follows:

sh.addShard("mongod1.sharding.com:27017")

Note

You can use a secondary or primary hostname to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}