Convert offline replica set, not work

I need to convert an offline replica set

I am using the following documentation:

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

After doing the following:

mongod --port 27017 --replSet rs0 

in 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 the mongo shell, the results of the rs.initiate () and rs.status () command are as follows:

 > 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 what I am doing wrong or what I am missing.

Thank you for attention

+4
source share
2 answers

It looks like your Mongod already thinks this is part of the replicas. If you run "rs.status ()", you will probably see several hosts. In addition, the host name, which, in his opinion, is a mongod, should be resolved for himself. Do not use "localhost" as the host name in your replication configuration.

+4
source

See what you could do, I did the same on a separate PC

1.create 3 directory, in which data will be stored for example - c: / data / rep1, c: / data / rep2, c: / data / rep3

2. Close all previous mongodb instances

3. Through the command line, perform the following steps (if the ur path is set) else, go to the folder in which mongod exists

command line

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

new command line

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

new command line

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

now connect to any of mongod via another command line

 />mongo -port 27001 

then we need to write a replica set configuration

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

replication starts

 rs.status() 
-1
source

Source: https://habr.com/ru/post/1446328/


All Articles