1 <chapter id="administration">
2 <!-- $Id: administration.xml,v 1.17 2004-01-22 16:23:23 heikki Exp $ -->
3 <title>Administrating Zebra</title>
4 <!-- ### It's a bit daft that this chapter (which describes half of
5 the configuration-file formats) is separated from
6 "recordmodel.xml" (which describes the other half) by the
7 instructions on running zebraidx and zebrasrv. Some careful
8 re-ordering is required here.
12 Unlike many simpler retrieval systems, Zebra supports safe, incremental
13 updates to an existing index.
17 Normally, when Zebra modifies the index it reads a number of records
19 Depending on your specifications and on the contents of each record
20 one the following events take place for each record:
27 The record is indexed as if it never occurred before.
28 Either the Zebra system doesn't know how to identify the record or
29 Zebra can identify the record but didn't find it to be already indexed.
37 The record has already been indexed.
38 In this case either the contents of the record or the location
39 (file) of the record indicates that it has been indexed before.
47 The record is deleted from the index. As in the
48 update-case it must be able to identify the record.
56 Please note that in both the modify- and delete- case the Zebra
57 indexer must be able to generate a unique key that identifies the record
58 in question (more on this below).
62 To administrate the Zebra retrieval system, you run the
63 <literal>zebraidx</literal> program.
64 This program supports a number of options which are preceded by a dash,
65 and a few commands (not preceded by dash).
69 Both the Zebra administrative tool and the Z39.50 server share a
70 set of index files and a global configuration file.
71 The name of the configuration file defaults to
72 <literal>zebra.cfg</literal>.
73 The configuration file includes specifications on how to index
74 various kinds of records and where the other configuration files
75 are located. <literal>zebrasrv</literal> and <literal>zebraidx</literal>
76 <emphasis>must</emphasis> be run in the directory where the
77 configuration file lives unless you indicate the location of the
78 configuration file by option <literal>-c</literal>.
81 <sect1 id="record-types">
82 <title>Record Types</title>
85 Indexing is a per-record process, in which either insert/modify/delete
86 will occur. Before a record is indexed search keys are extracted from
87 whatever might be the layout the original record (sgml,html,text, etc..).
88 The Zebra system currently supports two fundamental types of records:
89 structured and simple text.
90 To specify a particular extraction process, use either the
91 command line option <literal>-t</literal> or specify a
92 <literal>recordType</literal> setting in the configuration file.
97 <sect1 id="configuration-file">
98 <title>The Zebra Configuration File</title>
101 The Zebra configuration file, read by <literal>zebraidx</literal> and
102 <literal>zebrasrv</literal> defaults to <literal>zebra.cfg</literal>
103 unless specified by <literal>-c</literal> option.
107 You can edit the configuration file with a normal text editor.
108 parameter names and values are separated by colons in the file. Lines
109 starting with a hash sign (<literal>#</literal>) are
114 If you manage different sets of records that share common
115 characteristics, you can organize the configuration settings for each
117 When <literal>zebraidx</literal> is run and you wish to address a
118 given group you specify the group name with the <literal>-g</literal>
120 In this case settings that have the group name as their prefix
121 will be used by <literal>zebraidx</literal>.
122 If no <literal>-g</literal> option is specified, the settings
123 without prefix are used.
127 In the configuration file, the group name is placed before the option
128 name itself, separated by a dot (.). For instance, to set the record type
129 for group <literal>public</literal> to <literal>grs.sgml</literal>
130 (the SGML-like format for structured records) you would write:
135 public.recordType: grs.sgml
140 To set the default value of the record type to <literal>text</literal>
151 The available configuration settings are summarized below. They will be
152 explained further in the following sections.
156 FIXME - Didn't Adam make something to have multiple databases in multiple dirs...
164 <emphasis>group</emphasis>
165 .recordType[<emphasis>.name</emphasis>]:
166 <replaceable>type</replaceable>
170 Specifies how records with the file extension
171 <emphasis>name</emphasis> should be handled by the indexer.
172 This option may also be specified as a command line option
173 (<literal>-t</literal>). Note that if you do not specify a
174 <emphasis>name</emphasis>, the setting applies to all files.
175 In general, the record type specifier consists of the elements (each
176 element separated by dot), <emphasis>fundamental-type</emphasis>,
177 <emphasis>file-read-type</emphasis> and arguments. Currently, two
178 fundamental types exist, <literal>text</literal> and
179 <literal>grs</literal>.
184 <term><emphasis>group</emphasis>.recordId:
185 <replaceable>record-id-spec</replaceable></term>
188 Specifies how the records are to be identified when updated. See
189 <xref linkend="locating-records"/>.
194 <term><emphasis>group</emphasis>.database:
195 <replaceable>database</replaceable></term>
198 Specifies the Z39.50 database name.
199 <!-- FIXME - now we can have multiple databases in one server. -H -->
204 <term><emphasis>group</emphasis>.storeKeys:
205 <replaceable>boolean</replaceable></term>
208 Specifies whether key information should be saved for a given
209 group of records. If you plan to update/delete this type of
210 records later this should be specified as 1; otherwise it
211 should be 0 (default), to save register space.
212 <!-- ### this is the first mention of "register" -->
213 See <xref linkend="file-ids"/>.
218 <term><emphasis>group</emphasis>.storeData:
219 <replaceable>boolean</replaceable></term>
222 Specifies whether the records should be stored internally
223 in the Zebra system files.
224 If you want to maintain the raw records yourself,
225 this option should be false (0).
226 If you want Zebra to take care of the records for you, it
232 <!-- ### probably a better place to define "register" -->
233 <term>register: <replaceable>register-location</replaceable></term>
236 Specifies the location of the various register files that Zebra uses
237 to represent your databases.
238 See <xref linkend="register-location"/>.
243 <term>shadow: <replaceable>register-location</replaceable></term>
246 Enables the <emphasis>safe update</emphasis> facility of Zebra, and
247 tells the system where to place the required, temporary files.
248 See <xref linkend="shadow-registers"/>.
253 <term>lockDir: <replaceable>directory</replaceable></term>
256 Directory in which various lock files are stored.
261 <term>keyTmpDir: <replaceable>directory</replaceable></term>
264 Directory in which temporary files used during zebraidx's update
270 <term>setTmpDir: <replaceable>directory</replaceable></term>
273 Specifies the directory that the server uses for temporary result sets.
274 If not specified <literal>/tmp</literal> will be used.
279 <term>profilePath: <replaceable>path</replaceable></term>
282 Specifies a path of profile specification files.
283 The path is composed of one or more directories separated by
284 colon. Similar to PATH for UNIX systems.
289 <term>attset: <replaceable>filename</replaceable></term>
292 Specifies the filename(s) of attribute set files for use in
293 searching. At least the Bib-1 set should be loaded
294 (<literal>bib1.att</literal>).
295 The <literal>profilePath</literal> setting is used to look for
297 See <xref linkend="attset-files"/>
302 <term>memMax: <replaceable>size</replaceable></term>
305 Specifies <replaceable>size</replaceable> of internal memory
306 to use for the zebraidx program.
307 The amount is given in megabytes - default is 4 (4 MB).
308 The more memory, the faster large updates happen, up to about
309 half the free memory available on the computer.
314 <term>tempfiles: <replaceable>Yes/Auto/No</replaceable></term>
317 Tells zebra if it should use temporary files when indexing. The
318 default is Auto, in which case zebra uses temporary files only
319 if it would need more that <replaceable>memMax</replaceable>
320 megabytes of memory. This should be good for most uses.
326 <term>root: <replaceable>dir</replaceable></term>
329 Specifies a directory base for Zebra. All relative paths
330 given (in profilePath, register, shadow) are based on this
331 directory. This setting is useful if your Zebra server
332 is running in a different directory from where
333 <literal>zebra.cfg</literal> is located.
341 <term>tagsysno: 0|1</term>
344 Species whether Zebra should include system-number data in XML
345 and GRS-1 records returned to clients, represented by the
346 <literal><localControlNumber></literal> element in XML
347 and the <literal>(1,14)</literal> tag in GRS-1.
348 The content of these elements is an internally-generated
349 integer uniquely identifying the record within its database.
350 It is included by default but may be turned off, with
351 <literal>tagsysno: 0</literal> for databases in which a local
352 control number is explicitly specified in the input records
364 <sect1 id="locating-records">
365 <title>Locating Records</title>
368 The default behavior of the Zebra system is to reference the
369 records from their original location, i.e. where they were found when you
370 ran <literal>zebraidx</literal>.
371 That is, when a client wishes to retrieve a record
372 following a search operation, the files are accessed from the place
373 where you originally put them - if you remove the files (without
374 running <literal>zebraidx</literal> again, the server will return
375 diagnostic number 14 (``System error in presenting records'') to
380 If your input files are not permanent - for example if you retrieve
381 your records from an outside source, or if they were temporarily
382 mounted on a CD-ROM drive,
383 you may want Zebra to make an internal copy of them. To do this,
384 you specify 1 (true) in the <literal>storeData</literal> setting. When
385 the Z39.50 server retrieves the records they will be read from the
386 internal file structures of the system.
391 <sect1 id="simple-indexing">
392 <title>Indexing with no Record IDs (Simple Indexing)</title>
395 If you have a set of records that are not expected to change over time
396 you may can build your database without record IDs.
397 This indexing method uses less space than the other methods and
402 To use this method, you simply omit the <literal>recordId</literal> entry
403 for the group of files that you index. To add a set of records you use
404 <literal>zebraidx</literal> with the <literal>update</literal> command. The
405 <literal>update</literal> command will always add all of the records that it
406 encounters to the index - whether they have already been indexed or
407 not. If the set of indexed files change, you should delete all of the
408 index files, and build a new index from scratch.
412 Consider a system in which you have a group of text files called
413 <literal>simple</literal>.
414 That group of records should belong to a Z39.50 database called
415 <literal>textbase</literal>.
416 The following <literal>zebra.cfg</literal> file will suffice:
421 profilePath: /usr/local/idzebra/tab
423 simple.recordType: text
424 simple.database: textbase
430 Since the existing records in an index can not be addressed by their
431 IDs, it is impossible to delete or modify records when using this method.
436 <sect1 id="file-ids">
437 <title>Indexing with File Record IDs</title>
440 If you have a set of files that regularly change over time: Old files
441 are deleted, new ones are added, or existing files are modified, you
442 can benefit from using the <emphasis>file ID</emphasis>
443 indexing methodology.
444 Examples of this type of database might include an index of WWW
445 resources, or a USENET news spool area.
446 Briefly speaking, the file key methodology uses the directory paths
447 of the individual records as a unique identifier for each record.
448 To perform indexing of a directory with file keys, again, you specify
449 the top-level directory after the <literal>update</literal> command.
450 The command will recursively traverse the directories and compare
451 each one with whatever have been indexed before in that same directory.
452 If a file is new (not in the previous version of the directory) it
453 is inserted into the registers; if a file was already indexed and
454 it has been modified since the last update, the index is also
455 modified; if a file has been removed since the last
456 visit, it is deleted from the index.
460 The resulting system is easy to administrate. To delete a record you
461 simply have to delete the corresponding file (say, with the
462 <literal>rm</literal> command). And to add records you create new
463 files (or directories with files). For your changes to take effect
464 in the register you must run <literal>zebraidx update</literal> with
465 the same directory root again. This mode of operation requires more
466 disk space than simpler indexing methods, but it makes it easier for
467 you to keep the index in sync with a frequently changing set of data.
468 If you combine this system with the <emphasis>safe update</emphasis>
469 facility (see below), you never have to take your server off-line for
470 maintenance or register updating purposes.
474 To enable indexing with pathname IDs, you must specify
475 <literal>file</literal> as the value of <literal>recordId</literal>
476 in the configuration file. In addition, you should set
477 <literal>storeKeys</literal> to <literal>1</literal>, since the Zebra
478 indexer must save additional information about the contents of each record
479 in order to modify the indexes correctly at a later time.
483 FIXME - There must be a simpler way to do this with Adams string tags -H
487 For example, to update records of group <literal>esdd</literal>
489 <literal>/data1/records/</literal> you should type:
491 $ zebraidx -g esdd update /data1/records
496 The corresponding configuration file includes:
499 esdd.recordType: grs.sgml
505 <para>You cannot start out with a group of records with simple
506 indexing (no record IDs as in the previous section) and then later
507 enable file record Ids. Zebra must know from the first time that you
509 the files should be indexed with file record IDs.
514 You cannot explicitly delete records when using this method (using the
515 <literal>delete</literal> command to <literal>zebraidx</literal>. Instead
516 you have to delete the files from the file system (or move them to a
518 and then run <literal>zebraidx</literal> with the
519 <literal>update</literal> command.
521 <!-- ### what happens if a file contains multiple records? -->
524 <sect1 id="generic-ids">
525 <title>Indexing with General Record IDs</title>
528 When using this method you construct an (almost) arbitrary, internal
529 record key based on the contents of the record itself and other system
530 information. If you have a group of records that explicitly associates
531 an ID with each record, this method is convenient. For example, the
532 record format may contain a title or a ID-number - unique within the group.
533 In either case you specify the Z39.50 attribute set and use-attribute
534 location in which this information is stored, and the system looks at
535 that field to determine the identity of the record.
539 As before, the record ID is defined by the <literal>recordId</literal>
540 setting in the configuration file. The value of the record ID specification
541 consists of one or more tokens separated by whitespace. The resulting
542 ID is represented in the index by concatenating the tokens and
543 separating them by ASCII value (1).
547 There are three kinds of tokens:
551 <term>Internal record info</term>
554 The token refers to a key that is
555 extracted from the record. The syntax of this token is
556 <literal>(</literal> <emphasis>set</emphasis> <literal>,</literal>
557 <emphasis>use</emphasis> <literal>)</literal>,
558 where <emphasis>set</emphasis> is the
559 attribute set name <emphasis>use</emphasis> is the
560 name or value of the attribute.
565 <term>System variable</term>
568 The system variables are preceded by
573 and immediately followed by the system variable name, which
586 <term>database</term>
589 Current database specified.
606 <term>Constant string</term>
609 A string used as part of the ID — surrounded
610 by single- or double quotes.
618 For instance, the sample GILS records that come with the Zebra
619 distribution contain a unique ID in the data tagged Control-Identifier.
620 The data is mapped to the Bib-1 use attribute Identifier-standard
621 (code 1007). To use this field as a record id, specify
622 <literal>(bib1,Identifier-standard)</literal> as the value of the
623 <literal>recordId</literal> in the configuration file.
624 If you have other record types that uses the same field for a
625 different purpose, you might add the record type
626 (or group or database name) to the record id of the gils
627 records as well, to prevent matches with other types of records.
628 In this case the recordId might be set like this:
631 gils.recordId: $type (bib1,Identifier-standard)
637 (see <xref linkend="data-model"/>
638 for details of how the mapping between elements of your records and
639 searchable attributes is established).
643 As for the file record ID case described in the previous section,
644 updating your system is simply a matter of running
645 <literal>zebraidx</literal>
646 with the <literal>update</literal> command. However, the update with general
647 keys is considerably slower than with file record IDs, since all files
648 visited must be (re)read to discover their IDs.
652 As you might expect, when using the general record IDs
653 method, you can only add or modify existing records with the
654 <literal>update</literal> command.
655 If you wish to delete records, you must use the,
656 <literal>delete</literal> command, with a directory as a parameter.
657 This will remove all records that match the files below that root
663 <sect1 id="register-location">
664 <title>Register Location</title>
667 Normally, the index files that form dictionaries, inverted
668 files, record info, etc., are stored in the directory where you run
669 <literal>zebraidx</literal>. If you wish to store these, possibly large,
670 files somewhere else, you must add the <literal>register</literal>
671 entry to the <literal>zebra.cfg</literal> file.
672 Furthermore, the Zebra system allows its file
673 structures to span multiple file systems, which is useful for
674 managing very large databases.
678 The value of the <literal>register</literal> setting is a sequence
679 of tokens. Each token takes the form:
682 <emphasis>dir</emphasis><literal>:</literal><emphasis>size</emphasis>.
685 The <emphasis>dir</emphasis> specifies a directory in which index files
686 will be stored and the <emphasis>size</emphasis> specifies the maximum
687 size of all files in that directory. The Zebra indexer system fills
688 each directory in the order specified and use the next specified
689 directories as needed.
690 The <emphasis>size</emphasis> is an integer followed by a qualifier
692 <literal>b</literal> for bytes,
693 <literal>k</literal> for kilobytes.
694 <literal>M</literal> for megabytes,
695 <literal>G</literal> for gigabytes.
699 For instance, if you have allocated two disks for your register, and
700 the first disk is mounted
701 on <literal>/d1</literal> and has 2GB of free space and the
702 second, mounted on <literal>/d2</literal> has 3.6 GB, you could
703 put this entry in your configuration file:
706 register: /d1:2G /d2:3600M
712 Note that Zebra does not verify that the amount of space specified is
713 actually available on the directory (file system) specified - it is
714 your responsibility to ensure that enough space is available, and that
715 other applications do not attempt to use the free space. In a large
716 production system, it is recommended that you allocate one or more
717 file system exclusively to the Zebra register files.
722 <sect1 id="shadow-registers">
723 <title>Safe Updating - Using Shadow Registers</title>
726 <title>Description</title>
729 The Zebra server supports <emphasis>updating</emphasis> of the index
730 structures. That is, you can add, modify, or remove records from
731 databases managed by Zebra without rebuilding the entire index.
732 Since this process involves modifying structured files with various
733 references between blocks of data in the files, the update process
734 is inherently sensitive to system crashes, or to process interruptions:
735 Anything but a successfully completed update process will leave the
736 register files in an unknown state, and you will essentially have no
737 recourse but to re-index everything, or to restore the register files
738 from a backup medium.
739 Further, while the update process is active, users cannot be
740 allowed to access the system, as the contents of the register files
741 may change unpredictably.
745 You can solve these problems by enabling the shadow register system in
747 During the updating procedure, <literal>zebraidx</literal> will temporarily
748 write changes to the involved files in a set of "shadow
749 files", without modifying the files that are accessed by the
750 active server processes. If the update procedure is interrupted by a
751 system crash or a signal, you simply repeat the procedure - the
752 register files have not been changed or damaged, and the partially
753 written shadow files are automatically deleted before the new updating
758 At the end of the updating procedure (or in a separate operation, if
759 you so desire), the system enters a "commit mode". First,
760 any active server processes are forced to access those blocks that
761 have been changed from the shadow files rather than from the main
762 register files; the unmodified blocks are still accessed at their
763 normal location (the shadow files are not a complete copy of the
764 register files - they only contain those parts that have actually been
765 modified). If the commit process is interrupted at any point during the
766 commit process, the server processes will continue to access the
767 shadow files until you can repeat the commit procedure and complete
768 the writing of data to the main register files. You can perform
769 multiple update operations to the registers before you commit the
770 changes to the system files, or you can execute the commit operation
771 at the end of each update operation. When the commit phase has
772 completed successfully, any running server processes are instructed to
773 switch their operations to the new, operational register, and the
774 temporary shadow files are deleted.
780 <title>How to Use Shadow Register Files</title>
783 The first step is to allocate space on your system for the shadow
785 You do this by adding a <literal>shadow</literal> entry to the
786 <literal>zebra.cfg</literal> file.
787 The syntax of the <literal>shadow</literal> entry is exactly the
788 same as for the <literal>register</literal> entry
789 (see <xref linkend="register-location"/>).
790 The location of the shadow area should be
791 <emphasis>different</emphasis> from the location of the main register
792 area (if you have specified one - remember that if you provide no
793 <literal>register</literal> setting, the default register area is the
794 working directory of the server and indexing processes).
798 The following excerpt from a <literal>zebra.cfg</literal> file shows
799 one example of a setup that configures both the main register
800 location and the shadow file area.
801 Note that two directories or partitions have been set aside
802 for the shadow file area. You can specify any number of directories
803 for each of the file areas, but remember that there should be no
804 overlaps between the directories used for the main registers and the
805 shadow files, respectively.
812 shadow: /scratch1:100M /scratch2:200M
818 When shadow files are enabled, an extra command is available at the
819 <literal>zebraidx</literal> command line.
820 In order to make changes to the system take effect for the
821 users, you'll have to submit a "commit" command after a
822 (sequence of) update operation(s).
828 $ zebraidx update /d1/records
835 Or you can execute multiple updates before committing the changes:
841 $ zebraidx -g books update /d1/records /d2/more-records
842 $ zebraidx -g fun update /d3/fun-records
849 If one of the update operations above had been interrupted, the commit
850 operation on the last line would fail: <literal>zebraidx</literal>
851 will not let you commit changes that would destroy the running register.
852 You'll have to rerun all of the update operations since your last
853 commit operation, before you can commit the new changes.
857 Similarly, if the commit operation fails, <literal>zebraidx</literal>
858 will not let you start a new update operation before you have
859 successfully repeated the commit operation.
860 The server processes will keep accessing the shadow files rather
861 than the (possibly damaged) blocks of the main register files
862 until the commit operation has successfully completed.
866 You should be aware that update operations may take slightly longer
867 when the shadow register system is enabled, since more file access
868 operations are involved. Further, while the disk space required for
869 the shadow register data is modest for a small update operation, you
870 may prefer to disable the system if you are adding a very large number
871 of records to an already very large database (we use the terms
872 <emphasis>large</emphasis> and <emphasis>modest</emphasis>
873 very loosely here, since every application will have a
874 different perception of size).
875 To update the system without the use of the the shadow files,
876 simply run <literal>zebraidx</literal> with the <literal>-n</literal>
877 option (note that you do not have to execute the
878 <emphasis>commit</emphasis> command of <literal>zebraidx</literal>
879 when you temporarily disable the use of the shadow registers in
881 Note also that, just as when the shadow registers are not enabled,
882 server processes will be barred from accessing the main register
883 while the update procedure takes place.
891 <!-- Keep this comment at the end of the file
896 sgml-minimize-attributes:nil
897 sgml-always-quote-attributes:t
900 sgml-parent-document: "zebra.xml"
901 sgml-local-catalogs: nil
902 sgml-namecase-general:t