File: dbadmin.html

package info (click to toggle)
aolserver4 4.5.1-15.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 11,772 kB
  • sloc: ansic: 45,120; tcl: 5,532; sh: 1,021; makefile: 380; pascal: 219; php: 13
file content (523 lines) | stat: -rw-r--r-- 12,778 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<html>
<head>
<title>AOLserver</title>
</head>
<body>
     

<h1>AOLserver Database Administration Guide</h1>

<p>
<small>
$Header: /cvsroot/aolserver/aolserver.com/docs/admin/dbadmin.html,v 1.1 2002/03/07 19:15:34 kriston Exp $
</small>
<p>


<p>

<a href=#1>What is a Database?</a>

<p>

<a href=#2>Databases and AOLserver</a>

<p>

<a href=#3>Internal vs. External Drivers</a>

<p>

<a href=#4>Available Database Drivers</a>

<p>

<a href=#5>Internal Database Drivers</a>

<p>

<a href=#6>External Database Drivers</a>

<p>

<a href=#7>Developing Database Drivers for AOLserver</a>


<p>

<h2><a name=1>What is a Database?</a></h2>

<p>

A database is a collection of data stored in a computer. A Database
Management System (DBMS) is a software package that efficiently
manages databases and lets one or more people use or modify the
contents of the database. The main function of the DBMS is to manage
the internal representation of the data in a form optimized for
computer access, and to respond to requests from users to access or
modify the data. The DBMS translates these requests into database
commands that it then performs on the data.

<p>

One of the most common and powerful languages for accessing databases
is SQL. SQL (Structured Query Language) commands perform actions on
the database. There are two types of SQL commands: DDL (Data
Definition Language) commands, which are used to define the structure
of the data, and DML (Data Manipulation Language) commands, which are
used to manipulate the data itself. The data is organized into tables
in the database. Tables contain rows (sometimes called records) and
columns (sometimes called fields). The structure of the table and its
columns is defined by DDL commands. The commands to insert or update
values in the rows of the table are DML commands.

<p>


<h2><a name=2>Databases and AOLserver</a></h2>

<p>

AOLserver can be configured to have access to multiple databases
through AOLserver's database drivers. AOLserver creates a database
pool, a group of connections to a database, for each database it
accesses.

<p>

You can write your own Tcl or C extensions to
access the database. See the Tcl Developer's Guide and the C
Developer's Guide for more information.

<p>

<h2><a name=3>Internal vs. External Drivers</a></h2>

<p>

Prior to Version 2.1, AOLserver provided a tightly-coupled solution to
database driver integration, with database client libraries linked
directly into the server. Such database drivers are called internal
drivers.

<p>

Since Version 2.1, AOLserver provides an additional, loosely-coupled
architecture, where AOLserver redirects all database requests to a
separate process known as the database proxy daemon. This is
accomplished using a special external driver, which looks just like an
internal database driver to AOLserver.

<p>



<p>

 

<p>



<p>


  

<h2><a name=4>Available Database Drivers</a></h2>

<p>

AOLserver provides internal database drivers for Postgres and Solid.
AOLserver also provides external database drivers for Sybase.
Third-party database drivers are provided for Oracle, Informix, and
InterBase.

<p>

Database Type of Driver Location
Postgres95/PostgreSQL Internal A free implementation of SQL, available
at: http://www.postgresql.org

<p>

Database driver available at: /examples/c/postgres
Solid Internal A reasonably priced RDBMS available on several
platforms at: http://www.solidtech.com

<p>

Database driver available at: /examples/c/solid
Sybase External A well-known RDBMS available at: http://www.sybase.com

<p>

Database driver available at: /examples/c/nssybpd

<p>

Note: Since we cannot ship anything that includes Sybase's client
librarys, you'll need to compile the Sybase driver example.
Oracle 8 Internal or External The most popular RDBMS.

<p>

Database driver available from ArsDigita at:
http://arsdigita.com/services.html
Informix Universal Server Internal or External A well-known RDBMS.

<p>

