📄 app.so
字号:
m4_comment([$Id: app.so,v 1.31 2007/05/17 18:17:18 bostic Exp $])m4_ref_title(m4_db Replication, Building replicated applications,, rep/pri, rep/mgr_meth)m4_p([dnlThe simplest way to build a replicated m4_db application is to firstbuild (and debug!) the transactional version of the same application.Then, add a thin replication layer: application initialization must bechanged and the application's communication infrastructure must beadded.])m4_p([dnlThe application initialization changes are relatively simple.Replication Manager provides a communication infrastructure, butin order to use the Base replication API you must provide your own.])m4_p([dnlFor implementation reasons, all replicated databases must reside inthe data directories set from m4_ref(dbenv_set_data_dir) (or in thedefault environment home directory, if not usingm4_ref(dbenv_set_data_dir)), rather than in a subdirectory below thespecified directory. Care must be taken in applications usingrelative pathnames and changing working directories after opening theenvironment. In such applications the replication initialization codemay not be able to locate the databases, and applications that changetheir working directories may need to use absolute pathnames.])m4_p([dnlDuring application initialization, the application performs threeadditional tasks: first, it must specify the m4_ref(DB_INIT_REP) flagwhen opening its database environment; second, it must provide m4_dbinformation about its communications infrastructure; and third, it muststart the m4_db replication system. Generally, a replicated applicationwill do normal m4_db recovery and configuration, exactly like any othertransactional application.])m4_p([dnlReplication Manager applications configure the built-in communicationsinfrastructure by calling the m4_refT(repmgr_set_local_site)once and the m4_refT(repmgr_add_remote_site) zero or moretimes. Once the environment has been opened, the application startsthe replication system by calling the m4_refT(repmgr_start).])m4_p([dnlIf using the Base replication API, the application calls them4_refT(rep_set_transport) to configure the entry point to its owncommunications infrastructure, and then it calls them4_refT(rep_start) to join or create the replication group.])m4_p([dnlWhen starting the replication system, an application has two choices:it may choose the group master site explicitly, or alternatively itmay configure all group members as clients and then call for anelection, letting the clients select the master from amongthemselves. Either is correct, and the choice is entirely up to theapplication.])m4_p([dnlFor an application that uses the Base replication API, the result ofcalling m4_ref(rep_start) is usually the discovery of a master, or thedeclaration of the local environment as the master. If a master hasnot been discovered after a reasonable amount of time, the applicationshould call m4_ref(rep_elect) to call for an election.])m4_p([dnlReplication Manager applications have these same two choices. Butthey configure their start-up behavior simply by setting the flagsparameter to the m4_refT(repmgr_start).])m4_p([dnlConsider the case of multiple processes or multiple environment handlesthat modify databases in the replicated environment. All modificationsmust be done on the master environment. The first process to join orcreate the master environment must call both them4_refT(rep_set_transport) and the m4_refT(rep_start). Subsequentreplication processes must at least call the m4_refT(rep_set_transport).Those processes may call the m4_refT(rep_start) (as long as they use thesame master or client argument). If multiple processes are modifyingthe master environment there must be a unified communicationinfrastructure such that messages arriving at clients have a singlemaster ID. Additionally the application must be structured so that allincoming messages are able to be processed by a single m4_ref(DbEnv)handle.])m4_p([dnlNote that not all processes running in replicated environments need tocall m4_ref(rep_set_transport) or m4_ref(rep_start). Read-onlyprocesses running in a master environment do not need to be configuredfor replication in any way. Processes running in a client environmentare read-only by definition, and so do not need to be configured forreplication either (although, in the case of clients that may becomemasters, it is usually simplest to configure for replication on processstartup rather than trying to reconfigure when the client becomes amaster). Obviously, at least one thread of control on each client mustbe configured for replication as messages must be passed between themaster and the client.])m4_p([dnlAny site in a replication group may have its own privatetransactional databases in the environment as well. A site maycreate a local database by using the m4_ref(DB_TXN_NOT_DURABLE)flag to the m4_ref(dbh_set_flags). The applicationmust never create a private database with the same nameas a database replicated across the entire environmentas data corruption can result.])m4_p([dnlFor implementation reasons, all incoming replication messages must beprocessed using the same m4_ref(DbEnv) handle. It is not required thata single thread of control process all messages, only that all threadsof control processing messages use the same handle.])m4_p([dnlNo additional calls are required to shut down a database environmentparticipating in a replication group. The application should shut downthe environment in the usual manner, by calling the m4_refT(dbenv_close).For Replication Manager applications, this also terminates all networkconnections and background processing threads.])m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -