#include <db.h>

DB_ENV->repmgr_start(DB_ENV *env, int nthreads, u_int32_t flags);  

The DB_ENV->repmgr_start() method starts the Replication Manager.

There are two ways to build Berkeley DB replication applications: the most common approach is to use the Berkeley DB library Replication Manager, where the Berkeley DB library manages the replication group, including network transport, all replication message processing and acknowledgment, and group elections. Applications using the Replication Manager generally make the following calls:

  1. Call DB_ENV->repmgr_set_local_site() to configure the local site in the replication group.

  2. Call DB_ENV->repmgr_add_remote_site() to configure the remote site(s) in the replication group.

  3. Call DB_ENV->repmgr_set_ack_policy() to configure the message acknowledgment policy which best supports the replication group's transactional needs.

  4. Call DB_ENV->rep_set_priority() to configure the local site's election priority.

  5. Call DB_ENV->repmgr_start() to start the replication application.

For more information on building Replication Manager applications, please see the Replication Getting Started Guide included in the Berkeley DB documentation.

Applications with special needs (for example, applications using network protocols not supported by the Berkeley DB Replication Manager), must perform additional configuration and call other Berkeley DB replication Base API methods. For more information on building Base API applications, please see the Base API Methods section in the Berkeley DB Programmer's Reference Guide.

Starting the Replication Manager consists of opening the TCP/IP listening socket to accept incoming connections, and starting all necessary background threads. When multiple processes share a database environment, only one process can open the listening socket; the DB_ENV->repmgr_start() method automatically opens the socket in the first process to call it, and skips this step in the later calls from other processes.

The DB_ENV->repmgr_start() method may not be called before the DB_ENV->open() method is called to open the local environment and the DB_ENV->repmgr_set_local_site() method is called to configure the local site. In addition, the local environment must be opened with the DB_THREAD flag set.

The DB_ENV->repmgr_start() method will return DB_REP_IGNORE as an informational, non-error return code, if another process has previously become the TCP/IP listener (though the current call has nevertheless successfully started Replication Manager's background threads). Unless otherwise specified, the DB_ENV->repmgr_start() method returns a non-zero error value on failure and 0 on success.



The flags parameter must be set to one of the following values:


    Start as a master site, and do not call for an election. Note there must never be more than a single master in any replication group, and only one site at a time should ever be started with the DB_REP_MASTER flag specified.


    Start as a client site, and do not call for an election.


    Start as a client, and call for an election if no master is found.


Specify the number of threads of control created and dedicated to processing replication messages. In addition to these message processing threads, the Replication Manager creates and manages a few of its own threads of control.


The DB_ENV->repmgr_start() method may fail and return one of the following non-zero errors:


If the database environment was not already opened or was opened without the DB_THREAD flag set; a local site has not already been configured, this method is called from a Base API application; or if an invalid flag value or parameter was specified.



See Also

Replication and Related Methods