1
<!--Copyright 1999-2002 by Sleepycat Software, Inc.-->
2
<!--All rights reserved.-->
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
<meta name="GENERATOR" content="Mozilla/4.75 [en] (X11; U; Linux 2.2.16-22 i686) [Netscape]">
11
Environment Commands</h2>
12
Environments provide a structure for creating a consistent environment
13
for processes using one or more of the features of Berkeley DB. Unlike
14
some of the database commands, the environment commands are very low level.
17
<p>The user may create and open a new DB environment by invoking:
18
<p><b>> berkdb env</b>
19
<br><b> [-cdb] [-cdb_alldb] [-lock] [-log] [-txn [nosync]]</b>
20
<br><b> [-create] [-home<i> directory</i>] [-mode <i>mode</i>]</b>
21
<br><b> [-data_dir <i>directory</i>] [-log_dir <i>directory</i>]
22
[-tmp_dir <i>directory</i>]</b>
23
<br><b> [-nommap] [-private] [-recover] [-recover_fatal]
24
[-system_mem] [-errfile <i>filename</i>]</b>
25
<br><b> [-use_environ] [-use_environ_root] [-verbose
26
{<i>which </i>on|off}]</b>
27
<br><b> [-region_init]</b>
28
<br><b> [-cachesize {<i>gbytes bytes ncaches</i>}]</b>
29
<br><b> [-mmapsize<i> size</i>]</b>
30
<br><b> [-log_max <i>max</i>]</b>
31
<br><b> [-log_buffer <i>size</i>]</b>
32
<br><b> [-lock_conflict {<i>nmodes </i>{<i>matrix</i>}}]</b>
33
<br><b> [-lock_detect default|oldest|random|youngest]</b>
34
<br><b> [-lock_max <i>max</i>]</b>
35
<br><b> [-lock_max_locks <i>max</i>]</b>
36
<br><b> [-lock_max_lockers <i>max</i>]</b>
37
<br><b> [-lock_max_objects <i>max</i>]</b>
38
<br><b> [-lock_timeout <i>timeout</i>]</b>
39
<br><b> [-overwrite]</b>
40
<br><b> [-txn_max <i>max</i>]</b>
41
<br><b> [-txn_timeout <i>timeout</i>]</b>
42
<br><b> [-client_timeout <i>seconds</i>]</b>
43
<br><b> [-server_timeout <i>seconds</i>]</b>
44
<br><b> [-server <i>hostname</i>]</b>
45
<br><b> [-rep_master] [-rep_client]</b>
46
<br><b> [-rep_transport <i>{ machineid sendproc }</i>]</b>
48
<p>This command opens up an environment. We automatically set
49
the DB_THREAD and the DB_INIT_MPOOL flags. The arguments are:
52
<b>-cdb</b> selects the DB_INIT_CDB flag for Concurrent Data Store</li>
55
<b>-cdb_alldb</b> selects the DB_CDB_ALLDB flag for Concurrent Data Store</li>
58
<b>-lock</b> selects the DB_INIT_LOCK flag for the locking subsystem</li>
61
<b>-log</b> selects the DB_INIT_LOG flag for the logging subsystem</li>
64
<b>-txn</b> selects the DB_INIT_TXN, DB_INIT_LOCK and DB_INIT_LOG flags
65
for the transaction subsystem. If <b>nosync</b> is specified, then
66
it will also select DB_TXN_NOSYNC to indicate no flushes of log on commits</li>
69
<b>-create </b>selects the DB_CREATE flag to create underlying files</li>
72
<b>-home <i>directory </i></b>selects the home directory of the environment</li>
75
<b>-data_dir <i>directory </i></b>selects the data file directory of the
76
environment by calling <a href="../../docs/api_c/env_set_data_dir.html">DBENV->set_data_dir</a>.</li>
79
<b>-log_dir <i>directory </i></b>selects the log file directory of the
80
environment by calling <a href="../../docs/api_c/env_set_lg_dir.html">DBENV->set_lg_dir</a>.</li>
83
<b>-tmp_dir <i>directory </i></b>selects the temporary file directory of
84
the environment by calling <a href="../../docs/api_c/env_set_tmp_dir.so">DBENV->set_tmp_dir</a>.</li>
87
<b>-mode <i>mode </i></b>sets the permissions of created files to <b><i>mode</i></b></li>
90
<b>-nommap</b> selects the DB_NOMMAP flag to disallow using mmap'ed files</li>
93
<b>-private</b> selects the DB_PRIVATE flag for a private environment</li>
96
<b>-recover</b> selects the DB_RECOVER flag for recovery</li>
99
<b>-recover_fatal</b> selects the DB_RECOVER_FATAL flag for catastrophic
103
<b>-system_mem</b> selects the DB_SYSTEM_MEM flag to use system memory</li>
106
<b>-errfile </b>specifies the error file to use for this environment to
107
<b><i>filename</i></b>
108
by calling <a href="../../docs/api_c/env_set_errfile.html">DBENV->set_errfile</a><b><i>.
110
the file already exists then we will append to the end of the file</li>
113
<b>-use_environ</b> selects the DB_USE_ENVIRON flag to affect file naming</li>
116
<b>-use_environ_root</b> selects the DB_USE_ENVIRON_ROOT flag to have the
117
root environment affect file naming</li>
120
<b>-verbose</b> produces verbose error output for the given which subsystem,
121
using the <a href="../../docs/api_c/dbenv_set_verbose.html">DBENV->set_verbose</a>
122
method. See the description of <a href="#> <env> verbose which on|off">verbose</a>
123
below for valid <b><i>which </i></b>values</li>
126
<b>-region_init </b>specifies that the user wants to page fault the region
127
in on startup using the <a href="../../docs/api_c/env_set_region_init.html">DBENV->set_region_init</a>
131
<b>-cachesize </b>sets the size of the database cache to the size
132
specified by <b><i>gbytes </i></b>and <b><i>bytes, </i></b>broken up into
133
<b><i>ncaches</i></b>
134
number of caches using the <a href="../../docs/api_c/env_set_cachesize.html">DBENV->set_cachesize</a>
138
<b>-mmapsize </b>sets the size of the database page to <b><i>size </i></b>using
139
the <a href="../../docs/api_c/env_set_mp_mmapsize.html">DBENV->set_mp_mmapsize</a>
143
<b>-log_max </b>sets the maximum size of the log file to <b><i>max</i></b>
144
using the <a href="../../docs/api_c/env_set_lg_max.html">DBENV->set_lg_max</a>
148
<b>-log_regionmax </b>sets the size of the log region to <b><i>max</i></b>
149
using the <a href="../../docs/api_c/env_set_lg_regionmax.html">DBENV->set_lg_regionmax</a>
153
<b>-log_buffer </b>sets the size of the log file in bytes to <b><i>size</i></b>
154
using the <a href="../../docs/api_c/env_set_lg_bsize.html">DBENV->set_lg_bsize</a>
158
<b>-lock_conflict </b>sets the number of lock modes to <b><i>nmodes</i></b>
159
and sets the locking policy for those modes to the <b><i>conflict_matrix</i></b>
160
given using the <a href="../../docs/api_c/env_set_lk_conflict.html">DBENV->set_lk_conflict</a>
164
<b>-lock_detect </b>sets the deadlock detection policy to the given policy
165
using the <a href="../../docs/env_set_lk_detect.html">DBENV->set_lk_detect</a>
166
method call. The policy choices are:</li>
170
<b>default</b> selects the DB_LOCK_DEFAULT policy for default detection</li>
173
<b>oldest </b>selects DB_LOCK_OLDEST to abort the oldest locker on a deadlock</li>
176
<b>random</b> selects DB_LOCK_RANDOM to abort a random locker on a deadlock</li>
179
<b>youngest</b> selects DB_LOCK_YOUNGEST to abort the youngest locker on
184
<b>-lock_max </b>sets the maximum size of the lock table to <b><i>max </i></b>using
185
the <a href="../../docs/api_c/env_set_lk_max.html">DBENV->set_lk_max</a>
189
<b>-lock_max_locks </b>sets the maximum number of locks to <b><i>max </i></b>using
190
the <a href="../../docs/api_c/env_set_lk_max_locks.html">DBENV->set_lk_max_locks</a>
194
<b>-lock_max_lockers </b>sets the maximum number of locking entities to
196
</i></b>using the <a href="../../docs/api_c/env_set_lk_max_lockers.html">DBENV->set_lk_max_lockers</a>
200
<b>-lock_max_objects </b>sets the maximum number of simultaneously locked
201
objects to <b><i>max </i></b>using the <a href="../../docs/api_c/env_set_lk_max_objects.html">DBENV->set_lk_max_objects</a>
205
<b>-lock_timeout </b>sets the timeout for locks in the environment</li>
208
<b>-overwrite </b>sets DB_OVERWRITE flag</li>
211
<b>-txn_max </b>sets the maximum size of the transaction table to <b><i>max</i></b>
212
using the <a href="../../docs/api_c/env_set_txn_max.html">DBENV->set_txn_max</a>
216
<b>-txn_timeout </b>sets the timeout for transactions in the environment</li>
219
<b>-client_timeout</b> sets the timeout value for the client waiting for
220
a reply from the server for RPC operations to <b><i>seconds</i></b>.</li>
223
<b>-server_timeout</b> sets the timeout value for the server to determine
224
an idle client is gone to <b><i>seconds</i></b>.</li>
227
<b>-server </b>specifies the <b><i>hostname</i></b> of the server
228
to connect to in the <a href="../../docs/api_c/env_set_server.html">DBENV->set_server</a>
232
<b>-rep_client </b>sets the newly created environment to be a
233
replication client, using the <a href="../../docs/api_c/rep_client.html">
234
DBENV->rep_client</a> call.</li>
237
<b>-rep_master </b>sets the newly created environment to be a
238
replication master, using the <a href="../../docs/api_c/rep_master.html">
239
DBENV->rep_master</a> call.</li>
242
<b>-rep_transport </b>specifies the replication transport function,
244
<a href="../../docs/api_c/rep_transport.html">DBENV->set_rep_transport</a>
245
call. This site's machine ID is set to <b><i>machineid</i></b> and
246
the send function, a Tcl proc, is set to <b><i>sendproc</i></b>.</li>
250
This command will invoke the <a href="../../docs/api_c/env_create.html">db_env_create</a>
251
function. After it successfully gets a handle to an environment,
252
we bind it to a new Tcl command of the form <b><i>envX</i></b>, where X
253
is an integer starting at 0 (e.g. <b>env0, env1, </b>etc).
254
We use the <i>Tcl_CreateObjCommand()</i> to create the top level environment
255
command function. It is through this handle that the user can access
256
all the commands described in the <a href="#Environment Commands">Environment
257
Commands</a> section. Internally, the handle we get back from DB
258
will be stored as the <i>ClientData</i> portion of the new command set
259
so that all future environment calls will have that handle readily available.
260
Then we call the <a href="../../docs/api_c/env_open.html">DBENV->open</a>
261
method call and possibly some number of setup calls as described above.
264
<br><a NAME="> <env> verbose which on|off"></a><b>> <env> verbose <i>which</i>
266
<p>This command controls the use of debugging output for the environment.
267
This command directly translates to a call to the <a href="../../docs/api_c/dbenv_set_verbose.html">DBENV->set_verbose</a>
268
method call. It returns either a 0 (for success), a DB error message
269
or it throws a Tcl error with a system message. The user specifies
271
subsystem to control, and indicates whether debug messages should be turned
273
or <b>off</b> for that subsystem. The value of <b><i>which</i></b>
274
must be one of the following:
277
<b>chkpt</b> - Chooses the checkpointing code by using the DB_VERB_CHKPOINT
281
<b>deadlock </b>- Chooses the deadlocking code by using the DB_VERB_DEADLOCK
285
<b>recovery </b>- Chooses the recovery code by using the DB_VERB_RECOVERY
289
<b>wait </b>- Chooses the waitsfor code by using the DB_VERB_WAITSFOR value</li>
293
<p><a NAME="> <env> close"></a><b>> <env> close</b>
294
<p>This command closes an environment and deletes the handle. This
295
command directly translates to a call to the <a href="../../docs/api_c/env_close.html">DBENV->close</a>
296
method call. It returns either a 0 (for success), a DB error message
297
or it throws a Tcl error with a system message.
298
<p>Additionally, since the handle is no longer valid, we will call <i>Tcl_DeleteCommand()
300
that further uses of the handle will be dealt with properly by Tcl itself.
301
<p>Also, the close command will automatically abort any <a href="txn.html">transactions</a>
302
and close any <a href="mpool.html">mpool</a> memory files. As such
303
we must maintain a list of open transaction and mpool handles so that we
304
can call <i>Tcl_DeleteCommand</i> on those as well.
308
<b>> berkdb envremove<br>
309
[-data_dir <i>directory</i>]<br>
311
[-home <i>directory</i>]<br>
312
[-log_dir <i>directory</i>]<br>
314
[-tmp_dir <i>directory</i>]<br>
316
[-use_environ_root]</b>
318
<p>This command removes the environment if it is not in use and deletes
319
the handle. This command directly translates to a call to the <a href="../../docs/api_c/env_remove.html">DBENV->remove</a>
320
method call. It returns either a 0 (for success), a DB error message
321
or it throws a Tcl error with a system message. The arguments are:
324
<b>-force</b> selects the DB_FORCE flag to remove even if other processes
325
have the environment open</li>
328
<b>-home <i>directory</i> </b>specifies the home directory of the environment</li>
331
<b>-data_dir <i>directory </i></b>selects the data file directory of the
332
environment by calling <a href="../../docs/api_c/env_set_data_dir.html">DBENV->set_data_dir</a>.</li>
335
<b>-log_dir <i>directory </i></b>selects the log file directory of the
336
environment by calling <a href="../../docs/api_c/env_set_lg_dir.html">DBENV->set_lg_dir</a>.</li>
339
<b>-overwrite </b>sets DB_OVERWRITE flag</li>
342
<b>-tmp_dir <i>directory </i></b>selects the temporary file directory of
343
the environment by calling <a href="../../docs/api_c/env_set_tmp_dir.so">DBENV->set_tmp_dir</a>.</li>
346
<b>-use_environ </b>selects the DB_USE_ENVIRON flag to affect file naming</li>
349
<b>-use_environ_root</b> selects the DB_USE_ENVIRON_ROOT flag to affect