Sanx
Sanx

Reputation: 323

Convert a Standalone to a Replica Set, not work

I need to Convert a Standalone to a Replica Set

I'm using the following documentation:

http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/

After executing the following:

mongod --port 27017 --replSet rs0 

in the terminal shows me the following

Thu Nov 15 10:07:57 [rsStart] trying to contact MY_HOST.local:27017 
Thu Nov 15 10:07:57 [rsStart] couldn't connect to MY_HOST.local:27017: 
couldn't connect to server MY_HOST.local:27017 
Thu Nov 15 10:07:57 [rsStart] replSet can't get local.system.replset 
config from self or any seed (yet) 

In mongo shell, the command results of rs.initiate() and rs.status(), are the following:

> rs.initiate() 

{ 
        "startupStatus" : 4, 
        "info" : "rs0", 
        "errmsg" : "all members and seeds must be reachable to initiate set", 
        "ok" : 0 
} 
>  rs.status() 

{ 
        "startupStatus" : 4, 
        "errmsg" : "can't currently get local.system.replset config from self 
or any seed (EMPTYUNREACHABLE)", 
        "ok" : 0 
} 

Please I need help and tell me I'm doing wrong or what I'm missing

Thanks for your attention

Upvotes: 4

Views: 5990

Answers (2)

sudarshan
sudarshan

Reputation: 9

See this is what you could do , I did same on stand alone PC

1.create 3 directory where data will be stored eg - c:/data/rep1 , c:/data/rep2 , c:/data/rep3

2.Close all previous instance of mongodb

3.Through command prompt do the following (if ur path is set) else go the folder where mongod exist

command prompt

/>mongod -port 27001 -dbpath -c:/data/rep1 -replSet replication

new command prompt

/>mongod -port 27002 -dbpath -c:/data/rep2 -replSet replication

new command prompt

/>mongod -port 27003 -dbpath -c:/data/rep3 -replSet replication

now connect to any of mongod via another command prompt

/>mongo -port 27001

then we need to write configuration of replica sets

cfg={_id:"replication",members:[{_id:1,host:"localhost:27001"},   
    {_id:2,host:"localhost:27002"},{_id:3,host:"localhost:27003"}] }

rs.initiate(cfg)

replication will start

rs.status()

Upvotes: -1

Derick
Derick

Reputation: 36794

It looks like your mongod already thinks it is part of a replicaset. If you run "rs.status()" you will probably see more than one host. Also, the hostname that mongod thinks it has, needs to be resolvable back to itself. Do not use "localhost" as a hostname in your replicaset configuration.

Upvotes: 4

Related Questions