Hi guys, I’m having a problem when trying to connect to replica set. I’m trying to connect with compass and with python code, but nothing happens.
My docker-compose file:
version: "3.9"
services:
database:
image : 'mongo'
container_name: 'deibadb-container'
environment:
- PUID=1000
- PGID=1000
volumes:
- ./database:/data/db
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
ports:
- 27017:27017
restart: unless-stopped
mongo-express:
image: mongo-express:0.54
ports:
- "8081:8081"
environment:
ME_CONFIG_MONGODB_SERVER: database
depends_on:
- database
typesense:
image: typesense/typesense:0.21.0
ports:
- "8108:8108"
environment:
TYPESENSE_API_KEY: verbetes0key
TYPESENSE_DATA_DIR: /data/typesense
TYPESENSE_ENABLE_CORS: "true"
volumes:
- ./typesense:/data/typesense
My rs.status():
{
"set" : "rs0",
"date" : ISODate("2022-06-28T20:41:24.776Z"),
"myState" : 1,
"term" : NumberLong(1),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 1,
"writeMajorityCount" : 1,
"votingMembersCount" : 1,
"writableVotingMembersCount" : 1,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1656448876, 1),
"t" : NumberLong(1)
},
"lastCommittedWallTime" : ISODate("2022-06-28T20:41:16.041Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1656448876, 1),
"t" : NumberLong(1)
},
"appliedOpTime" : {
"ts" : Timestamp(1656448876, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1656448876, 1),
"t" : NumberLong(1)
},
"lastAppliedWallTime" : ISODate("2022-06-28T20:41:16.041Z"),
"lastDurableWallTime" : ISODate("2022-06-28T20:41:16.041Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1656448828, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2022-06-27T20:47:58.345Z"),
"electionTerm" : NumberLong(1),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(1656362878, 1),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1656362878, 1),
"t" : NumberLong(-1)
},
"numVotesNeeded" : 1,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"newTermStartDate" : ISODate("2022-06-27T20:47:58.368Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2022-06-27T20:47:58.379Z")
},
"members" : [
{
"_id" : 0,
"name" : "70b5125bd4e1:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 86088,
"optime" : {
"ts" : Timestamp(1656448876, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2022-06-28T20:41:16Z"),
"lastAppliedWallTime" : ISODate("2022-06-28T20:41:16.041Z"),
"lastDurableWallTime" : ISODate("2022-06-28T20:41:16.041Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1656362878, 2),
"electionDate" : ISODate("2022-06-27T20:47:58Z"),
"configVersion" : 3,
"configTerm" : 1,
"self" : true,
"lastHeartbeatMessage" : ""
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1656448876, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1656448876, 1)
}
When I trying from compass, a loading page still to trying connect. When trying from python code, I get:
pymongo.errors.ServerSelectionTimeoutError: Could not reach any servers in [(‘70b5125bd4e1’, 27017)]. Replica set is configured with internal hostnames or IPs?, Timeout: 30s, Topology Description: <TopologyDescription id: 62bc58af5e1aafde51de4af1, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription (‘70b5125bd4e1’, 27017) server_type: Unknown, rtt: None, error=AutoReconnect(‘70b5125bd4e1:27017: [Errno -3] Temporary failure in name resolution’)>]>
Could help me?