replication - How to configure a replica set with MongoDB -


i've got problem can't solve. partly because can't explain right terms. i'm new sorry clumsy question.

below can see overview of goal.

i want configure replication set in mongodb tried

use local db.dropdatabase()  config = { _id: "rs0", members:[ {_id: 0, host: 'localhost:27017'}] }  rs.initiate(config) 

i hope every thing correct here showing following error message

{ "errmsg" : "server not running --replset", "ok" : 0 } 

anything wrong did here ?

any ideas ?

you can follow mongodb manual setup replica set. it's pretty clear. here critical steps described below:

  1. change configuration file , add following line.don't mess master/slave replication, because replica set meant replacement of master/slave replication. may want remove master/slave related config configuration files.

    replset = [set name] 
  2. restart mongod instance:

    systemctl restart mongodb // or service mongod restart 
  3. go local database , initiate replica set. don't pass initiate function, , mongodb handle well. note use hostname name of current instance , know it's not easy change. may want change host name before doing so.

    use local rs.initiate() 

that's it. set go. if have other member join set, need 1/2 steps, , go primary instance , type:

rs.add("hostname:port") 

only when want change configs of replica set, need type:

var conf = rs.conf(); // change conf here rs.reconfig(conf); 

note lead server offline little bit time. if doing online, careful.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -