DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Berkeley DB Reference Guide:
Berkeley DB Replication

PrevRefNext

Ex_repquote: a replication example

Ex_repquote, found in the examples_c/ex_repquote subdirectory of the Berkeley DB distribution, is a simple but complete demonstration of a replicated application. The application is a mock stock ticker. The master accepts a stock symbol and an integer value as input, stores this information into a replicated database; the clients display the contents of the database every few seconds.

The ex_repquote application's communication infrastructure is based on TCP/IP sockets, and uses POSIX 1003.1 style networking/socket support. As a result, it is not as portable as the Berkeley DB library itself. The Makefile created by the standard UNIX configuration will build the ex_repquote application on most platforms. Enter "make ex_repquote" to attempt to build it.

The synopsis for ex_repquote is as follows:

ex_repquote [-MC] [-h home] [-m host:port] [-o host:port] [-n sites] [-p priority]

The options to ex_repquote are as follows:

-M
Configure this process as a master.
-C
Configure this process as a client.
-h
Specify a home directory for the database environment; by default, the current working directory is used.
-m
Listen on port "port" of host "host" for incoming connections.
-o
Attempt to connect to another member of the replication group which is listening on host "host" at port "port". Members of a replication group should be able to find all other members of a replication group so long as they are in contact with at least one other member of the replication group.
-n
Specify the total number of sites in the replication group.
-p
Set the election priority. See DB_ENV->rep_elect for more information.

A typical ex_repquote session begins with a command such as the following, to start a master:

ex_repquote -M -p 100 -n 4 -h DIR1 -m localhost:6000

and several clients:

ex_repquote -C -p 50 -n 4 -h DIR2 -m localhost:6001 -o localhost:6000
ex_repquote -C -p 10 -n 4 -h DIR3 -m localhost:6002 -o localhost:6000
ex_repquote -C -p  0 -n 4 -h DIR4 -m localhost:6003 -o localhost:6000

In this example, the client with home directory DIR4 can never become a master (its priority is 0). Both of the other clients can become masters, but the one with home directory DIR2 is preferred. Priorities are assigned by the application and should reflect the desirability of having particular clients take over as master in the case that the master fails.


PrevRefNext

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.