Я пытаюсь подключиться к MongoDB с помощью MongoDB Compass 1.20.4
Моя строка подключения:
mongodb://localhost:27017/?replicaSet=rs0
Вот моя установка MongoDB docker:
version: '3'
services:
mongo0:
hostname: mongo0
container_name: mongo0
image: mongo
ports:
- 27017:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
mongo1:
hostname: mongo1
container_name: mongo1
image: mongo
ports:
- 27018:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
mongosetup:
hostname: mongosetup
container_name: mongosetup
image: mongo
depends_on:
- mongo0
- mongo1
volumes:
- ./scripts/:/scripts
restart: "no"
entrypoint: [ "bash", "/scripts/mongo-setup.sh" ]
mon go -setup. sh
#!/bin/bash
sleep 10
mongo --host mongo0:27017 <<EOF
var config={"_id":"rs0","members":[{"_id":0,"host":"mongo0:27017"},{"_id":1,"host":"mongo1:27017"}]};
rs.initiate(config);
EOF
Вот что я вижу в моих docker журналах:
mongo0 | 2020-02-02T14:42:35.114+0000 I NETWORK [listener] connection accepted from 172.27.0.1:55494 #31 (4 connections now open)
mongo0 | 2020-02-02T14:42:35.115+0000 I NETWORK [conn31] received client metadata from 172.27.0.1:55494 conn31: { driver: { name: "nodejs", version: "3.4.0" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "19.3.0" }, platform: "'Node.js v10.2.0, LE (unified)", application: { name: "MongoDB Compass" } }
mongo0 | 2020-02-02T14:42:35.120+0000 I NETWORK [conn31] end connection 172.27.0.1:55494 (3 connections now open)
До использования набора реплик он подключен просто отлично, также Studio 3T отлично работает с этой настройкой. Буду признателен за любую помощь