rhl48.htm

来自「linux的初学电子书」· HTM 代码 · 共 1,541 行 · 第 1/3 页

HTM
1,541
字号
<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

one_line

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Index each line of a document so a match can show the exact line the match occurred in.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

text

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Index so a match shows the entire document with no indication of the exact line the match occurred in. This is the default option.</FONT>

</TABLE><P>The waisindex command takes arguments for the name of the destination index file (-d followed by the filename), and the directory or files to be indexed. For example, to index a directory called /usr/sales/sales_lit into a destination index file 
called sales, using the one_line indexing approach, you would issue the command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">waisindex -d sales -t one_line /usr/sales/sales_lit</FONT></PRE>

<P>Because there is no path provided for the sales index file in this example, it would be stored in the current directory.

<BR>

<P>Once your WAIS server is running (see the section entitled &quot;Starting freeWAIS&quot;), you can test the indexes by using the waissearch command. For example, to look for the word &quot;WAIS&quot; in the index files, issue the command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">waissearch -p 210 -d index_file WAIS</FONT></PRE>

<P>where -p gives the port number (default value is 210), and -d is the path to the index file. If the search is successful (and you have something that matches) you will see messages about the number of records returned and the scores of each match. If 
you see error messages or nothing, check the configuration information and the index files.

<BR>

<P>A final step you can take if you want your freeWAIS system to be accessible by Internet users is to issue the command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">waisindex -export -register Filenames</FONT></PRE>

<P>where Filenames is the name of the index. This will be registered with the Directory of Servers at cnidr.org and quake.think.com. These addresses are reached automatically with the -register option. Only do this step if you want all Internet users to 
access your WAIS service. (We will look at the waisindex command in much more detail shortly.)

<BR>

<P>If you want to enable clients to connect to your freeWAIS system with a WWW browser (such as Mosaic or Netscape), you must issue the command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">waisindex -d WWW -T HTML -contents -export /usr/resources/*html</FONT></PRE>

<P>Replace the /usr/resources path with the path to your HTML files. This line allows WAIS clients to perform keyword searches on HTML documents, as well.

<BR>

<P>If you want, you can set WAIS to allow only certain domains to connect to it. This is done in the ir.h file, which has a line like this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">#define SERVSECURITYFILE &quot;SERV_SEC&quot;</FONT></PRE>

<P>You have to place a copy of an existing SERV_SEC file or one you create yourself in the same directory as the WAIS index files. If there is no SERV_SEC file accessible to WAIS, all domains are allowed access. (You can change the name of the file, of 
course, as long as the entry in ir.h matches the filename with quotation marks around it.)

<BR>

<P>Each ASCII entry in the SERV_SEC file follows a strict format for defining the domains that are granted access to WAIS. The format of each line is:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">domain [IP address]</FONT></PRE>

<P>Each line has the domain name of the host that you want to grant access to with its IP address as an optional add-on to the line. If the domain name and IP address do not match, it doesn't matter because WAIS allows access to a match of either name or 
address. A sample SERV_SEC file looks likes this:

<BR>

<PRE>

<FONT COLOR="#000080">chatton.com

roy.sailing.org

bighost.bignet.com</FONT></PRE>

<P>Each of these three domain names can access WAIS, while any connection from a host without these domain names is refused.

<BR>

<P>The SERV_SEC file should be owned and accessible only by the user that the freeWAIS system is running as (it should not be run as root to avoid security problems), and the file should be modifiable only by root.

<BR>

<P>Similar to the SERVSECURITYFILE variable is DATASECURITYFILE, which controls access to the databases. There is a line in the ir.h file that looks like this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">#define DATASECURITYFILE &quot;DATA_SEC&quot;</FONT></PRE>

<P>where DATA_SEC is a file listing each database file and the domains that have access to it. The file should reside in the same directory as the index files. The format of the DATA_SEC file is:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">database domain [IP address]</FONT></PRE>

<P>where database is the name of the database the permissions refer to, and domain and the optional IP address are the same as the SERV_SEC file. A sample DATA_SEC file looks like this:

<BR>

<PRE>

<FONT COLOR="#000080">primary chatton.com

primary bignet.org

primary roy.sailing.org

sailing roy.sailing.org</FONT></PRE>

<P>In this example, three domains are granted access to a database called primary (note that primary is just a filename and has no special meaning), while one domain has specific access to the database called sailing as well as primary. If you want to 
allow all hosts with access to the system (controlled by SERV_SEC) to access a particular database, you can use asterisks in the domain name and IP address fields. For example, the entries:

<BR>

<PRE>

<FONT COLOR="#000080">primary * *

sailing roy.sailing.org</FONT></PRE>

<P>allow anyone with access to WAIS to use the primary database, with only one domain allowed access to the sailing database.

<BR>

<P>In both the SERV_SEC and DATA_SEC files, you have to be careful with the IP addresses to avoid inadvertently granting access to hosts you really don't want on your system. For example, if you specify the IP address 150.12 in your file, then any IP 
addresses from 150.12 through 150.120, 151.121, and so on, are also granted access because they match the IP components. Specify IP addresses explicitly to avoid this problem.

<BR>

<BR>

<A NAME="E68E382"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Starting freeWAIS</B></FONT></CENTER></H3>

<BR>

<P>As with the FTP services, you can set freeWAIS to start up when the system boots, by using the rc files from the command line at any time, or you can have the processes started by inetd when a service request arrives. If you want to start freeWAIS from 
the command line, you need to specify a number of options. A sample startup command line looks like this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">waisserver -u username -p 210 -l 10 -d /usr/wais/wais_index</FONT></PRE>

