Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the method of manually selecting the master node of a replication group in the database

Shulou Source: shulou.com Published: 2022-05-31 12:24:11 09月16日 Update

This article introduces the knowledge of "what is the method of manually selecting the master node of the replication group in the database". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

[detailed description of the problem]

How to manually select the master node of a replication group?

[solution]

1. In the replication group, each node can set the voting weight. When the LSN is the same, the node with the largest weight becomes the primary node. Therefore, you can configure weight through the database, and then call the SdbReplicaGroup.reelect () interface to achieve the manual selection of the primary node.

2. The SdbReplicaGroup.reelect () interface will block the write operation and wait for the node LSN to be consistent before the election. If it times out, it will fail and report an error.

3. For example, group1 on v3.0 has nodes sdbserver:11720 (master) and sdbserver:11750 (standby). The main reference steps are as follows:

> var db = new Sdb ()

> db.updateConf ({weight: 20}, {GroupName: "group1", Svcname: "11750"})

> db.snapshot (SDB_SNAP_CONFIGS, {NodeName: "sdbserver1:11720"}, {weight: 1})

{

"weight": 10

}

> db.snapshot (SDB_SNAP_CONFIGS, {NodeName: "sdbserver1:11750"}, {weight: 1})

{

"weight": 20

}

> db.getRG ('group1'). Reelect ()

When you are finished, look at the master node and switch.

This is the end of the content of "what is the method of manually selecting the master node of the replication group in the database". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Node selection labor data database method content interface more weight knowledge election practical maximum same consistent successful learning and then can pass the dilemma Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Redmi Apple MySQL