Closed Felk closed 3 years ago
sucks to be whoever has to do this, glad it's not me Kappa
I'm gonna do this
replication:
replSetName: rs0
rs.initiate()
to initialize the replication set. Check status with rs.status()
database_mongodb_uri
to mongodb://localhost:27017/?replicaSet=rs0
replication:
replSetName: rs0
rs.add({host: "192.168.0.42:27017", priority: 0, votes: 0})
SECONDARY
state. Check with rs.status()
. This may take a few minutes.rs.conf()
to see which node that is, probably index 1.
var cfg = rs.conf();
cfg.members[1].priority = 1
cfg.members[1].votes = 1
rs.reconfig(cfg)
database_mongodb_uri
to include the new node, e.g. mongodb://localhost:27017,192.168.0.42:27017/?replicaSet=rs0
db.isMaster()
and then execute rs.stepDown()
rs.status()
1/2
isn't enough, but 1/1
is). Check with rs.conf()
which index that is, in this example it is index 0 (execute on primary):
var cfg = rs.conf();
cfg.members[0].priority = 0
cfg.members[0].votes = 0
rs.reconfig(cfg)
rs.status()
if it finishes recovering and transitions to SECONDARY
state.1
db is now in replica mode. At least that went smoothly
pls finish this when possible
I am blocked. m4 needs to provide me with a machine to put a secondary database on
The database is now running in a 2-node replication set. The original database is still on 3.4, while the new one is now on 3.6. I reconfigured the replication set multiple times to transition the stream over to the new node without downtime. That seems to have worked without any problems except one uncritical error during the stepdown in the api:
[2020-07-08 21:43:10,814] tpp.webext log_exception():1892 ERROR Exception on /api/badges [GET]
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\flask\app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
...
File "C:\Program Files\Python36\lib\site-packages\pymongo\helpers.py", line 136, in _check_command_response
raise NotMasterError(errmsg, response)
pymongo.errors.NotMasterError: not master
I made the second node master with 1 vote 1 priority, took away the original database's votes and priority, and shut that one down. The stream is now operating on the new node on 3.6. I will let it run like that for a while before performing further updates.
stream is now running in a 3-node replica set config on MongoDB version 4.2
We are currently on MongoDB 3.4 The upgrade path roughly looks like this:
Being on a 4.2 server in replica mode will be required once we use the new core. Having a replica also has the advantage that we can continue to update and move the database server without any downtime in the future.