lihongjie0209 / myblog

4 stars 0 forks source link

MongoDB: 升级 #39

Open lihongjie0209 opened 4 years ago

lihongjie0209 commented 4 years ago

单机节点升级

主要就是备份一下数据, 然后使用包管理工具升级mongod二进制文件, 然后重启就可以了。

lihongjie0209 commented 4 years ago

复制集升级

复制集升级采用的先升级从节点, 升级方式和单机节点一致。

升级完成之后重启节点, 等待与主节点同步, 同步成功之后升级完成。

Upgrade Secondaries

Upgrade each secondary separately as follows:

Upgrade the secondary’s mongod binary by following the instructions in Upgrade a MongoDB Instance.

After upgrading a secondary, wait for the secondary to recover to the SECONDARY state before upgrading the next instance. To check the member’s state, issue rs.status() in the mongo shell.

The secondary may briefly go into STARTUP2 or RECOVERING. This is normal. Make sure to wait for the secondary to fully recover to SECONDARY before you continue the upgrade.

等所有的从节点升级完成之后, 把主节点从复制集中摘除, 等待复制集选出新的主节点。

升级完主节点之后再加入到复制集。

Upgrade the Primary

Step down the primary to initiate the normal failover procedure. Using one of the following:

The rs.stepDown() helper in the mongo shell. The replSetStepDown database command. During failover, the set cannot accept writes. Typically this takes 10-20 seconds. Plan the upgrade during a predefined maintenance window.

NOTE

Stepping down the primary is preferable to directly shutting down the primary. Stepping down expedites the failover procedure.

Once the primary has stepped down, call the rs.status() method from the mongo shell until you see that another member has assumed the PRIMARY state.

Shut down the original primary and upgrade its instance by following the instructions in Upgrade a MongoDB Instance.