1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.08 [en] (X11; I; FreeBSD 3.3-RELEASE i386) [Netscape]">
</HEAD>
<BODY>
<H2>
Environment Commands</H2>
Environments provide a structure for creating a consistent environment
for processes using one or more of the features of Berkeley DB. Unlike
some of the database commands, the environment commands are very low level.
<BR>
<HR WIDTH="100%">
<P>The user may create and open a new DB environment by invoking:
<P><B>> berkdb env</B>
<BR><B> [-cdb] [-cdb_alldb] [-lock] [-log] [-txn [nosync]]</B>
<BR><B> [-create] [-home<I> directory</I>] [-mode <I>mode</I>]</B>
<BR><B> [-data_dir <I>directory</I>] [-log_dir <I>directory</I>]
[-tmp_dir <I>directory</I>]</B>
<BR><B> [-nommap] [-private] [-recover] [-recover_fatal]
[-system_mem] [-errfile <I>filename</I>]</B>
<BR><B> [-use_environ] [-use_environ_root] [-verbose
{<I>which </I>on|off}]</B>
<BR><B> [-region_init]</B>
<BR><B> [-cachesize {<I>gbytes bytes ncaches</I>}]</B>
<BR><B> [-mmapsize<I> size</I>]</B>
<BR><B> [-log_max <I>max</I>]</B>
<BR><B> [-log_buffer <I>size</I>]</B>
<BR><B> [-lock_conflict {<I>nmodes </I>{<I>matrix</I>}}]</B>
<BR><B> [-lock_detect default|oldest|random|youngest]</B>
<BR><B> [-lock_max <I>max</I>]</B>
<BR><B> [-lock_max_locks <I>max</I>]</B>
<BR><B> [-lock_max_lockers <I>max</I>]</B>
<BR><B> [-lock_max_objects <I>max</I>]</B>
<BR><B> [-txn_max <I>max</I>]</B>
<BR><B> [-client_timeout <I>seconds</I>]</B>
<BR><B> [-server_timeout <I>seconds</I>]</B>
<BR><B> [-server <I>hostname</I>]</B>
<BR>
<P>This command opens up an environment. We automatically set
the DB_THREAD and the DB_INIT_MPOOL flags. The arguments are:
<UL>
<LI>
<B>-cdb</B> selects the DB_INIT_CDB flag for Concurrent Data Store</LI>
<LI>
<B>-cdb_alldb</B> selects the DB_CDB_ALLDB flag for Concurrent Data Store</LI>
<LI>
<B>-lock</B> selects the DB_INIT_LOCK flag for the locking subsystem</LI>
<LI>
<B>-log</B> selects the DB_INIT_LOG flag for the logging subsystem</LI>
<LI>
<B>-txn</B> selects the DB_INIT_TXN, DB_INIT_LOCK and DB_INIT_LOG flags
for the transaction subsystem. If <B>nosync</B> is specified, then
it will also select DB_TXN_NOSYNC to indicate no flushes of log on commits</LI>
<LI>
<B>-create </B>selects the DB_CREATE flag to create underlying files</LI>
<LI>
<B>-home <I>directory </I></B>selects the home directory of the environment</LI>
<LI>
<B>-data_dir <I>directory </I></B>selects the data file directory of the
environment by calling <A HREF="../../docs/api_c/env_set_data_dir.html">DBENV->set_data_dir</A>.</LI>
<LI>
<B>-log_dir <I>directory </I></B>selects the log file directory of the
environment by calling <A HREF="../../docs/api_c/env_set_lg_dir.html">DBENV->set_lg_dir</A>.</LI>
<LI>
<B>-tmp_dir <I>directory </I></B>selects the temporary file directory of
the environment by calling <A HREF="../../docs/api_c/env_set_tmp_dir.so">DBENV->set_tmp_dir</A>.</LI>
<LI>
<B>-mode <I>mode </I></B>sets the permissions of created files to <B><I>mode</I></B></LI>
<LI>
<B>-nommap</B> selects the DB_NOMMAP flag to disallow using mmap'ed files</LI>
<LI>
<B>-private</B> selects the DB_PRIVATE flag for a private environment</LI>
<LI>
<B>-recover</B> selects the DB_RECOVER flag for recovery</LI>
<LI>
<B>-recover_fatal</B> selects the DB_RECOVER_FATAL flag for catastrophic
recovery</LI>
<LI>
<B>-system_mem</B> selects the DB_SYSTEM_MEM flag to use system memory</LI>
<LI>
<B>-errfile </B>specifies the error file to use for this environment to
<B><I>filename</I></B>
by calling <A HREF="../../docs/api_c/env_set_errfile.html">DBENV->set_errfile</A><B><I>.
</I></B>If
the file already exists then we will append to the end of the file</LI>
<LI>
<B>-use_environ</B> selects the DB_USE_ENVIRON flag to affect file naming</LI>
<LI>
<B>-use_environ_root</B> selects the DB_USE_ENVIRON_ROOT flag to have the
root environment affect file naming</LI>
<LI>
<B>-verbose</B> produces verbose error output for the given which subsystem,
using the <A HREF="../../docs/api_c/dbenv_set_verbose.html">DBENV->set_verbose</A>
method. See the description of <A HREF="#> <env> verbose which on|off">verbose</A>
below for valid <B><I>which </I></B>values</LI>
<LI>
<B>-region_init </B>specifies that the user wants to page fault the region
in on startup using the <A HREF="../../docs/api_c/env_set_region_init.html">DBENV->set_region_init</A>
method call</LI>
<LI>
<B>-cachesize </B>sets the size of the database cache to the size
specified by <B><I>gbytes </I></B>and <B><I>bytes, </I></B>broken up into
<B><I>ncaches</I></B>
number of caches using the <A HREF="../../docs/api_c/env_set_cachesize.html">DBENV->set_cachesize</A>
method</LI>
<LI>
<B>-mmapsize </B>sets the size of the database page to <B><I>size </I></B>using
the <A HREF="../../docs/api_c/env_set_mp_mmapsize.html">DBENV->set_mp_mmapsize</A>
method</LI>
<LI>
<B>-log_max </B>sets the maximum size of the log file to <B><I>max</I></B>
using the <A HREF="../../docs/api_c/env_set_lg_max.html">DBENV->set_lg_max</A>
call</LI>
<LI>
<B>-log_buffer </B>sets the size of the log file in bytes to <B><I>size</I></B>
using the <A HREF="../../docs/api_c/env_set_lg_bsize.html">DBENV->set_lg_bsize</A>
call</LI>
<LI>
<B>-lock_conflict </B>sets the number of lock modes to <B><I>nmodes</I></B>
and sets the locking policy for those modes to the <B><I>conflict_matrix</I></B>
given using the <A HREF="../../docs/api_c/env_set_lk_conflict.html">DBENV->set_lk_conflict</A>
method call</LI>
<LI>
<B>-lock_detect </B>sets the deadlock detection policy to the given policy
using the <A HREF="../../docs/env_set_lk_detect.html">DBENV->set_lk_detect</A>
method call. The policy choices are:</LI>
<UL>
<LI>
<B>default</B> selects the DB_LOCK_DEFAULT policy for default detection</LI>
<LI>
<B>oldest </B>selects DB_LOCK_OLDEST to abort the oldest locker on a deadlock</LI>
<LI>
<B>random</B> selects DB_LOCK_RANDOM to abort a random locker on a deadlock</LI>
<LI>
<B>youngest</B> selects DB_LOCK_YOUNGEST to abort the youngest locker on
a deadlock</LI>
</UL>
<LI>
<B>-lock_max </B>sets the maximum size of the lock table to <B><I>max </I></B>using
the <A HREF="../../docs/api_c/env_set_lk_max.html">DBENV->set_lk_max</A>
method call</LI>
<LI>
<B>-lock_max_locks </B>sets the maximum number of locks to <B><I>max </I></B>using
the <A HREF="../../docs/api_c/env_set_lk_max_locks.html">DBENV->set_lk_max_locks</A>
method call</LI>
<LI>
<B>-lock_max_lockers </B>sets the maximum number of locking entities to
<B><I>max </I></B>using the <A HREF="../../docs/api_c/env_set_lk_max_lockers.html">DBENV->set_lk_max_lockers</A>
method call</LI>
<LI>
<B>-lock_max_objects </B>sets the maximum number of simultaneously locked
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>
method call</LI>
<LI>
<B>-txn_max </B>sets the maximum size of the transaction table to <B><I>max</I></B>
using the <A HREF="../../docs/api_c/env_set_txn_max.html">DBENV->set_txn_max</A>
method call</LI>
<LI>
<B>-client_timeout</B> sets the timeout value for the client waiting for
a reply from the server for RPC operations to <B><I>seconds</I></B>.</LI>
<LI>
<B>-server_timeout</B> sets the timeout value for the server to determine
an idle client is gone to <B><I>seconds</I></B>.</LI>
<LI>
<B> -server </B>specifies the <B><I>hostname</I></B> of the server
to connect to in the <A HREF="../../docs/api_c/env_set_server.html">DBENV->set_server</A>
call.</LI>
</UL>
This command will invoke the <A HREF="../../docs/api_c/env_create.html">db_env_create</A>
function. After it successfully gets a handle to an environment,
we bind it to a new Tcl command of the form <B><I>envX</I></B>, where X
is an integer starting at 0 (e.g. <B>env0, env1, </B>etc).
We use the <I>Tcl_CreateObjCommand()</I> to create the top level environment
command function. It is through this handle that the user can access
all the commands described in the <A HREF="#Environment Commands">Environment
Commands</A> section. Internally, the handle we get back from DB
will be stored as the <I>ClientData</I> portion of the new command set
so that all future environment calls will have that handle readily available.
Then we call the <A HREF="../../docs/api_c/env_open.html">DBENV->open</A>
method call and possibly some number of setup calls as described above.
<P>
<HR WIDTH="100%">
<BR><A NAME="> <env> verbose which on|off"></A><B>> <env> verbose <I>which</I>
on|off</B>
<P>This command controls the use of debugging output for the environment.
This command directly translates to a call to the <A HREF="../../docs/api_c/dbenv_set_verbose.html">DBENV->set_verbose</A>
method call. It returns either a 0 (for success), a DB error message
or it throws a Tcl error with a system message. The user specifies
<B><I>which</I></B>
subsystem to control, and indicates whether debug messages should be turned
<B>on</B>
or <B>off</B> for that subsystem. The value of <B><I>which</I></B>
must be one of the following:
<UL>
<LI>
<B>chkpt</B> - Chooses the checkpointing code by using the DB_VERB_CHKPOINT
value</LI>
<LI>
<B>deadlock </B>- Chooses the deadlocking code by using the DB_VERB_DEADLOCK
value</LI>
<LI>
<B>recovery </B>- Chooses the recovery code by using the DB_VERB_RECOVERY
value</LI>
<LI>
<B>wait </B>- Chooses the waitsfor code by using the DB_VERB_WAITSFOR value</LI>
</UL>
<HR WIDTH="100%">
<P><A NAME="> <env> close"></A><B>> <env> close</B>
<P>This command closes an environment and deletes the handle. This
command directly translates to a call to the <A HREF="../../docs/api_c/env_close.html">DBENV->close</A>
method call. It returns either a 0 (for success), a DB error message
or it throws a Tcl error with a system message.
<P>Additionally, since the handle is no longer valid, we will call <I>Tcl_DeleteCommand()
</I>so
that further uses of the handle will be dealt with properly by Tcl itself.
<P>Also, the close command will automatically abort any <A HREF="txn.html">transactions</A>
and close any <A HREF="mpool.html">mpool</A> memory files. As such
we must maintain a list of open transaction and mpool handles so that we
can call <I>Tcl_DeleteCommand</I> on those as well.
<P>
<HR WIDTH="100%">
<BR><B>> berkdb envremove [-data_dir <I>directory</I>] [-force] [-home
<I>directory</I>]
-log_dir <I>directory</I>] [-tmp_dir <I>directory</I>] [-use_environ] [-use_environ_root]</B>
<P>This command removes the environment if it is not in use and deletes
the handle. This command directly translates to a call to the <A HREF="../../docs/api_c/env_remove.html">DBENV->remove</A>
method call. It returns either a 0 (for success), a DB error message
or it throws a Tcl error with a system message. The arguments are:
<UL>
<LI>
<B>-force</B> selects the DB_FORCE flag to remove even if other processes
have the environment open</LI>
<LI>
<B>-home <I>directory</I> </B>specifies the home directory of the environment</LI>
<LI>
<B>-data_dir <I>directory </I></B>selects the data file directory of the
environment by calling <A HREF="../../docs/api_c/env_set_data_dir.html">DBENV->set_data_dir</A>.</LI>
<LI>
<B>-log_dir <I>directory </I></B>selects the log file directory of the
environment by calling <A HREF="../../docs/api_c/env_set_lg_dir.html">DBENV->set_lg_dir</A>.</LI>
<LI>
<B>-tmp_dir <I>directory </I></B>selects the temporary file directory of
the environment by calling <A HREF="../../docs/api_c/env_set_tmp_dir.so">DBENV->set_tmp_dir</A>.</LI>
<LI>
<B>-use_environ </B>selects the DB_USE_ENVIRON flag to affect file naming</LI>
<LI>
<B>-use_environ_root</B> selects the DB_USE_ENVIRON_ROOT flag to affect
file naming</LI>
</UL>
</BODY>
</HTML>
|