Database driver available from ArsDigita at:
http://arsdigita.com/services.html
InterBase External Database driver available at:
http://www.lavsa.com/sskracic/aolinterbase/

<p>



<p>

 

<p>



<p>


  

<h2><a name=5>Internal Database Drivers</a></h2>

<p>

 Configuration

<p>

Configuration for an internal database driver consists of setting
parameters for the internal driver and creating a database pool that
uses that driver.

<p>

The internal database driver parameters can be typed directly in the
configuration file as described below. This example describes the
steps involved in configuring an internal driver to interface with the
Postgres or Solid driver.

<p>

Configure an Internal Database Driver

<p>

<br>
 1. Edit your AOLserver configuration file, usually named nsd.tcl.
<br>
 2. Add a configuration file section called ns/db/drivers:
<br>
 ns_section "ns/db/drivers"
<br>
 3. List the database drivers you will be using. For example:
<br>
 ns_section "ns/db/drivers"
<br>
 ns_param postgres nspostgres.so
<br>
 ns_param solid nssolid.so
<br>
 4. Add a configuration file section to list your database pools. For
 example:
<br>
 ns_section "ns/db/pools"
<br>
 ns_param mypool "This pool will use Solid"
<br>
 5. Add a configuration file section to define the database pool you
 have named. For example:
<br>
 ns_section "ns/db/pool/mypool"
<br>
 ns_param Driver solid
<br>
 ns_param Datasource "TCP/IP hostname 1313"
<br>
 ns_param Connection 1
<br>
 6. Choose which server or servers is to have access to the database
 pools you have defined. For each server, add a configuration file
 section to define which database pools it can access. For example:
<br>
 ns_section "ns/server/servername/db"
<br>
 ns_params Pools *

<p>

  The "*" designation means that this server can access any of the
 defined database pools.

<p>

 Solid Database

<p>

The SOLID database is a reasonably-priced database from Solid
Information Technology that can be installed on many platforms.
AOLserver provides an internal database driver for the SOLID database.
Temporary evalation copies can be downloaded from their web site,
http://www.solidtech.com. There are some special considerations with
using the SOLID database that are addressed in this section.

<p>

This database driver is installed in the same way as other database
drivers. Add nssolid.so as a database driver in the ns/db/drivers
section of the configuration file. When you create a database pool for
it, the correct format for the datasource is this:
 TCP/IP hostname 1313

<p>

TCP/IP specifies the protocol with which the SOLID AOLServer driver
will communicate with the SOLID database server. The hostname is the
fully-qualified hostname on which the SOLID database server resides,
and 1313 is the port on that server where it is listening.

<p>

If you are using the nssolid database driver on Solaris 2.5.1, you
need to set the LD_PRELOAD environment variable as follows:
 setenv LD_PRELOAD /usr/lib/libm.so.1

<p>

Note that the Solid database driver only works with nsdp under Irix.

<p>

Special thanks to Robert Locke for contributing the code for this
module.

<p>



<h2><a name=6>External Database Drivers</a></h2>

<p>

The external driver sends messages to the external database proxy
daemon instead of calling database client libraries directly. This
database proxy daemon can be a local or remote process. The reason for
this seemingly unnecessary indirection is that some database client
libraries are undesirable partners in the AOLserver process space. For
example, they may make assumptions regarding per-process resources
such as signals, or they may not be thread-safe. Also, platforms
without support for a particular database client library can still
interface with a database via a remote database proxy daemon.

<p>

A database proxy daemon is created for each connection in an AOLserver
database pool. Like connections within a pool configured for an
internal driver, the connections associated with proxy daemons are
efficiently managed by the AOLserver on an ad hoc basis. Thus,
database proxy daemon processes are created and shut down by the
AOLserver as demand for concurrent database handles varies over time.

<p>

This distributed approach is not intended to replace the existing
practice of linking database client libraries into the server via a
driver. It merely provides an alternative interface
mechanism--augmenting the choices available to developers who are
extending the AOLserver database interface capabilities. It is likely,
however, that this distributed approach, i.e. a separate process per
database connection, will improve overall database throughput, even
with the additional communication overhead. We expect this performance
improvement because vendor-supplied database client libraries, running
within a multi-threaded server, must limit concurrency via resource
locks.

