1<!--$Id: env_open.so,v 11.29 2002/12/22 21:11:07 bostic Exp $-->
2<!--$Id: m4.tcl,v 11.28 2004/12/16 19:13:05 bostic Exp $-->
3<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
4<!--See the file LICENSE for redistribution information.-->
5<html>
6<head>
7<title>Berkeley DB: berkdb env</title>
8<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
10</head>
11<body bgcolor=white>
12<table width="100%"><tr valign=top>
13<td>
14<b><b>berkdb env</b></b>
15</td>
16<td align=right>
17<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a>
18<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
19</tr></table>
20<hr size=1 noshade>
21<tt>
22<b><pre>berkdb env
23	[-cachesize {gbytes bytes ncache}]
24	[-create]
25	[-data_dir dirname]
26	[-encryptaes passwd]
27	[-encryptany passwd]
28	[-errfile filename]
29	[-home directory]
30	[-log_dir dirname]
31	[-mode mode]
32	[-private]
33	[-recover]
34	[-recover_fatal]
35	[-shm_key shmid]
36	[-system_mem]
37	[-tmp_dir dirname]
38	[-txn [nosync]]
39	[-txn_max max]
40	[-use_environ]
41	[-use_environ_root]
42</pre></b>
43<b>Description(berkdb env)</b>
44<p>The <b>berkdb env</b> command opens and optionally creates a database
45environment.  The returned environment handle is bound to a Tcl command
46of the form <b>envN</b>, where N is an integer starting at 0 (for
47example, env0 and env1).  It is through this Tcl command that the script
48accesses the environment methods.  The command automatically initializes
49the Shared Memory Buffer Pool subsystem.  This subsystem is used
50whenever the application is using any Berkeley DB access method.</p>
51<p>The options are as follows:</p>
52<br>
53<b>-cachesize {gbytes bytes ncache}</b><ul compact><li>Set the size of the database's shared memory buffer pool (that is, the
54cache), to <b>gbytes</b> gigabytes plus <b>bytes</b>.  The cache
55should be the size of the normal working data set of the application,
56with some small amount of additional memory for unusual situations.
57(Note: The working set is not the same as the number of simultaneously
58referenced pages, and should be quite a bit larger!)
59<p>The default cache size is 256KB, and may not be specified as less than
6020KB.  Any cache size less than 500MB is automatically increased by 25%
61to account for buffer pool overhead; cache sizes larger than 500MB are
62used as specified.</p>
63<p>It is possible to specify caches to Berkeley DB that are large enough so that
64they cannot be allocated contiguously on some architectures; for example,
65some releases of Solaris limit the amount of memory that may be
66allocated contiguously by a process.  If <b>ncache</b> is 0 or 1, the
67cache will be allocated contiguously in memory.  If it is greater than
681, the cache will be broken up into <b>ncache</b> equally sized
69separate pieces of memory.</p>
70<p>For information on tuning the Berkeley DB cache size, see
71<a href="../ref/am_conf/cachesize.html">Selecting a cache size</a>.</p></ul>
72<b>-create</b><ul compact><li>Cause Berkeley DB subsystems to create any underlying files, as necessary.</ul>
73<b>-data_dir dirname</b><ul compact><li>Specify the environment's data directory as described in
74<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.</ul>
75<b>-encryptaes passwd</b><ul compact><li>Specify the database should be encrypted with the given password
76using the Rijndael/AES (also known as the Advanced Encryption Standard
77and Federal Information Processing Standard (FIPS) 197) algorithm.</ul>
78<b>-encryptany passwd</b><ul compact><li>Specify the already existing environment should be opened
79with the given password.  This option is used if the environment is
80known to be encrypted, but the specific algorithm used is not known.</ul>
81<b>-errfile filename</b><ul compact><li><p>When an error occurs in the Berkeley DB library, a Berkeley DB error or an error
82return value is returned by the function. In some cases, however, the
83errno value may be insufficient to completely describe the cause of the
84error especially during initial application debugging.</p>
85<p>The <b>-errfile</b> argument is used to enhance the mechanism for
86reporting error messages to the application by specifying a file to be
87used for displaying additional Berkeley DB error messages. In some cases, when
88an error occurs, Berkeley DB will output an additional error message to the
89specified file reference.</p>
90<p>consist of the environment command name (for example, env0) and a colon
91(":"), an error string, and a trailing &lt;newline&gt;
92character.</p>
93<p>This error-logging enhancement does not slow performance or significantly
94increase application size, and may be run during normal operation as well
95as during application debugging.</p></ul>
96<b>-home directory</b><ul compact><li>The <b>-home</b> argument is described in
97<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.</ul>
98<b>-log_dir dirname</b><ul compact><li>Specify the environment's logging file directory as described in
99<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.</ul>
100<b>-mode mode</b><ul compact><li><p>On UNIX systems, or in IEEE/ANSI Std 1003.1 (POSIX) environments, all files created by Berkeley DB
101are created with mode <b>mode</b> (as described in <b>chmod</b>(2)) and
102modified by the process' umask value at the time of creation (see
103<b>umask</b>(2)).  The group ownership of created files is based on
104the system and directory defaults, and is not further specified by Berkeley DB.
105If <b>mode</b> is 0, files are created readable and writable by both
106owner and group.  On Windows systems, the mode argument is ignored.</p></ul>
107<b>-private</b><ul compact><li>Specify that the environment will only be accessed by a single process
108(although that process may be multithreaded).  This flag has two effects
109on the Berkeley DB environment.  First, all underlying data structures are
110allocated from per-process memory instead of from shared memory that is
111potentially accessible to more than a single process.  Second, mutexes
112are only configured to work between threads.
113<p>This flag should not be specified if more than a single process is
114accessing the environment, as it is likely to cause database corruption
115and unpredictable behavior.  For example, if both a server application
116and the Berkeley DB utility <a href="../utility/db_stat.html">db_stat</a> will access the environment, the
117<b>-private</b> option should not be specified.</p></ul>
118<b>-recover</b><ul compact><li>Run normal recovery on this environment before opening it for normal use.
119If this flag is set, the <b>-create</b> option must also be set because
120the regions will be removed and re-created.</ul>
121<b>-recover_fatal</b><ul compact><li>Run catastrophic recovery on this environment before opening it for
122normal use.  If this flag is set, the <b>-create</b> option must also be
123set since the regions will be removed and re-created.</ul>
124<b>-shm_key key</b><ul compact><li>Specify a base segment ID for Berkeley DB environment shared memory regions
125created in system memory on systems supporting X/Open-style shared
126memory interfaces, for example, UNIX systems supporting shmget(2) and
127related System V IPC interfaces.  See <a href="../ref/env/region.html">Shared Memory Regions</a> for more information.</ul>
128<b>-system_mem</b><ul compact><li>Allocate memory from system shared memory instead of memory backed by the
129filesystem.  See <a href="../ref/env/region.html">Shared Memory Regions</a>
130for more information.</ul>
131<b>-tmp_dir dirname</b><ul compact><li>Specify the environment's tmp directory, as described in
132<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.</ul>
133<b>-txn [nosync]</b><ul compact><li>Initialize the Transaction subsystem.  This subsystem is used when
134recovery and atomicity of multiple operations and recovery are important.
135The <b>-txn</b> option implies the initialization of the logging
136and locking subsystems as well.
137<p>If the optional <b>nosync</b> argument is specified, the log will not
138be synchronously flushed on transaction commit.  This means that
139transactions exhibit the ACI (atomicity, consistency, and isolation)
140properties, but not D (durability); that is, database integrity will be
141maintained, but it is possible that some number of the most recently
142committed transactions may be undone during recovery instead of being
143redone.</p>
144<p>The number of transactions that are potentially at risk is governed by
145how often the log is checkpointed (see <a href="../utility/db_checkpoint.html">db_checkpoint</a> for more
146information) and how many log updates can fit on a single log page.</p></ul>
147<b>-txn_max max</b><ul compact><li>Set the maximum number of simultaneous transactions that are supported
148by the environment, which bounds the size of backing files.  When there
149are more than the specified number of concurrent transactions, calls to
150<i>env</i> <b>txn</b> will fail (until some active transactions complete).</ul>
151<b>-use_environ</b><ul compact><li>The Berkeley DB process' environment may be permitted to specify information
152to be used when naming files; see
153<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.
154Because permitting users to specify which files are used can create
155security problems, environment information will be used in file naming
156for all users only if the <b>-use_environ</b> flag is set.</ul>
157<b>-use_environ_root</b><ul compact><li>The Berkeley DB process' environment may be permitted to specify information
158to be used when naming files; see
159<a href="../ref/env/naming.html">Berkeley DB File Naming</a>.
160As permitting users to specify which files are used can create security
161problems, if the <b>-use_environ_root</b> flag is set, environment
162information will be used for file naming only for users with appropriate
163permissions (for example, users with a user-ID of 0 on IEEE/ANSI Std 1003.1 (POSIX)
164systems).</ul>
165<br>
166<p>The <b>berkdb env</b> command returns an environment handle on success.</p>
167<p>In the case of error, a Tcl error is thrown.</p>
168</tt>
169<table width="100%"><tr><td><br></td><td align=right>
170<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
171</td></tr></table>
172<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
173</body>
174</html>
175