{"id":13567,"date":"2013-07-02T19:00:59","date_gmt":"2013-07-02T16:00:59","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=13567"},"modified":"2013-07-02T12:35:36","modified_gmt":"2013-07-02T09:35:36","slug":"setup-mongodb-replica-set-in-4-steps","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html","title":{"rendered":"Setup MongoDB Replica Set in 4 steps"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Before going into details of configuring MongoDB replica sets, let me give brief details about same:<\/p>\n<ul>\n<li>Replica Set is the feature provided by the Mongodb database to achieve high availability and automatic failover.<\/li>\n<li>It is kinda traditional master-slave configuration but have capability of automatic failover.<\/li>\n<li>It is basically group\/cluster of the mongod instances which communicates, replicates to each other to provide high availability and to do automatic failover<\/li>\n<li>Basically, in replica sets there are minimum 2 and maximum of 12 mongod instances can exist<\/li>\n<li>In replica set following types of server exist. out of all, one server is always primary.\n<ul>\n<li><strong>Primary:<\/strong>\u00a0It stores the data, all write\/read operation goes to this server from any client.<\/li>\n<li><strong>Secondary: <\/strong>First it stores the data, second these servers stays in sync with primary, if \u00a0\u00a0primary server goes down then these servers are for failover to the primary.<\/li>\n<li><strong>BackUp:<\/strong> It stores backup data and as name says, it meant for backup only although it never becomes primary<\/li>\n<li><strong>Arbiter:<\/strong> It stores the no data, it meant only for participate in election during failover.<\/li>\n<\/ul>\n<li>It provides automatic failover meaning that it doesn\u2019t require human intervention to make another server as primary and it has internal mechanism to elect new primary server.<\/li>\n<li>In replica set, if primary server goes down due to network error or other servers in replica sets not able to reach to primary server or primary become unresponsive then internally by all servers election mechanism is triggered to elect new primary server and all this is very automatic.<\/li>\n<\/ul>\n<p>In this article, i am going to show you configuration of the 3 member\/node cluster replica set in 4 easy steps. In this replica set configuration, we will make two data servers in which one will be primary, \u00a0another will be secondary and other one non-data server which is arbiter. So, lets go ahead and configure the replica in following 4 steps:<\/p>\n<h2>Step-1 : Setup the each instance of replica set<\/h2>\n<p>Create and setup 3 new instances of mongodb server instance the as i discussed in last article with following information but don\u2019t start these server instances:<\/p>\n<ul>\n<li><strong>server-1<\/strong><\/li>\n<\/ul>\n<pre class=\"brush:bash\">port = 27017\r\n\r\ndirectory path =&lt;dir path&gt;\\ rs1\r\n\r\nE.g.directory structure :  I:\\workspace\\mongo\\rs1\\bin<\/pre>\n<ul>\n<li><strong>server-2<\/strong><\/li>\n<\/ul>\n<pre class=\"brush:bash\">port = 26017\r\n\r\ndirectory path =&lt;dir path&gt;\\ rs2\r\n\r\nE.g.directory structure  I:\\workspace\\mongo\\rs2\\bin<\/pre>\n<ul>\n<li><strong>server-3<\/strong><\/li>\n<\/ul>\n<pre class=\"brush:bash\">port = 25017\r\n\r\ndirectory path =&lt;dir path&gt;\\ rs2\r\n\r\nE.g.directory structure  I:\\workspace\\mongo\\rs3\\bin<\/pre>\n<h2>Step-2 : modify the mongodb.conf to include replica set information<\/h2>\n<p>Edit the <em>mongod.conf<\/em> \u00a0of each server to Include the following properties:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li><strong>replSet<\/strong> = unique name for replica set which is given to all members<\/li>\n<li><strong>rest<\/strong> = to enable rest interface for admin web page<\/li>\n<\/ul>\n<p>You can give any name to replica sets but make sure that it is same for all members. Go ahead give any name you want. Here, i am using \u00a0name \u2018damon\u2019<\/p>\n<p>E.g. append following into <em>mongod.conf<\/em> file<\/p>\n<pre class=\"brush:bash\">replSet=damon\r\nrest=true<\/pre>\n<h2>Step-3 : start the all the server up<\/h2>\n<p>After necessary configuration, go ahead and start the server in any order<\/p>\n<pre class=\"brush:bash\">rs1 &gt;&gt; mongod -f \\rs1\\mongod.conf\r\nrs2 &gt;&gt; mongod -f \\rs2\\mongod.conf\r\nrs3 &gt;&gt; mongod -f \\rs3\\mongod.conf<\/pre>\n<h2>Step-4 : configure the servers to include in replica set<\/h2>\n<p>Now, all the servers are up but they aren\u2019t connected to each other. In other words, they are not part of replica set. So, for that we need to do following. Again, we going to create the two data server i,e one primary, another secondary and one arbiter server. Now, connect to any one of the server using mongo shell provided in MongoDB binaries.<\/p>\n<p>Here. lets connect to server <em>rs1 <\/em>using mongodb shell<\/p>\n<pre class=\"brush:bash\">rs1 &gt; \/rs1\/bin\/mongo.exe --port 27017<\/pre>\n<p>After this you will get the prompt for mongo shell as shown in following figure:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase645e9fd8342dd15fa1.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase645e9fd8342dd15fa1-300x51.png\" alt=\"png;base645e9fd8342dd15fa1\" width=\"300\" height=\"51\" class=\"aligncenter size-medium wp-image-15066\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase645e9fd8342dd15fa1-300x51.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase645e9fd8342dd15fa1.png 556w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>For replica configuration, mongo shell provides the predefined object rs which contains the following functions for configuration:<\/p>\n<ul>\n<li><strong>initiate()<\/strong> =&gt; creates the replica set configuration in current server<\/li>\n<li><strong>status()<\/strong> =&gt; gives the current status of replica set to which server is part of<\/li>\n<li><strong>add(serverInfo)<\/strong> =&gt; adds the new server (provided as param) in replica set.<\/li>\n<li><strong>addArb(serverInfo)<\/strong> =&gt; specialized function for adding the arbiter in the replica set<\/li>\n<\/ul>\n<p>First we need to create the replica set configuration in one of server. Go and hit the following command in mongo shell:<\/p>\n<pre class=\"brush:bash\">&gt; rs.initiate()<\/pre>\n<p>After the you see following in prompt:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64838a3d5dc722c104.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64838a3d5dc722c104-300x61.png\" alt=\"png;base64838a3d5dc722c104\" width=\"300\" height=\"61\" class=\"aligncenter size-medium wp-image-15067\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64838a3d5dc722c104-300x61.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64838a3d5dc722c104.png 848w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This will create the necessary replica sets information locally for this server and you will notice prompt changing from initial <em>\u2018&gt;\u2019<\/em> to<em> \u2018damon:STARTUP2 &gt;\u2019<\/em> which is indicating <em>&lt;replicaSetName:State of server &gt;<\/em><\/p>\n<p>You can enter the<em> rs.status() <\/em>in the shell prompt to check how many servers are in replica set:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase642ef0ef96d4cc2826.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase642ef0ef96d4cc2826-300x158.png\" alt=\"png;base642ef0ef96d4cc2826\" width=\"300\" height=\"158\" class=\"aligncenter size-medium wp-image-15069\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase642ef0ef96d4cc2826-300x158.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase642ef0ef96d4cc2826.png 743w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As you can see we only have the only one server added in replica set which is current server, whose state is primary.<\/p>\n<p>Other way of checking for the members in replica is use following URL in your browser address bar  http:\/\/<machine-name>:<port>\/_replSet . In our case, \u00a0 http:\/\/localhost:28017\/_replSet<br \/>\nNote that, this requires rest=true to enabled in config file.(and we did it already! ). This one can be preferred way of checking for states of servers in replica sets.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase648c9b0542e15ba78.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase648c9b0542e15ba78-300x113.png\" alt=\"png;base648c9b0542e15ba78\" width=\"300\" height=\"113\" class=\"aligncenter size-medium wp-image-15070\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase648c9b0542e15ba78-300x113.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase648c9b0542e15ba78-1024x388.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase648c9b0542e15ba78.png 1059w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now we have the one server added in replica, lets add the rest of servers.<\/p>\n<p>For<em> add()<\/em> and <em>addArb()<\/em> method we are going to provide the string param that contains <em>&lt;machine\/host-name&gt; : &lt;port-no-of-server&gt;<\/em><\/p>\n<p>(Please note, that if you want machine name then use <em>hostname<\/em> command in dos or bash shell )<\/p>\n<pre class=\" brush:bash\">rs.add(\u201c&lt;machine\/host-name&gt;:26017\u201d)<\/pre>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6451a8e8144fb9bf78.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6451a8e8144fb9bf78-300x51.png\" alt=\"png;base6451a8e8144fb9bf78\" width=\"300\" height=\"51\" class=\"aligncenter size-medium wp-image-15071\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6451a8e8144fb9bf78-300x51.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6451a8e8144fb9bf78.png 500w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre class=\" brush:bash\">rs.addArb(\u201c&lt;machine\/host-name&gt;:25017\u201d)<\/pre>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6471cda960ad51ffc4.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6471cda960ad51ffc4-300x63.png\" alt=\"png;base6471cda960ad51ffc4\" width=\"300\" height=\"63\" class=\"aligncenter size-medium wp-image-15072\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6471cda960ad51ffc4-300x63.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase6471cda960ad51ffc4.png 475w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Lets check whether node\/member added using<em> rs.status()<\/em> command:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64bc2381387562ac74.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64bc2381387562ac74-280x300.png\" alt=\"png;base64bc2381387562ac74\" width=\"280\" height=\"300\" class=\"aligncenter size-medium wp-image-15073\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64bc2381387562ac74-280x300.png 280w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64bc2381387562ac74.png 569w\" sizes=\"(max-width: 280px) 100vw, 280px\" \/><\/a><\/p>\n<p>or using the browser based:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64281be3bd5613c0e2.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64281be3bd5613c0e2-300x232.png\" alt=\"png;base64281be3bd5613c0e2\" width=\"300\" height=\"232\" class=\"aligncenter size-medium wp-image-15074\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64281be3bd5613c0e2-300x232.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/07\/pngbase64281be3bd5613c0e2.png 941w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And here we configured the 3 node replica set MongoDB database cluster. Although this piece of information can be applied to configuring any no. of node in replica set.<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/blog.ajduke.in\/2013\/05\/31\/setup-mongodb-replica-set-in-4-steps\/\">Setup MongoDB Replica Set in 4 steps<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Abhijeet Sutar at the <a href=\"http:\/\/blog.ajduke.in\/\">Another Java Duke<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by the Mongodb database to achieve high availability and automatic failover. It is kinda traditional master-slave configuration but have capability of automatic failover. It is basically group\/cluster of the mongod instances which &hellip;<\/p>\n","protected":false},"author":297,"featured_media":187,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[112,113],"class_list":["post-13567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-mongodb","tag-nosql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setup MongoDB Replica Set in 4 steps<\/title>\n<meta name=\"description\" content=\"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setup MongoDB Replica Set in 4 steps\" \/>\n<meta property=\"og:description\" content=\"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-07-02T16:00:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Abhijeet Sutar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/_ajduke\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhijeet Sutar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html\"},\"author\":{\"name\":\"Abhijeet Sutar\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/8a924d20452461f7a32dbf350ecb9faa\"},\"headline\":\"Setup MongoDB Replica Set in 4 steps\",\"datePublished\":\"2013-07-02T16:00:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html\"},\"wordCount\":905,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"keywords\":[\"MongoDB\",\"NoSQL\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html\",\"name\":\"Setup MongoDB Replica Set in 4 steps\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"datePublished\":\"2013-07-02T16:00:59+00:00\",\"description\":\"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/07\\\/setup-mongodb-replica-set-in-4-steps.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Setup MongoDB Replica Set in 4 steps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/8a924d20452461f7a32dbf350ecb9faa\",\"name\":\"Abhijeet Sutar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g\",\"caption\":\"Abhijeet Sutar\"},\"description\":\"Abhijeet (ajduke) is self-taught, self-organized software developer. His current go to language is Java and also he is exploring other languages such as Scala, Ruby.\",\"sameAs\":[\"http:\\\/\\\/blog.ajduke.in\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/ajduke\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/_ajduke\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/abhijeet-sutar\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setup MongoDB Replica Set in 4 steps","description":"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html","og_locale":"en_US","og_type":"article","og_title":"Setup MongoDB Replica Set in 4 steps","og_description":"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by","og_url":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-07-02T16:00:59+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Abhijeet Sutar","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/_ajduke","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Abhijeet Sutar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html"},"author":{"name":"Abhijeet Sutar","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/8a924d20452461f7a32dbf350ecb9faa"},"headline":"Setup MongoDB Replica Set in 4 steps","datePublished":"2013-07-02T16:00:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html"},"wordCount":905,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","keywords":["MongoDB","NoSQL"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html","url":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html","name":"Setup MongoDB Replica Set in 4 steps","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","datePublished":"2013-07-02T16:00:59+00:00","description":"Introduction Before going into details of configuring MongoDB replica sets, let me give brief details about same: Replica Set is the feature provided by","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/07\/setup-mongodb-replica-set-in-4-steps.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Setup MongoDB Replica Set in 4 steps"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/8a924d20452461f7a32dbf350ecb9faa","name":"Abhijeet Sutar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d37b9e8b23c65278f800401ed31ecbcd591e54ff336174c403e96ee0286e1b33?s=96&d=mm&r=g","caption":"Abhijeet Sutar"},"description":"Abhijeet (ajduke) is self-taught, self-organized software developer. His current go to language is Java and also he is exploring other languages such as Scala, Ruby.","sameAs":["http:\/\/blog.ajduke.in\/","http:\/\/www.linkedin.com\/in\/ajduke","https:\/\/x.com\/https:\/\/twitter.com\/_ajduke"],"url":"https:\/\/www.javacodegeeks.com\/author\/abhijeet-sutar"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/13567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/297"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=13567"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/13567\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/187"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=13567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=13567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=13567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}