DBIServer/Install.pm untested

filter: Statementstmt 0.0% 0 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod n/a totaltotal 0.0% 0 / 4 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
CRAP 2.0
1 # $Header: /home/mike/cvs/mike/zSQLgate/lib/Net/Z3950/DBIServer/Install.pm,v 1.9 2005-04-20 09:56:24 mike Exp $
2  
3 package Net::Z3950::DBIServer::Install;
4 use strict;
5  
6  
7 =head1 NAME
8  
9 Net::Z3950::DBIServer::Install - The zSQLgate Installation Guide
10  
11  
12 =head1 SYNOPSIS
13  
14 Before you can install C<zSQLgate>, you need to have already installed
15 both its front end, which speaks Z39.50, and its back end, which is a
16 relational database. The front end is Index Data's
17 C<Net::Z3950::SimpleServer> module, which itself depends on their YAZ
18 toolkit. The back end is Perl's DBI (DataBase Independent) module,
19 together with the driver for some particular RDBMS, plus the RDBMS
20 itself.
21  
22  
23 =head1 DESCRIPTION
24  
25 C<zSQLgate>
26 provides an Z39.50 interface to your relational databases.
27 That is, it provides a generic gateway between the Z39.50 Information
28 Retrieval protocol and pretty much any relational database you
29 care to mention.
30  
31 In order to provide a gateway between those two things, it needs those
32 two things to be there. That means that there are quite a lot of
33 prerequisites, since both the Z39.50 front end and the relational
34 database back end are pretty complex systems. And of course, you'll
35 need Perl itself - the language in which C<zSQLgate> is written.
36  
37 This may appear a daunting list, but take heart! You probably have
38 most of these things already. It's pretty much impossible to buy a
39 Real Computer without Perl these days, for example. And you probably
40 already have the database system that you want to build a gateway for
41 (otherwise why do you want a gateway to it?)
42  
43 The following sections deal in some detail with the various things
44 that need to be installed. The order they're listed in works fine:
45 you can just follow the list if you like. But you don't need to
46 adhere to its exact order. Here are the actual dependencies:
47  
48 =over 4
49  
50 =item *
51  
52 C<zSQLgate> depends on SimpleServer and DBI configured with an
53 appropriate driver.
54  
55 =item *
56  
57 C<SimpleServer> depends on Perl and the YAZ toolkit.
58  
59 =item *
60  
61 The DBI driver depends on Perl, DBI and the relevant RDBMS.
62  
63 =item *
64  
65 DBI itself depends only on Perl.
66  
67 =back
68  
69 Basically, if you start with Perl, the database system and the YAZ
70 toolkit, none of which have any prerequisites, you should be OK.
71  
72  
73 =head1 THINGS TO INSTALL
74  
75 =head2 Install Perl.
76  
77 Building and installing Perl, if you don't already have it, it an
78 art-form in itself. Reams have been written about the process, but
79 fortunately you should never have to read any of it, since pretty much
80 every Real Computer these days comes with Perl already installed - if
81 only because it's widely used behind the scenes for system
82 administration tasks.
83  
84 To see if you have Perl, go to the shell prompt and type
85  
86 $ perl -e 'print 2+2'
87  
88 If you get C<4>, you're OK, and can skip to the next section. If you
89 get C<command not found>, you may not have Perl (or it may not be in
90 your path). If you get C<5>, you've got real problems :-)
91  
92 If you're running any kind of Unix (including Linux), then the odds
93 are good that your operating system's install media have a ready-to-go
94 Perl package that you can breathe into life. If you're running on
95 Windows, then the best way to get Perl installed is to install Linux
96 and then ... No, wait! I promised myself not to get bogged down in
97 operating system evangelism :-) You should be able to get pre-built
98 Win32 binaries at http://www.cpan.org/ - the Comprehensive Perl
99 Archive Network.
100  
101  
102 =head2 Install an RDBMS.
103  
104 If you already have the database that you want to build a Z39.50
105 gateway to, then you no doubt also have the RDBMS (relational database
106 management system) software that controls it; so you're OK.
107  
108 If you're building a system from scratch, then you'll need to install
109 the database software. That can be anything from a trivial to a
110 wizardly process. At the simplest end of the scale, I did the bulk of
111 the C<zSQLgate> development work using a PostgreSQL database which I
112 installed from packages on my Red Hat 7.1 CD-ROM. It went like this:
113  
114 # mount /mnt/cdrom
115 # rpm -Uhv /mnt/cdrom/RedHat/RPMS/postgresql-7.0.3-8.i386.rpm
116 # rpm -Uhv /mnt/cdrom/RedHat/RPMS/postgresql-server-7.0.3-8.i386.rpm
117 # rpm -Uhv /mnt/cdrom/RedHat/RPMS/postgresql-devel-7.0.3-8.i386.rpm
118  
119 (You need the core package for the client libraries; the server
120 package so you can run the server (duh!); and the the development
121 package so that you can build C<DBD::Pg> against its header files
122 later.)
123  
124 Then I created the actual database:
125  
126 $ mkdir -p /usr/local/postgres/data
127 $ initdb --pglib=/usr/lib/pgsql --pgdata=/usr/local/postgres/data
128 $ postmaster -D /usr/local/postgres/data
129  
130 More recently, I have been working with MySQL running on Debian
131 GNU/Linux, which I installed like this:
132  
133 # apt-get install mysql-client
134 # apt-get install mysql-common
135 # apt-get install mysql-server
136  
137 But - this goes without saying, I am sure - these are just examples of
138 how two particular RDBMSs can be installed. They are all very
139 different from each other.
140  
141 Which RDBMS should you choose? That's a whole subject in itself. The
142 C<DBI::FAQ> document (section 3.7, I<What database do you recommend me
143 using?>) speaks highly of mSQL and MySQL (both of which used to be
144 free, and the latter of which still is) and Oracle and
145 Informix (both not at all free!). To this list, I would add
146 PostgreSQL (also free, which helps, and it's part of recent Red Hat
147 distributions, hence my very easy installation). Others say great
148 things about Sybase, or IBM's DB2; and at the other end of the scale,
149 there's a Perl module (C<DBD::CSV>) that presents an RDBMS-like
150 interface to boring old CVS files - that is, text files in which each
151 line is a record, with the fields separated by commas.
152  
153 A few URLs:
154  
155 =over 4
156  
157 =item *
158  
159 mSQL
160 at
161 http://www.hughes.com.au/products/msql/
162  
163 =item *
164  
165 MySQL
166 at
167 http://www.mysql.com/
168  
169 =item *
170  
171 Oracle
172 at
173 http://www.oracle.com/
174  
175 =item *
176  
177 Informix
178 at
179 http://www.informix.com/
180  
181 =item *
182  
183 PostgreSQL
184 at
185 http://www.postgresql.org/
186  
187 =item *
188  
189 Sybase
190 at
191 http://www.sybase.com/
192  
193 =item *
194  
195 DB2
196 at
197 http://www-3.ibm.com/software/data/db2/
198  
199 =item *
200  
201 C<DBD::CSV>
202 at
203 http://www.cpan.org/authors/id/J/JW/JWIED/
204  
205 =back
206  
207 Basically, this is a Holy War subject. Use what works for you. If
208 you really have no preference, then get one of the free ones: they're
209 good.
210  
211  
212 =head2 Install the DBI module.
213  
214 Ah, now this is much easier. C<DBI> is Perl's DataBase Independent
215 interface, which presents a uniform interface to pretty much any RDBMS
216 (and which is responsible for C<zSQLgate>'s multilinguality.) In
217 principle, it's similar to ODBC, although it's very different in the
218 details.
219  
220 C<DBI> is a refreshingly straightforward module to build and install,
221 using the standard sequence of commands:
222  
223 $ gunzip < DBI-1.20.tar.gz | tar xf -
224 $ cd DBI-1.20
225 $ perl Makefile.PL
226 $ make
227 $ make test
228 $ su
229 # make install
230  
231 (You can find the C<DBI> module, like all respectable Perl modules, on
232 CPAN. Versions 1.20 and 1.32 are known to work with zSQLgate, but all
233 more recent version will work fine, too, and there is no reason to
234 think that older versions won't.)
235  
236  
237 =head2 Install the DBI driver for the RDBMS of your choice.
238  
239 C<DBI> provides the uniform front end to any RDBMS, but to make it
240 work, you need a I<driver> for for the specific RDBMS you want to use.
241 The drivers are found in modules with names of the form
242 C<DBD::>I<something> where I<something> is related to the name of the
243 RDBMS. For example, the driver for PostgreSQL is called C<DBD::Pg>
244 and the driver for MySQL is called C<DBD::mysql>.
245 If you poke around on CPAN, you'll be able to find drivers for most of
246 the well-known RDBMSs, including all those discussed above.
247  
248 Once you've fetched your driver (from CPAN, natch), you can unpack it
249 and build it just as you did with DBI itself: C<perl Makefile.PL>,
250 C<make>, C<make test> and then - as root - C<make install>.
251  
252 Most DBI drivers need to be told at build time where the RDBMS is
253 installed. Usually, the C<perl Makefile.PL> stage will complain if
254 you've not done this, or if you've got it wrong. For example, in
255 order to build the PostgreSQL driver, I had to set two environment
256 variables specifying where the PostgreSQL libraries and header files
257 were:
258  
259 $ POSTGRES_LIB=/usr/lib # location of libpq.so
260 $ POSTGRES_INCLUDE=/usr/include/pgsql
261 $ export POSTGRES_LIB POSTGRES_INCLUDE
262  
263 But again, you'll have to do something different if you're using a
264 different RDBMS. Consult your C<DBI> driver's documentation for
265 details.
266  
267 Increasingly these days Linux distributions include pre-built packages
268 for the more commonly used DBD drivers. For example, I installed the
269 MySQL driver on my Debian box like this:
270  
271 # apt-get install mysql-server libdbd-mysql-perl
272  
273 =head2 Install the YAZ toolkit.
274  
275 YAZ is written in C. You'll need to download it from
276 http://www.indexdata.com/yaz/ and unpack it, then just:
277  
278 $ ./configure
279 $ make
280 $ su
281 # make install
282  
283 Yes, it's that easy. No, nothing can go wrong. Not only is YAZ
284 robust, efficient, battle tested and elegant code, it's also a cinch
285 to build. Go, Index Data!
286  
287  
288 =head2 Install the Net::Z3950::SimpleServer module.
289  
290 Penultimate lap. You need the SimpleServer module on which
291 C<zSQLgate> is built: go to http://www.indexdata.com/simpleserver/ and
292 download it. Unpack the archive, and do the usual Perl thing: C<perl
293 Makefile.PL>, C<make>, C<make test> and then, as root, C<make
294 install>.
295  
296  
297 =head2 Install zSQLgate itself.
298  
299 You've surely got the hang of this by now? :-) Unpack the archive,
300 then C<perl Makefile.PL>, C<make> ... Ah, you can figure the rest
301 out. (OK, for those of a nervous disposition, the sequence ends:
302 C<make test> and then, as root, C<make install>)
303  
304 Congratulations. You're done!
305  
306  
307 =head2 ### Install XSLT support - see http://sql.z3950.org/xslt/
308  
309  
310 =head1 TROUBLESHOOTING
311  
312 Here are a few of the thing that might go wrong:
313  
314  
315 =head2 No C Compiler
316  
317 When you come to build C<DBI>, a C<DBI> driver, YAZ or the
318 SimpleServer module, you may find that the C<make> phase fails, saying
319 something like:
320  
321 make: cc: Command not found
322  
323 This means you don't have a C compiler installed (or its not in your
324 path). Go to your operating system's install media and remedy this
325 deficiency. If the CD-ROM doesn't have a C compiler on it, then you
326 have problems: this used to happen a lot years ago - it was called
327 ``unbundling'' - but it's thankfully very rare now except on Microsoft
328 operating systems. If that's your problem, then your best best is
329 probably just to upgrade to a Real Computer. Oops, sorry, it just
330 slipped out.
331  
332  
333 =head2 Missing DBI Driver
334  
335 When you come to actually run C<zSQLgate>, you may find that it starts
336 correctly but dies when a client connects to it, saying something
337 like:
338  
339 install_driver(CSV) failed: Can't locate DBD/CSV.pm in @INC
340 Perhaps the DBD::CSV perl module hasn't been fully installed,
341 or perhaps the capitalisation of 'CSV' isn't right.
342 Available drivers: ExampleP, Pg, Proxy.
343  
344 Actually, this message is pretty clear: it's telling you that you've
345 not installed the driver that C<zSQLgate>'s configuration file wants
346 to use. You'll need to go back to CPAN and find, download, unpack,
347 build and install the relevant driver.
348  
349 (Why does this message only appear when a client connects? Because
350 C<DBI> loads its drivers at run-time - in fact, at the point where it
351 tries to connect to the RDBMS - rather than when the Perl program is
352 compiled. Which is, of course, because it can't tell in advance what
353 drivers you're going to want to use.)
354  
355  
356 =head1 HELP!
357  
358 If all this just seems too much, or if you're really stuck,
359 installation consultancy is available from the author. Email me.
360  
361  
362 =head1 AUTHOR
363  
364 Mike Taylor E<lt>mike@miketaylor.org.ukE<gt>
365  
366 First version Thursday 7th March 2002.
367  
368 =cut
369  
370 1;