2017-06-21 130 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})