File: driv-ch6.htm

package info (click to toggle)
aolserver 3.4.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 22,692 kB
  • ctags: 33,612
  • sloc: ansic: 171,340; tcl: 10,218; sh: 3,821; cpp: 2,779; makefile: 2,041; yacc: 1,648; perl: 456; php: 13
file content (159 lines) | stat: -rw-r--r-- 8,709 bytes parent folder | download | duplicates (2)
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
<HTML><HEAD>
<TITLE>Database Access -- External Database Drivers</TITLE>
<LINK rel=Previous href="driv-ch5.htm">
<LINK rel=ToC href="toc.htm">
<LINK rel=Index href="master.htm">
<LINK rel=Next href="driv-ch7.htm">
</HEAD><BODY BGCOLOR="#ffffff"><A NAME="topofpage"></A>
<TABLE WIDTH=100%>
  <TR>
    <TD ALIGN=LEFT>
      <A NAME="topofpage"></A> <IMG  SRC="as-c-sm.gif">
    </TD>
    <TD ALIGN=RIGHT>
      <A href="driv-ch5.htm"><IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
      <A href=toc.htm> <IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
      <A href=master.htm> <IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
      <A href="driv-ch7.htm"> <IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
      <A name="7983"> </A>
    </TD>
  </TR>
</TABLE>

<a name="31400">
</a><h3>External Database Drivers</h3>
<p><a name="31414">
</a>The <i>external driver</i> 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>
<p><a name="31421">
</a>A <i>database proxy daemon</i> 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>
<p><a name="31428">
</a>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>
<a name="31437">
</a><h4>Configuration</h4>
<p><a name="31438">
</a>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>
<p><a name="31440">
</a>The following example describes the steps involved in configuring an external driver to interface with the  Sybase proxy daemon.</p>
<a name="31441">
</a><h5>Configure an External Database Driver</h5>
<ol>
<li>Edit your AOLserver configuration file, usually named nsd.tcl.
<a name="40347">
</a><p>
<li>Add a configuration file section called ns/db/drivers:
<a name="40348">
</a><p>
<pre>    <a name="40349"></a>ns_section "ns/db/drivers"
</pre><p><li>List the Sybase database driver.  For example:
<a name="40350">
</a><p>
<pre>    <a name="40351"></a>ns_section "ns/db/drivers"
    <a name="40352"></a>ns_param extsyb nssybpd.so
</pre><p><li>Configure the Sybase driver. For example:
<a name="40354">
</a><p>
<pre>    <a name="40420"></a>ns_section "ns/db/driver/extsyb"
    <a name="40421"></a>ns_param LocalDaemon nssybpd
    <a name="40432"></a>ns_param Param <i>SYBASE-env-variable
</i></pre><p><dl>
<dt>The Param parameter should be set to the value of the SYBASE environment variable. For a description of the all the parameters, see <a href="con-ch3.htm#66659">page 73</a>.<a name="40441">
</a>
<p></dl>
<li>Add a configuration file section to list your database pools. For example:
<a name="40477">
</a><p>
<pre>    <a name="40478"></a>ns_section "ns/db/pools"
    <a name="40479"></a>ns_param mypool "This pool will use Sybase"
</pre><p><li>Add a configuration file section to define the database pool you have named.  See<a href="con-ch3.htm#26424">page 75</a> for a complete list of database pool parameters. For example:
<a name="40480">
</a><p>
<pre>    <a name="40484"></a>ns_section "ns/db/pool/mypool"
    <a name="40485"></a>ns_param Driver extsyb
</pre><p><li>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:
<a name="40365">
</a><p>
<pre>    <a name="40366"></a>ns_section "ns/server/Server1/db"
    <a name="40367"></a>ns_params Pools *
</pre><p><dl>
<dt>The "*" designation means that this server can access any of the defined database pools. See <a href="con-ch3.htm#67160">page 58</a> for a complete list of parameters for this section.<a name="40368">
</a>
<p></dl>
</ol>
<a name="31512">
</a><h4>Remote Database Proxy Daemons</h4>
<p><a name="31513">
</a>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>
<p><a name="31514">
</a>The following example shows how to configure an interface to a proxy daemon on a remote machine.</p>
<a name="31515">
</a><h5>Configure a Remote External Database Driver</h5>
<ol>
<li>Edit your AOLserver configuration file as described in the previous section, <a href="driv-ch6.htm#31400">"External Database Drivers" section</a>.
<a name="31516">
</a><p>
<li>In the ns/db/drivers/extsyb configuration section, delete the definition for the LocalDaemon parameter. 
<a name="40541">
</a><p>
<li>Add definitions for the RemoteHost and RemotePort parameters. For example: 
<a name="40542">
</a><p>
<pre>    <a name="40548"></a>ns_section "ns/db/driver/extsyb"
    <a name="40549"></a>ns_param RemoteHost <i>host-name
</i>    <a name="40555"></a>ns_param RemotePort p<i>ort-number
</i>    <a name="40550"></a>ns_param Param <i>SYBASE-env-variable
</i></pre><p><li>Run <code>nssybpd</code>, or configure <code>inetd</code> as shown in the next step instead. For example:
<a name="31522">
</a><p>
<pre>    <a name="34282"></a>nssybpd 8199
</pre><p><li>As an alternative to running <code>nssybpd</code> as shown in the previous step, you can configure <code>inetd</code> on the target remote machine as follows. 
<a name="34280">
</a><p>
<ol>
<li>Add the following line to <code>/etc/inet/services</code>:
<a name="31523">
</a><p>
</ol>
<pre>    <a name="31524"></a>nssybpd			8199/tcp	
</pre><p><ol>
<li>Add the following line to <code>/etc/inet/inetd.conf</code>:
<a name="31525">
</a><p>
</ol>
<pre>    <a name="31526"></a>nssybpd stream tcp nowait sa 
    <a name="31527"></a>/<i>serverhome</i>/bin/nssybpd nssybpd
<dl>
<dt>(Type the above <i>all on one line</i>.)<a name="31528">
</a>
<p></dl>
</pre><p><ol>
<li>Send a <code>SIGHUP</code> signal to your <code>inetd</code> process.
<a name="31529">
</a><p>
</ol>
</ol>
<a name="31530">
</a><h4>Tcl Interface</h4>
<p><a name="31531">
</a>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 (see <a href="tapi-c54.htm#82709">page 105</a> of the <i>AOLserver Tcl Developer's Guide</i>).</p>


<TABLE BORDER="2" CELLPADDING="1" width="100%">
<TR><TD COLSPAN=3><P ALIGN=Center>
<IMG SRC="bluebult.gif">
<A HREF="#topofpage">
<FONT SIZE=-1>Top of Page</FONT></A>
<IMG SRC="bluebult.gif">
</TD></TR>
<TR><TD COLSPAN=3><P ALIGN=Center>
<A href="driv-ch5.htm">
<IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm>
<IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm>
<IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="driv-ch7.htm">
<IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<BR align=center>
<FONT size=-1>Copyright &copy; 1998-99 America Online,
Inc.</FONT>
</TD></TR></TABLE></BODY></HTML>