head 1.2; access; symbols RPM_4_2_1:1.1.1.4 RPM_4_2:1.1.1.4 RPM_4_1_1:1.1.1.4 RPM_4_1:1.1.1.3 RPM_4_0_5:1.1.1.2 RPM_4_0_4:1.1.1.1 RPM:1.1.1; locks; strict; comment @# @; 1.2 date 2008.01.02.09.55.29; author rse; state dead; branches; next 1.1; commitid z4cpSiAhOCXk5PLs; 1.1 date 2002.01.08.00.30.12; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2002.01.08.00.30.12; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2003.01.18.13.49.03; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2002.01.17.20.11.42; author rse; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2003.01.18.14.05.00; author rse; state Exp; branches; next ; desc @@ 1.2 log @remove the ancient RPM 4.2.1 source tree copy @ text @ Berkeley DB Reference Guide: Building replicated applications

Berkeley DB Reference Guide:
Berkeley DB Replication

PrevRefNext

Building replicated applications

The simplest way to build a replicated Berkeley DB application is to first build (and debug!) the transactional version of the same application. Then, add a thin replication layer to the application. Highly available applications use the following additional four Berkeley DB methods: DB_ENV->rep_elect, DB_ENV->rep_process_message, DB_ENV->rep_start and DB_ENV->set_rep_transport:

DB_ENV->set_rep_transport
The DB_ENV->set_rep_transport function configures the replication system's communications infrastructure.

DB_ENV->rep_start
The DB_ENV->rep_start function configures (or reconfigures) an existing database environment to be a replication master or client.

DB_ENV->rep_process_message
The DB_ENV->rep_process_message function is used to process incoming messages from other environments in the replication group. For clients, it is responsible for accepting log records and updating the local databases based on messages from the master. For both the master and the clients, it is responsible for handling administrative functions (for example, the protocol for dealing with lost messages), and permitting new clients to join an active replication group.

DB_ENV->rep_elect
The DB_ENV->rep_elect function causes the replication group to elect a new master; it is called whenever contact with the master is lost.

To add replication to a Berkeley DB application, application initialization must be changed, and some new code, the application's communications infrastructure, must be written. The application initialization changes are relatively simple, but the communications infrastructure code is fairly complex.

During application initialization, the application must perform two additional tasks: first, it must provide Berkeley DB information about its communications infrastructure, and second, it must start the Berkeley DB replication system. Generally, a replicated application will do normal Berkeley DB recovery and configuration, exactly like any other transactional application. Then, once the database environment has been opened, it will call the DB_ENV->set_rep_transport function to configure Berkeley DB for replication, and then will call the DB_ENV->rep_start function to join or create the replication group. When calling DB_ENV->rep_start, the application has two choices: specifically configure the master for the replication group, or, alternatively, configure all group members as clients and then call an election, letting the clients select the master from among themselves. Either is correct, and the choice is entirely up to the application.

The result of calling DB_ENV->rep_start is usually the discovery of a master, or the declaration of the local environment as the master. If a master has not been discovered after a reasonable amount of time, the application should call DB_ENV->rep_elect to call for an election.

Databases are generally opened read-write on both clients and masters in order to simplify upgrading replication clients to be masters. (If databases are opened read-only on clients, and the client is then upgraded to be the master, the client would have to close and reopen all of its databases in order to support database update queries.) However, even though the database is opened read-write on the client, any attempt to update it will result in an error until the client is reconfigured as a master.

There are no additional interface calls required to shut down a database environment participating in a replication group. The application should shut down the environment in the usual manner, by calling the DB_ENV->close function.

PrevRefNext

Copyright Sleepycat Software @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @Import: RPM 4.0.4 @ text @@ 1.1.1.2 log @Import: RPM 4.0.5 @ text @d1 2 a2 2 a3 1 d19 1 a19 1 Then, add a thin replication layer to the application. All highly available d22 1 a22 2 DB_ENV->set_rep_transport and may also use the configuration method DB_ENV->set_rep_limit: d24 1 a24 1

DB_ENV->set_rep_transport
The DB_ENV->set_rep_transport method configures the replication system's d26 1 a26 1

DB_ENV->rep_start
The DB_ENV->rep_start method configures (or reconfigures) an existing database d28 1 a28 1

DB_ENV->rep_process_message
The DB_ENV->rep_process_message method is used to process incoming messages from other d35 1 a35 1

DB_ENV->rep_elect
The DB_ENV->rep_elect method causes the replication group to elect a new a36 2

DB_ENV->set_rep_limit
The DB_ENV->set_rep_limit imposes an upper bound on the amount of data that will be sent in response to a single call to DB_ENV->rep_process_message. d39 5 a43 4 must be changed and the application's communications infrastructure must be written. The application initialization changes are relatively simple, but the communications infrastructure code can be complex.

During application initialization, the application performs two d49 9 a57 9 will call the DB_ENV->set_rep_transport method to configure Berkeley DB for replication, and then will call the DB_ENV->rep_start method to join or create the replication group.

When calling DB_ENV->rep_start, the application has two choices: specifically configure the master for the replication group, or, alternatively, configure all group members as clients and then call an election, letting the clients select the master from among themselves. Either is correct, and the choice is entirely up to the application. The result of calling DB_ENV->rep_start is usually the discovery of a d59 2 a60 16 a master has not been discovered after a reasonable amount of time, the application should call DB_ENV->rep_elect to call for an election.

