2017-06-21 89 views
0

我按照URL https://neo4j.com/developer/neo4j-doc-manager/提供的步驟連接mongoDb和neo4j。無法連接mongoDB和neo4j

  1. 在終端在殼
  2. 開始,mongod的--replSet myDevReplSet
  3. 在新終端中起動蒙戈殼,蒙戈
  4. 鍵入rs.initiate()同樣,在輸入新的終端,蒙戈連接器 - 米本地主機:27017 -t http://localhost:7474/db/data -d neo4j_doc_manager

,但我得到一個錯誤:

Exception in thread Thread-1: Traceback (most recent call last): File "/Users/gauravvashisth/anaconda/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/mongo_connector/util.py", line 104, in wrapped func(*args, **kwargs) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/mongo_connector/connector.py", line 382, in run self.update_version_from_client(self.main_conn) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/mongo_connector/connector.py", line 334, in update_version_from_client is_master = client.admin.command("isMaster") File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/pymongo/database.py", line 491, in command with client._socket_for_reads(read_preference) as (sock_info, slave_ok): File "/Users/gauravvashisth/anaconda/lib/python3.5/contextlib.py", line 59, in enter return next(self.gen) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/pymongo/mongo_client.py", line 859, in _socket_for_reads with self._get_socket(read_preference) as sock_info: File "/Users/gauravvashisth/anaconda/lib/python3.5/contextlib.py", line 59, in enter return next(self.gen) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/pymongo/mongo_client.py", line 823, in _get_socket server = self._get_topology().select_server(selector) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/pymongo/topology.py", line 214, in select_server address)) File "/Users/gauravvashisth/anaconda/lib/python3.5/site-packages/pymongo/topology.py", line 189, in select_servers self._error_message(selector))

pymongo.errors.ServerSelectionTimeoutError: No replica set members match selector "Primary()"

回答

0

您應該在MongoDB中至少有一個replicaset成員。 您可以在mongo shell中使用rs.conf()命令查詢成員。 如果它沒有會員,那麼你可以這樣做:

cfg = { 
    ...  "_id" : "rs0", 
    ...  "version" : 1, 
    ...  "members" : [ 
    ...   { 
    ...    "_id" : 0, 
    ...    "host" : "localhost:27017" 
    ...   } 
    ...  ] 
    ... } 

    >rs.reconfig(cfg, {force:true})