Berkeley DB Reference Guide: Environment
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++

### Berkeley DB Reference Guide: Environment |

# Introduction

A Berkeley DB environment is an encapsulation of one or more databases, log files and shared information about the database environment such as shared memory buffer cache pages.

The simplest way to administer a Berkeley DB application environment is to create a single home directory that stores the files for the applications that will share the environment. The environment home directory must be created before any Berkeley DB applications are run. Berkeley DB itself never creates the environment home directory. The environment can then be identified by the name of that directory.

An environment may be shared by any number of applications as well as by any number of threads within the applications. It is possible for an environment to include resources from other directories on the system, and applications often choose to distribute resources to other directories or disks for performance or other reasons. However, by default, the databases, shared regions (the locking, logging, memory pool, and transaction shared memory areas) and log files will be stored in a single directory hierarchy.

It is important to realize that all applications sharing a database environment implicitly trust each other. They have access to each other's data as it resides in the shared regions and they will share resources such as buffer space and locks. At the same time, any applications using the same databases must share an environment if consistency is to be maintained between them.

The Berkeley DB environment is created and described by the db_env_create and DBENV->open interfaces. In situations where customization is desired, such as storing log files on a separate disk drive, applications must describe the customization by either creating an environment configuration file in the environment home directory or by arguments passed to the DBENV->open interface. See the documentation on that function for details on this procedure.

Once an environment has been created, database files specified using relative pathnames will be named relative to the home directory. Using pathnames relative to the home directory allows the entire environment to be easily moved to facilitate restoring and recovering a database in a different directory or on a different system.

Copyright Sleepycat Software