mariadb/bdb/tcl/docs/env.html
tim@threads.polyesthetic.msg 89dad52004 Import changeset
2001-03-04 19:42:05 -05:00

303 lines
12 KiB
HTML

<!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.&nbsp; 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&nbsp; by invoking:
<P><B>> berkdb env</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-cdb] [-cdb_alldb] [-lock] [-log] [-txn [nosync]]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-create] [-home<I> directory</I>] [-mode <I>mode</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-data_dir <I>directory</I>] [-log_dir <I>directory</I>]
[-tmp_dir <I>directory</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-nommap] [-private] [-recover] [-recover_fatal]
[-system_mem] [-errfile <I>filename</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-use_environ] [-use_environ_root] [-verbose
{<I>which </I>on|off}]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-region_init]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-cachesize {<I>gbytes bytes ncaches</I>}]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-mmapsize<I> size</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-log_max <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-log_buffer <I>size</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_conflict {<I>nmodes </I>{<I>matrix</I>}}]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_detect default|oldest|random|youngest]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_max <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_max_locks <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_max_lockers <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-lock_max_objects <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-txn_max <I>max</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-client_timeout <I>seconds</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-server_timeout <I>seconds</I>]</B>
<BR><B>&nbsp;&nbsp;&nbsp; [-server <I>hostname</I>]</B>
<BR>&nbsp;
<P>This command opens up an environment.&nbsp;&nbsp; We automatically set
the DB_THREAD and the DB_INIT_MPOOL flags.&nbsp; 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.&nbsp; 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&nbsp; 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&nbsp; 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.&nbsp;&nbsp; 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&nbsp;
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.&nbsp; 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>&nbsp;-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.&nbsp; 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&nbsp; 0 (e.g. <B>env0, env1, </B>etc).&nbsp;
We use the <I>Tcl_CreateObjCommand()</I> to create the top level environment
command function.&nbsp; It is through this handle that the user can access
all the commands described in the <A HREF="#Environment Commands">Environment
Commands</A> section.&nbsp; 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.&nbsp;
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>> &lt;env> verbose <I>which</I>
on|off</B>
<P>This command controls the use of debugging output for the environment.&nbsp;
This command directly translates to a call to the <A HREF="../../docs/api_c/dbenv_set_verbose.html">DBENV->set_verbose</A>
method call.&nbsp; It returns either a 0 (for success), a DB error message
or it throws a Tcl error with a system message.&nbsp; 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.&nbsp; 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>> &lt;env> close</B>
<P>This command closes an environment and deletes the handle.&nbsp; This
command directly translates to a call to the <A HREF="../../docs/api_c/env_close.html">DBENV->close</A>
method call.&nbsp; 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.&nbsp; 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.&nbsp; This command directly translates to a call to the <A HREF="../../docs/api_c/env_remove.html">DBENV->remove</A>
method call.&nbsp; It returns either a 0 (for success), a DB error message
or it throws a Tcl error with a system message.&nbsp; 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&nbsp; 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&nbsp; 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>