Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect Monstache(local machine) with my MongoDB containers(3 replicas) and elasticsearch containers. #703

Open
Praveen005 opened this issue Dec 4, 2023 · 0 comments

Comments

@Praveen005
Copy link

This is my Docker-Compose file:

`version: '3'
services:
mongo1:
container_name: mongo1
image: mongo
ports:
- "27017:27017"
command: mongod --replSet myReplicaSet --bind_ip localhost,mongo1
networks:
- mongo-network
mongo2:
container_name: mongo2
image: mongo
ports:
- "27018:27017"
command: mongod --replSet myReplicaSet --bind_ip localhost,mongo2
networks:
- mongo-network
mongo3:
container_name: mongo3
image: mongo
ports:
- "27019:27017"
command: mongod --replSet myReplicaSet --bind_ip localhost,mongo3
networks:
- mongo-network
mongoexpress:
container_name: mongoExpress
image: mongo-express
ports:
- "8081:8081"
environment:
- ME_CONFIG_MONGODB_SERVER=mongo1,mongo2,mongo3
networks:
- mongo-network
elasticsearch:
container_name: elasticsearch2
image: elasticsearch:8.11.1
ports:
- "9200:9200"
networks:
- mongo-network
kibana:
container_name: kibana2
image: kibana:8.11.1
ports:
- "5601:5601"
networks:
- mongo-network

networks:
mongo-network:
external: true

`

Initiating the replica:

rs.initiate( { _id : "myReplicaSet", members: [ { _id: 0, host: "mongo1:27017" }, { _id: 1, host: "mongo2:27017" }, { _id: 2, host: "mongo3:27017" } ] })

This is my rs.status() log:

{ set: 'myReplicaSet', date: ISODate("2023-12-04T17:12:23.927Z"), myState: 2, term: Long("9"), syncSourceHost: 'mongo3:27017', syncSourceId: 2, heartbeatIntervalMillis: Long("2000"), majorityVoteCount: 2, writeMajorityCount: 2, votingMembersCount: 3, writableVotingMembersCount: 3, optimes: { lastCommittedOpTime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, lastCommittedWallTime: ISODate("2023-12-04T17:12:21.595Z"), readConcernMajorityOpTime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, appliedOpTime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, durableOpTime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, lastAppliedWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastDurableWallTime: ISODate("2023-12-04T17:12:21.595Z") }, lastStableRecoveryTimestamp: Timestamp({ t: 1701709931, i: 1 }), electionParticipantMetrics: { votedForCandidate: true, electionTerm: Long("9"), lastVoteDate: ISODate("2023-12-04T14:24:38.971Z"), electionCandidateMemberId: 1, voteReason: '', lastAppliedOpTimeAtElection: { ts: Timestamp({ t: 1701699191, i: 1 }), t: Long("7") }, maxAppliedOpTimeInSet: { ts: Timestamp({ t: 1701699191, i: 1 }), t: Long("7") }, priorityAtElection: 1, newTermStartDate: ISODate("2023-12-04T14:24:39.126Z"), newTermAppliedDate: ISODate("2023-12-04T14:24:39.709Z") }, members: [ { _id: 0, name: 'mongo1:27017', health: 1, state: 2, stateStr: 'SECONDARY', uptime: 18695, optime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, optimeDate: ISODate("2023-12-04T17:12:21.000Z"), lastAppliedWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastDurableWallTime: ISODate("2023-12-04T17:12:21.595Z"), syncSourceHost: 'mongo3:27017', syncSourceId: 2, infoMessage: '', configVersion: 1, configTerm: 9, self: true, lastHeartbeatMessage: '' }, { _id: 1, name: 'mongo2:27017', health: 1, state: 1, stateStr: 'PRIMARY', uptime: 18685, optime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, optimeDurable: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, optimeDate: ISODate("2023-12-04T17:12:21.000Z"), optimeDurableDate: ISODate("2023-12-04T17:12:21.000Z"), lastAppliedWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastDurableWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastHeartbeat: ISODate("2023-12-04T17:12:23.508Z"), lastHeartbeatRecv: ISODate("2023-12-04T17:12:23.508Z"), pingMs: Long("0"), lastHeartbeatMessage: '', syncSourceHost: '', syncSourceId: -1, infoMessage: '', electionTime: Timestamp({ t: 1701699878, i: 1 }), electionDate: ISODate("2023-12-04T14:24:38.000Z"), configVersion: 1, configTerm: 9 }, { _id: 2, name: 'mongo3:27017', health: 1, state: 2, stateStr: 'SECONDARY', uptime: 18685, optime: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, optimeDurable: { ts: Timestamp({ t: 1701709941, i: 1 }), t: Long("9") }, optimeDate: ISODate("2023-12-04T17:12:21.000Z"), optimeDurableDate: ISODate("2023-12-04T17:12:21.000Z"), lastAppliedWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastDurableWallTime: ISODate("2023-12-04T17:12:21.595Z"), lastHeartbeat: ISODate("2023-12-04T17:12:22.527Z"), lastHeartbeatRecv: ISODate("2023-12-04T17:12:22.717Z"), pingMs: Long("0"), lastHeartbeatMessage: '', syncSourceHost: 'mongo2:27017', syncSourceId: 1, infoMessage: '', configVersion: 1, configTerm: 9 } ], ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1701709941, i: 1 }), signature: { hash: Binary.createFromBase64("AAAAAAAAAAAAAAAAAAAAAAAAAAA=", 0), keyId: Long("0") } }, operationTime: Timestamp({ t: 1701709941, i: 1 }) }

