MongoDB ReplicaSet system configuration and modeling
0
votes
1
answer
53
views
**I want to create a replica set model that look like this:**
PC 1 : ip=1.1.1.1 - The only one that writes
PC 2 : ip=2.2.2.2 - Read only
PC 3 : ip=3.3.3.3 - Read only
**Use-case:** On PC 1 I have a program that writes to the DB, on PC 2 and 3 I have a program that reads that data, I want to be able to access the data from each PC even if there is no connection. The solution I thought of is - creating a replica-set, that way data is replicated to each pc locally, the challenge is how to configure the replica set.
**System requirements:** Only pc 1 does the writing - meaning this is the primary If connection between the PC’s falls each PC should be able to work as stand alone, as far as I understand the solution for that is nominating that PC as primary therefore an arbiter is needed (you need a group of minimum 2 to do an election) - based on this requirement, each pc runs a DB instance and an arbiter. And this should look something like this:
members: [
{_id:0,host:“1.1.1.1:27017”,priority:10},
{_id:1,host:“1.1.1.1:27018”,arbiterOnly: true},
{_id:2,host:“2.2.2.2:27017”,priority:1},
{_id:3,host:“2.2.2.2:27018”,arbiterOnly: true},
{_id:4,host:“3.3.3.3:27017”,priority:1},
{_id:5,host:“3.3.3.3:27018”,arbiterOnly: true}
]
I have tested this scenario and closed PC1 and PC2 therefore PC3 has left alone; on PC3 the DB instance and arbiter are running, for some reason the instance on PC3 won’t become primary (meaning I cant access the DB and read). I would love knowing why.
Maybe this is the problem?
{“setDefaultRWConcern”: 1,“defaultWriteConcern”: { “w”: 2 },“defaultReadConcern”: { “level”: “majority” }}
Asked by Roman Milman
(1 rep)
Jul 30, 2024, 06:37 AM
Last activity: Aug 1, 2024, 09:27 AM
Last activity: Aug 1, 2024, 09:27 AM