无法连接 mongoDB 和 neo4j
unable to connect mongoDB and neo4j
我正在按照 URL https://neo4j.com/developer/neo4j-doc-manager/ 中提供的步骤连接 mongoDb 和 neo4j。
- 在终端启动时,mongod --replSet myDevReplSet
- 在新终端启动mongoshell,mongo
- 在 shell
中输入了 rs.initiate()
- 再次在新终端输入,mongo-connector -m localhost: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()"
您应该在 MongoDB 中至少有一个副本集成员。
您可以在mongo shell中使用rs.conf()命令查询成员。
如果它没有成员,那么你可以这样做:
cfg = {
... "_id" : "rs0",
... "version" : 1,
... "members" : [
... {
... "_id" : 0,
... "host" : "localhost:27017"
... }
... ]
... }
>rs.reconfig(cfg, {force:true})
我正在按照 URL https://neo4j.com/developer/neo4j-doc-manager/ 中提供的步骤连接 mongoDb 和 neo4j。
- 在终端启动时,mongod --replSet myDevReplSet
- 在新终端启动mongoshell,mongo
- 在 shell 中输入了 rs.initiate()
- 再次在新终端输入,mongo-connector -m localhost: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()"
您应该在 MongoDB 中至少有一个副本集成员。 您可以在mongo shell中使用rs.conf()命令查询成员。 如果它没有成员,那么你可以这样做:
cfg = {
... "_id" : "rs0",
... "version" : 1,
... "members" : [
... {
... "_id" : 0,
... "host" : "localhost:27017"
... }
... ]
... }
>rs.reconfig(cfg, {force:true})