You can configure most aspects of your Berkeley DB environment by
using the DB_CONFIG
file. This file must be
placed in your environment directory. When using the BDB SQL interface, this is
the directory created alongside of your database. It has
the same name as your database, followed by a
-journal
extension. For example, if your
database is named mydb.db
, then your
environment directory is created next to the
mydb.db
file, and it
is called mydb.db-journal
.
If a DB_CONFIG
file exists in your
environment directory, it will be read when
your environment is opened. This happens when your
application starts up and creates its first connection to
the database.
Configurations set in the DB_CONFIG file usually appear as the name of the configuration's C function, as documented in Berkeley DB C API Reference Guide, followed by the values of the function arguments. For example, you can use the set_lg_dir DB_CONFIG parameter to configure the directory in which log files are stored like this:
set_lg_dir ../myLogDir
In some cases, you must either specify a configuration option before the environment is created, or the environment must be re-created before the configuration option will take effect. The documentation for each configuration option will indicate where this is true.
In order to provide the DB_CONFIG
file before the database is first created, physically
make the journal directory in the correct location in
your filesystem (this is wherever you want to place
your database file), and put the
DB_CONFIG
file there before you
create your database. For example, if you plan to
create a database named mydb.db
,
then in the same directory as the database, create a
directory named mydb.db-journal
.
Some DB_CONFIG
parameters require you to
re-create your environment before they take effect.
The DB_CONFIG
parameter descriptions
indicates where this is the case.
To re-create your environment:
Make sure the DB_CONFIG
file
contains the following line:
add_data_dir ..
(This line should already be in the
DB_CONFIG
file.)
Run the db_recover
command line utility. If
you run it from within your environment
(-journal
) directory, no
command line arguments are required. If you run
it from outside your environment directory, use
the -h
parameter to identify
the location of the environment directory:
db_recover -h /some/path/to/mydb.db-journal