In the case of multiple processes accessing a replicated environment, all of the threads of control expecting to modify databases in the environment or process replication messages must call the DB_ENV->rep_start method. Note that not all processes running in replicated environments need to call DB_ENV->set_rep_transport or DB_ENV->rep_start. Read-only processes running in a master environment do not need to be configured for replication in any way. Processes running in a client environment are read-only by definition, and so do not need to be configured for replication either (although, in the case of clients that may become masters, it is usually simplest to configure for replication on process startup rather than trying to reconfigure when the client becomes a master). Obviously, at least one thread of control on each client must be configured for replication as messages must be passed between the master and the client. d68 1 a68 3 reconfigured as a master. No databases can be opened on clients before calling DB_ENV->rep_start, and attempting to do so will result in an error. d72 1 a72 1 DB_ENV->close method. @ 1.1.1.3 log @Import: RPM 4.1 @ text @d1 2 a2 2 d4 1 d20 1 a20 1 Then, add a thin replication layer to the application. Highly available d23 2 a24 1 DB_ENV->set_rep_transport: d26 1 a26 1

DB_ENV->set_rep_transport
The DB_ENV->set_rep_transport function configures the replication system's d28 1 a28 1

DB_ENV->rep_start
The DB_ENV->rep_start function configures (or reconfigures) an existing database d30 1 a30 1

DB_ENV->rep_process_message
The DB_ENV->rep_process_message function is used to process incoming messages from other d37 1 a37 1

DB_ENV->rep_elect
The DB_ENV->rep_elect function causes the replication group to elect a new d39 2 d43 4 a46 5 must be changed, and some new code, the application's communications infrastructure, must be written. The application initialization changes are relatively simple, but the communications infrastructure code is fairly complex.

During application initialization, the application must perform two d52 9 a60 9 will call the DB_ENV->set_rep_transport function to configure Berkeley DB for replication, and then will call the DB_ENV->rep_start function to join or create the replication group. When calling DB_ENV->rep_start, the application has two choices: specifically configure the master for the replication group, or, alternatively, configure all group members as clients and then call an election, letting the clients select the master from among themselves. Either is correct, and the choice is entirely up to the application.

The result of calling DB_ENV->rep_start is usually the discovery of a d62 16 a77 2 a master has not been discovered after a reasonable amount of time, the application should call DB_ENV->rep_elect to call for an election. d85 3 a87 1 reconfigured as a master. d91 1 a91 1 DB_ENV->close function. @ 1.1.1.4 log @Import: RPM 4.1.1 @ text @d1 2 a2 2 a3 1 d19 1 a19 1 Then, add a thin replication layer to the application. All highly available d22 1 a22 2 DB_ENV->set_rep_transport and may also use the configuration method DB_ENV->set_rep_limit: d24 1 a24 1

DB_ENV->set_rep_transport
The DB_ENV->set_rep_transport method configures the replication system's d26 1 a26 1

DB_ENV->rep_start
The DB_ENV->rep_start method configures (or reconfigures) an existing database d28 1 a28 1

DB_ENV->rep_process_message
The DB_ENV->rep_process_message method is used to process incoming messages from other d35 1 a35 1

DB_ENV->rep_elect
The DB_ENV->rep_elect method causes the replication group to elect a new a36 2

DB_ENV->set_rep_limit
The DB_ENV->set_rep_limit imposes an upper bound on the amount of data that will be sent in response to a single call to DB_ENV->rep_process_message. d39 5 a43 4 must be changed and the application's communications infrastructure must be written. The application initialization changes are relatively simple, but the communications infrastructure code can be complex.

During application initialization, the application performs two d49 9 a57 9 will call the DB_ENV->set_rep_transport method to configure Berkeley DB for replication, and then will call the DB_ENV->rep_start method to join or create the replication group.

When calling DB_ENV->rep_start, the application has two choices: specifically configure the master for the replication group, or, alternatively, configure all group members as clients and then call an election, letting the clients select the master from among themselves. Either is correct, and the choice is entirely up to the application. The result of calling DB_ENV->rep_start is usually the discovery of a d59 2 a60 16 a master has not been discovered after a reasonable amount of time, the application should call DB_ENV->rep_elect to call for an election.

In the case of multiple processes accessing a replicated environment, all of the threads of control expecting to modify databases in the environment or process replication messages must call the DB_ENV->rep_start method. Note that not all processes running in replicated environments need to call DB_ENV->set_rep_transport or DB_ENV->rep_start. Read-only processes running in a master environment do not need to be configured for replication in any way. Processes running in a client environment are read-only by definition, and so do not need to be configured for replication either (although, in the case of clients that may become masters, it is usually simplest to configure for replication on process startup rather than trying to reconfigure when the client becomes a master). Obviously, at least one thread of control on each client must be configured for replication as messages must be passed between the master and the client. d68 1 a68 3 reconfigured as a master. No databases can be opened on clients before calling DB_ENV->rep_start, and attempting to do so will result in an error. d72 1 a72 1 DB_ENV->close method. @