docker-compose.yml,我也为副本集启用了rs.initiate(config)。我在这里做错了什么?如何连接副本集。以及如何知道副本集的主要对象来启动mongo-connector。崩溃后,我看到Member techiez_db_container_1:27017 is now in state PRIMARY
日志。如何同步或等待mongo_one容器成为主要容器。
version: '3.3'
services:
mongo_one:
container_name: techiez_db_container_1
image: mongo
command: mongod --replSet techiez-set
ports: ['27017:27017']
networks: ['techiez']
mongo_two:
container_name: techiez_db_container_2
image: mongo
command: mongod --replSet techiez-set
ports: ['27018:27017']
networks: ['techiez']
mongo_three:
container_name: techiez_db_container_3
image: mongo
command: mongod --replSet techiez-set
ports: ['27019:27017']
networks: ['techiez']
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.16
container_name: elasticsearch
ports: ['9200:9200']
networks: [techiez]
mongoconnector:
image: yeasy/mongo-connector
links: ['elasticsearch:elasticsearch', 'mongo_one:mongo']
depends_on: ['mongo_one', 'mongo_two', 'mongo_three', 'elasticsearch']
networks: [techiez]
networks:
techiez: {}
下面是崩溃日志
mongoconnector_1 | Logging to mongo-connector.log.
mongoconnector_1 | Exception in thread Thread-1:
mongoconnector_1 | Traceback (most recent call last):
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 425, in __init__
mongoconnector_1 | self._ensure_connected(True)
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 1083, in _ensure_connected
mongoconnector_1 | self.__ensure_member()
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 957, in __ensure_member
mongoconnector_1 | member, nodes = self.__find_node()
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 1048, in __find_node
mongoconnector_1 | raise AutoReconnect(', '.join(errors))
mongoconnector_1 | pymongo.errors.AutoReconnect: mongo:27017 is not primary or master
mongoconnector_1 |
mongoconnector_1 | During handling of the above exception, another exception occurred:
mongoconnector_1 |
mongoconnector_1 | Traceback (most recent call last):
mongoconnector_1 | File "/usr/local/lib/python3.4/threading.py", line 920, in _bootstrap_inner
mongoconnector_1 | self.run()
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/mongo_connector/util.py", line 85, in wrapped
mongoconnector_1 | func(*args, **kwargs)
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/mongo_connector/connector.py", line 285, in run
mongoconnector_1 | tz_aware=self.tz_aware, **self.ssl_kwargs)
mongoconnector_1 | File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 428, in __init__
mongoconnector_1 | raise ConnectionFailure(str(e))
mongoconnector_1 | pymongo.errors.ConnectionFailure: mongo:27017 is not primary or master
mongoconnector_1 |
techiez_mongoconnector_1 exited with code 0