<P>The -u option tells waisserver to run as the user username (which has to be a valid user in /etc/passwd, of course), the -p option tells waisserver what port to use (the default is 210, as shown in the /etc/services file), and the -d option shows the 
default location of WAIS indexes. If you want to invoke logging of sessions to a file, use the -e option followed by the name of the logfile.

<BR>

<P>You should run waisserver as another user instead of root to prevent holes in the WAIS system from being exploited by a hacker. If the service is run as a standard user (such as wais), only the files that the user would have access to would be in 
jeopardy.

<BR>

<P>If the port for waisserver is set to 210, the service corresponds to the Internet standards for access. If you set the value to another port, you can configure the system for local area access only. If the port number is less than 1023, the WAIS service 
must be started and managed by root, but any port over 1023 can be handled by a normal user. If you intend to use port 210, you don't have to specify the number in the command line, although the -p option still must be used.

<BR>

<P>If you want to let inetd handle the waisserver startup, you need to ensure the file /etc/services has an entry for WAIS. The line in the /etc/services file looks like this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">z3950 210/tcp #WAIS</FONT></PRE>

<P>where 210 is the port number WAIS uses, and tcp is the protocol. After modifying or verifying the entry in /etc/services, you need to add a WAIS entry to the inetd.conf file to start up waisserver whenever a request is received on port 210 (or whatever 
other port you are using). The entry looks like this:

<BR>

<PRE>

<FONT COLOR="#000080">z3950 stream tcp nowait root/usr/local/bin/waisserver/waisserver.d

-u username -d /usr/wais/wais_index</FONT></PRE>

<P>where the options are the same as for the command line startup mentioned above. The daemon waisserver.d is used when starting up in inetd mode, instead of waisserver. Again you can use the -e option to log activity to a file.

<BR>

<BR>

<A NAME="E68E383"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Building Your WAIS Indexes</B></FONT></CENTER></H3>

<BR>

<P>Once you have the freeWAIS server ready to run and everything seems to be working, it's time to provide some content for your WAIS system. Usually, documents are the primary source of information for WAIS, although you can index any type of file. The 
key step to providing WAIS service is to build the WAIS index using the waisindex command. The waisindex command can be a bit obtuse at times, but a little practice and some trial-and-error fiddling will help you master its somewhat awkward behavior.

<BR>

<P>The waisindex program works by examining all the data in the files in which you want to create an index. From its examination, waisindex usually generates seven different index files (depending on the content and your commands). Each file holds a list 
of unique words in the documents. The different index files are then combined into one large database, often called the &quot;source&quot; (or &quot;WAIS source&quot;). Whenever a client WAIS package submits a search, the search strings are compared to the 
source, and the results displayed with accuracy analysis (the match score).

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>The use of waisindex enables a client search to proceed much more quickly because the keywords in the data files have already been extracted. However, the mass of data in the index files can be sizable, so allow plenty of disk space for a WAIS server 
to work with. (For a typical WAIS site, assume at least double the amount of room needed for the source files.)</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E69E505"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>WAIS Index Files</B></FONT></CENTER></H4>

<BR>

<P>The freeWAIS index files are not usually readable by a system user (although one or two files can be read with some success). Usually, waisindex creates seven index files, although the number may vary depending on requirements. Each index file has a 
specific file extension to show its purpose, based on a root name (specified on the waisindex command line, or defaulting to index). The index files and their purposes are as follows:

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.doc

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A document file that contains a table with the filename, a headline (title) from the file, the location of the first and last characters of an entry, the length of the document, the number of lines in the document, and the time and date the document was 
created.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.dct

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A dictionary file that contains a list of every unique word in the files cross-indexed to the inverted file.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.fn

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A filename file that contains a table with a list of the filenames, the date they were created in the index, and the type of file.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.hl

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A headline file that contains a table of all headlines (titles). The headline is displayed in the search output when a match occurs.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.inv

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Inverted files that contain a table associating every unique word in all the files with a pointer to the files themselves and the word's importance (determined by how close the word is to the start of the file, the number of times the word occurs in the 
document, and the percentage of times the word appears in the document).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.src

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A source description file that contains descriptions of the information indexed, including the host name and IP address, the port watched by </FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

WAIS, the source filename, any cost information

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

for the service, the headline of the service, a description of the source, and the e-mail address of the administrator. The source description file is editable by ASCII editors. We will look at this file in a little more detail shortly.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

index.status

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

A status file containing user-defined information.</FONT>

</TABLE><P>The source description file is a standard ASCII file that is read by waisindex at intervals to see if information has changed. If the changes are significant, waisindex updates its internal information. A sample source file looks like this:

<BR>

<PRE>

<FONT COLOR="#000080">(:source

:version 2

:ip-address &quot;147.120.0.10&quot;

:ip-name: &quot;wizard.tpci.com&quot;

:tcp-port 210

:database-name &quot;Linux stuff&quot;

:cost 0.00

:cost-unit: free

:maintainer &quot;wais_help@tpci.com&quot;

:subjects &quot;Everything you need to know about Linux&quot;

:description &quot;If you need to know something about Linux, it's here.&quot;</FONT></PRE>

<P>You should edit this file when you set up freeWAIS because the default descriptions are rather sparse and useless.

<BR>

<BR>

<A NAME="E69E506"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>waisindex</B><B> Command</B></FONT></CENTER></H4>

<BR>

<P>The waisindex command allows a number of options, some of which you have seen earlier in this chapter. The following list contains the primary waisindex options of interest to most users:

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-a

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Appends data to an existing index file (used to update index files instead of regenerating them each time a new document is added).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-contents

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Indexes the file contents (default action).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-d

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Gives the filename root for index files (for example, -d /usr/wais/foo named all index files as /usr/wais/foo.xxx).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-e

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Gives the name of the log file for error information (default is stderr&#151;usually the console&#151;although you can specify -s for /dev/null).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-export

</FONT>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?