Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pymongo.errors.OperationFailure: error

I started 3 mongod process each on different port with different dbpath.

./bin/mongod --replSet foo/tauquir:27018,tauquir:27019 --rest
./bin/mongod --port 27018 --dbpath /data/db1 --replSet foo/tauquir:27017 --rest
./bin/mongod --port 27019 --dbpath /data/db2 --replSet foo/tauquir:27017 --rest

Started the connection as:

CONN = Connection("tauquir:27017", slave_okay=True)
CONN.admin.command("replSetInitiate")
CONN = Connection(["tauquir:27018", "tauquir:27019"])

Traceback I am getting:

     CONN.admin.command("replSetInitiate")
              File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-
        i686.egg/pymongo/database.py", line 293, in command msg, allowable_errors)
              File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux- 
    i686.egg/pymongo/helpers.py", line 119, in _check_command_response raise 
OperationFailure(msg % response["errmsg"])
            pymongo.errors.OperationFailure: command SON([('replSetInitiate', 1)]) failed: 

all members and seeds must be reachable to initiate set
like image 877
Tauquir Avatar asked Nov 15 '22 04:11

Tauquir


1 Answers

replSetInitiate is a one time command so you probably don't want that coded with your connection init, but after that line you need to instantiate your python client with connection information for all 3 mongod servers.

In your example you are replacing your CONN variable with a connection only to 27018 and 27019

db = Connection(["tauquir:27017", "tauquir:27018", "tauquir:27019"])
like image 117
Jehiah Avatar answered Dec 14 '22 16:12

Jehiah