I am trying to add a data node in replica set in MongoDB from Node.js but it is not adding the data node into the replica set
//This is my code
var Db = require('mongodb').Db,//The modules importing
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSet = require('mongodb').ReplSet,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Grid = require('mongodb').Grid,
Code = require('mongodb').Code,
assert = require('assert');
//The ip address of my machine and port number
MongoClient.connect('mongodb://192.168.0.10:27217/test', function(err, db) {
console.log(".....");
// Use the admin database for commands
var adminDb = db.admin();
console.log(".....Going");
// Default replica set conf
var conf = {
_id: "rpl0",
members: [
{
_id: 2,
host: "192.168.0.10:27217"
},
{
_id: 2,
host: "192.168.0.10:27317"
},
{
_id: 3,
host: "192.168.0.10:27417"
},
{
_id: 4,
host: "192.168.0.7:27017"
}
]
};
//The command for adding the member
adminDb.command({replSetConfig: conf}, function(err, info) {
console.log(info);
});
})
//This is what I am getting the output: .... .....Going undefined //I don't understand what wrong I am doing.
via kiranshahdadpuri
No comments:
Post a Comment