<p>

 Configuration

<p>

Configuration for an external database driver consists of setting
parameters for the external driver and creating a database pool that
uses that driver. An external driver is configured to spawn and
communicate with a database-specific proxy daemon. Database proxy
daemons are provided for Sybase.

<p>

The following example describes the steps involved in configuring an
external driver to interface with the Sybase proxy daemon.

<p>

Configure an External Database Driver

<p>

<br>
 1. Edit your AOLserver configuration file, usually named nsd.tcl.
<br>
 2. Add a configuration file section called ns/db/drivers:
<br>
 ns_section "ns/db/drivers"
<br>
 3. List the Sybase database driver. For example:
<br>
 ns_section "ns/db/drivers"
<br>
 ns_param extsyb nssybpd.so
<br>
 4. Configure the Sybase driver. For example:
<br>
 ns_section "ns/db/driver/extsyb"
<br>
 ns_param LocalDaemon nssybpd
<br>
 ns_param Param SYBASE-env-variable
<br>

<p>
 
  The Param parameter should be set to the value of the SYBASE
 environment variable.

<p>

<br>
 5. Add a configuration file section to list your database pools. For
 example:
<br>
 ns_section "ns/db/pools"
<br>
 ns_param mypool "This pool will use Sybase"
<br>
 6. Add a configuration file section to define the database pool you
 have named. For example:
<br>
 ns_section "ns/db/pool/mypool"
<br>
 ns_param Driver extsyb
<br>
 7. Choose which server or servers is to have access to the database
 pools you have defined. For each server, add a configuration file
 section to define which database pools it can access. For example:
<br>
 ns_section "ns/server/servername/db"
<br>
 ns_params Pools *

<p>

  The "*" designation means that this server can access any of the
 defined database pools. 

<p>

 Remote Database Proxy Daemons

<p>

The previous example showed configuration of a local proxy daemon. One
of the advantages of the external driver interface is that you are
free to run database proxy daemons on any other host, perhaps one on
which database vendor client libraries are more readily available or
more reliable.

<p>

The following example shows how to configure an interface to a proxy
daemon on a remote machine.

<p>

Configure a Remote External Database Driver

<p>

<br>
 1. Edit your AOLserver configuration file as described in the
 previous section, "External Database Drivers" section.
<br>
 2. In the ns/db/drivers/extsyb configuration section, delete the
 definition for the LocalDaemon parameter.
<br>
 3. Add definitions for the RemoteHost and RemotePort parameters. For
 example:
<br>
 ns_section "ns/db/driver/extsyb"
<br>
 ns_param RemoteHost host-name
<br>
 ns_param RemotePort port-number
<br>
 ns_param Param SYBASE-env-variable
<br>
 4. Run nssybpd, or configure inetd as shown in the next step instead.
<br>
 For example:
<br>
 nssybpd 8199
<br>
 5. As an alternative to running nssybpd as shown in the previous
 step, you can configure inetd on the target remote machine as
 follows.
<br>
1. Add the following line to /etc/inet/services:
<br>
 nssybpd 8199/tcp
<br>
1. Add the following line to /etc/inet/inetd.conf:
<br>
 nssybpd stream tcp nowait sa /serverhome/bin/nssybpd nssybpd
<br>

<p>

  (Type the above all on one line.)

<p>

 1. Send a SIGHUP signal to your inetd process.

<p>

 Tcl Interface

<p>

In addition to the built-in, database-driver independent ns_db Tcl
functions, the ns_ext function is available for special functions that
relate to the external driver mechanism. In general, you will not need
to use ns_ext for most database operations. The ns_ext functions are
used primarily by the ns_db functions, but ns_ext is provided in the
event that you need to call it directly.

<p>

<h2><a name=7>Developing Database Drivers for AOLserver</a></h2>

<p>

For information on developing your own database drivers, see the
Database Drivers Development guide.

<p>

</body>
</html>