my docker network inspect mongo-network log:

[ { "Name": "mongo-network", "Id": "cbc9087f5f6edf6128255c9e2786e9e3fa2225a79001f87a3896c096d63f0493", "Created": "2023-11-23T06:51:49.060040502Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": {}, "Config": [ { "Subnet": "172.18.0.0/16", "Gateway": "172.18.0.1" } ] }, "Internal": false, "Attachable": false, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": { "7c32e3798daa4c6718d4dd3e32ae7855d6299130fb8f28e9d76f6089b4cd404e": { "Name": "mongo2", "EndpointID": "7e3132ea74c7721ff9f20b9878e07f260cf665dcc253d6447d9ad37d618a1a1e", "MacAddress": "02:42:ac:12:00:02", "IPv4Address": "172.18.0.2/16", "IPv6Address": "" }, "a1f24019e52a807d044553288ca5f0f4d1f9a5dc3e674537be70c292b2f26507": { "Name": "mongo1", "EndpointID": "999717e4bd69411c728686f596318c73fa5d0e15fbfd8fb37a8aded6e6c9f43c", "MacAddress": "02:42:ac:12:00:03", "IPv4Address": "172.18.0.3/16", "IPv6Address": "" }, "ac8bfceea4b9da75b55db1e0c4d70c76aab51b0a8c2de2e8cd95fb04b5cddef4": { "Name": "mongoExpress", "EndpointID": "544cb0f99f3a4c5f6087b1067067b8a8f3abb8c0d9090c4295ca98075eef515f", "MacAddress": "02:42:ac:12:00:05", "IPv4Address": "172.18.0.5/16", "IPv6Address": "" }, "cf170c8b65b526dc04bb35f13656439ea65f666acbab4c9b1e2dc3840c5ef7d1": { "Name": "kibana2", "EndpointID": "69169b23fa4a73cbd152f5e184d391bc55dd26d03f5b45662ee34fecca6532ee", "MacAddress": "02:42:ac:12:00:04", "IPv4Address": "172.18.0.4/16", "IPv6Address": "" }, "dac748ac8a7d1f1dd76b4c8239870eabed3a0dbb0a3987d64cc13871bd9e2e5a": { "Name": "elasticsearch2", "EndpointID": "f4556041098f16a287c374a235f7fb2aacf135e69a147883e0110b4ec3ad7959", "MacAddress": "02:42:ac:12:00:06", "IPv4Address": "172.18.0.6/16", "IPv6Address": "" }, "f81cc2470acc8597e5dd262edf85aa02c06486940fa7904763af5cca100905fd": { "Name": "mongo3", "EndpointID": "2ae94419bcb64f6a051dead4332896f3eb61d6bb3d1cf3072e30b12193a25d8a", "MacAddress": "02:42:ac:12:00:07", "IPv4Address": "172.18.0.7/16", "IPv6Address": "" } }, "Options": {}, "Labels": {} } ]

Config.toml:

connection settings

mongo-url = "mongodb://127.0.0.1:27017"

elasticsearch-urls = ["http://localhost:9200"]

namespace-regex = '^logIngestorDB.logs$'

gzip = true

stats = true
index-stats = true

replay = false

resume = true

resume-write-unsafe = false
resume-name = "default"

verbose = true

cluster-name = 'logCluster'

exit-after-direct-reads = false

I got the following with mongo-url = "mongodb://127.0.0.1:27017" :

INFO 2023/12/04 22:51:11 Started monstache version 6.7.14
INFO 2023/12/04 22:51:11 Go version go1.21.2
INFO 2023/12/04 22:51:11 MongoDB go driver v1.12.1
INFO 2023/12/04 22:51:11 Elasticsearch go driver 7.0.31
INFO 2023/12/04 22:51:11 Successfully connected to MongoDB version 7.0.3
INFO 2023/12/04 22:51:12 Successfully connected to Elasticsearch version 8.11.1
INFO 2023/12/04 22:51:12 Sending systemd READY=1
WARN 2023/12/04 22:51:12 Systemd notification not supported (i.e. NOTIFY_SOCKET is unset)
INFO 2023/12/04 22:51:12 Joined cluster logCluster
INFO 2023/12/04 22:51:12 Starting work for cluster logCluster
INFO 2023/12/04 22:51:12 Listening for events
INFO 2023/12/04 22:51:12 Watching changes on collection logIngestorDB.logs
INFO 2023/12/04 22:51:12 Resuming from timestamp {T:0 I:0}
ERROR 2023/12/04 22:51:12 Error starting change stream: (Location40573) The $changeStream stage is only supported on replica sets
ERROR 2023/12/04 22:51:12 element not found

with mongo-url= "mongodb://mongo1:27017,mongo2:27018,mongo3:27019" I got:

ERROR 2023/12/04 22:54:53 Unable to connect to MongoDB using URL mongodb://mongo1:27017,mongo2:27018,mongo3:27019: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: mongo1:27017, Type: Unknown, Last error: dial tcp: lookup mongo1: no such host }, { Addr: mongo2:27018, Type: Unknown, Last error: dial tcp: lookup mongo2: no such host }, { Addr: mongo3:27019, Type: Unknown, Last error: dial tcp: lookup mongo3: no such host }, ] }

PS: I also tried using direct IPs instead of mongo1, mongo2 and mongo3 in the URL, But same result.

Also, Monstache is running on my local machine, whereas rest are docker containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant