mu_ch3.htm
来自「db.* (pronounced dee-be star) is an adva」· HTM 代码 · 共 484 行 · 第 1/2 页
HTM
484 行
managers for any practical number of users is not typicallysignificant.</font></p><p>The TCP and UNIX domain socket lock managers consume filedescriptors on a one per user basis plus a fixed overhead. Forsafety and simplicity, a reasonable estimation for the number offile descriptors needed is ten plus the number of users. MostUNIX/Linux platforms have a per process open file descriptor limitconfigured into and enforced by the kernel. On many of thesesystems, there is both a soft limit that is set lower by defaultthan the hard limit enforced by the kernel. Where an API isavailable, these lock managers attempt to set the soft limit to thehard limit to avoid problems. Increasing the hard limit involvesreconfiguring the kernel. Some systems (mostly SVR4) have a kernelconfiguration file that is read at boot time to set soft and hardlimit parameters. On other systems such as BSD UNIX variants, thenormal procedure involves editing a configuration file andrebuilding the kernel. In any case, the procedures are highlysystem dependent and have potential to cause serious harm to thesystem (for example, the system will no longer boot) if carried outincorrectly. Carefully read your relevant system administrationdocumentation before attempting any such procedure.</p><p>On systems that implement the System V IPC primitives in thekernel, modifying these parameters involves reconfiguring thekernel as discussed above. On systems in which the System V IPCsystem does not involve the kernel, there will be a different meansof setting these parameters unless they happen to only beconstrained by other resource limits. Again, consult your relevantsystem administration documentation carefully before attempting tomake any changes.</p><h3><a name="Naming" id="Naming"></a>3.3.7 Lock Manager Naming</h3><h4>Setting Lock Manager Names</h4><p><font size="2">When not using the default lock manager name (seebelow for specific cases), the name of a lock manager is mosttypically specified using the <b>-a</b> command line switch whenstarting the lock manager. However it can also be set via theLOCKMGR environment variable. The name of the lock manager beingused by an application can be set using the <b>d_lockmgr</b> APIcall, the LOCKMGR environment variable, or the <b>db.star.ini</b>file.</font></p><h4>Local Lock Managers</h4><p><font size="2">Naming local lock managers is quite simple. TheUNIX domain socket lock manager has the default name of "lockmgr".When using only one lock manager of given type on a system, nocomplications arise from using the default and you avoid thenecessity of setting the lock manager name for both the lockmanager and lock manager clients. When using multiple lock managerson the same system, it is necessary to set the appropriate names asdescribed above (although one lock manager can continue to use thedefault name if desired).</font></p><h4>TCP Lock Manager</h4><p><font size="2">Naming for the TCP lock manager is morecomplicated than for any of the others, partly because of itsinclusion of the UNIX domain lock manager functionality. As withthe other UNIX lock managers the default name is "lockmgr". Thisworks perfectly provided only local connections are used. Thislimited case is equivalent to using the UNIX domain socket lockmanager, and the same naming considerations apply.</font></p><p>However, to obtain a network (TCP) connection to the lockmanager it is necessary to identify the lock manager's host and(either implicitly or explicitly) the port on which it islistening. You can implicitly specify the port by putting a"db.star tcp" port specification in each system's<b>/etc/services</b> file, or in a network NIS services map, or byallowing it to default to 1523.</p><p>A complete explicit TCP lock manager name for a TCP connectionis of the form <b><i>hostname:port</i></b> where<b><i>hostname</i></b> is either a host's primary name, an aliasregistered in <b>/etc/hosts</b>, in NIS host maps, or with DNS(some of which will not be available on many systems), or an IPaddress. See the following list for an example:</p><table border="1" cellspacing="1" cellpadding="7" width="542"><tr><td width="56%" valign="top"><p><font size="2">IP address:port</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">192.0.1.205:1523</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">hostname:port</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">db.star:1611</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">hostname:port</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">db.star.domain.com:1611</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">IP address (implicit port)</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">192.0.1.204</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">hostname (implicit port)</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">db.star</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">hostname (implicit port)</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">db.star.domain.com</font></p></td></tr><tr><td width="56%" valign="top"><p><font size="2">local name (for UNIX domain socketsonly)</font></p></td><td width="44%" valign="top"><p><font face="Courier" size="2">lockmgr2</font></p></td></tr></table><p><font size="2">As a result of these considerations, the defaultname "lockmgr" can only work for TCP connections if the lockmanager port is specified implicitly, and the host it is on has aprimary name or alias of "lockmgr". However, note that it is stillpossible to mix TCP and UNIX domain socket connections in the samelock manager. Simply choose your name by taking TCP considerationsinto account and then using the <i>hostname</i> part of the name asthe lock manager name for local clients. See the following as anexample:</font></p><pre><font color="#0000FF">lm -mt -a wlw:1550setenv LOCKMGR wlwida -mt</font></pre><p><font size="2">If you specify a name in <b>hostname:port</b>format, even if the lock manager is local, a TCP connection will beestablished. Finally, keep in mind that the UNIX domain lockmanager and the UNIX domain socket part of the TCP lock managersshare the same name space on the local system.</font></p><p>While any of the formats described above will work, you cannotmix them. If you do, you will get a S_TAFSYNC TAF synchronizationerror, because lock manager names written to the TAF files will notmatch. Choose one representation for the lock manager name andstick with it.</p><p>More than one TCP lock manager can be run from the same hostprovided that both the name <i>and</i> the port are unique. Forexample, two lock managers named <b>lockmgr:1523</b> and<b>lockmgr2:1523</b> cannot be run on the same host, nor can<b>wlw:1523</b> and <b>wlw:1524</b>. You must set up one or morehost aliases to obtain the distinct <i>hostname</i> components ofthe lock manager names.</p><h3><a name="Filesystems" id="Filesystems"></a>3.3.8 NFSFilesystems</h3><p><font size="2">The TCP lock manager relies on file identifiersgenerated by the runtime of the form <i>fsname@hostname</i> plusthe <b>i-node</b>. The <b>fsname</b> is the absolute path of amount point and <i>hostname</i> is the server name or alias forthat mount point as extracted from the local mounted filesystemtable. The <b>i-node</b> parameter is the <b>i-node</b>. Creatingalternate paths to the mount point or individual files usingsymbolic links can also confuse the TCP lock manager and lead todata corruption. For example, an NFS host named <b>ufs2</b> mayhave a database stored in a directory named<b>/Centura/shared/db/tims</b>, with one of the files named<b>tims.d01</b> at an i-node of 34453. An NFS client may have thatdirectory mounted as <b>/db/tims</b>. The runtime library willconstruct the following canonical identifier for thefile:</font></p><pre><font color="#0000FF">/Centura/shared/db/tims@ufs2:34453 </font></pre><p><font size="2">This identifier will be the same from otherworkstations that may have the database drive mounted on adifferent local path.</font></p><p>Databases accessed by <b><i>db.*</i></b> that are kept on NFSfile systems are more susceptible to data loss and corruption thanfiles kept on a local disk because of the extra levels of cachinginvolved. If an NFS client system crashes (on most UNIX systemsthis happens rarely if ever) or suffers a power loss, data updatesin its local cache that were not written back to the file serverwill be lost. <b><i>db.*</i></b> provides the SYNCFILE option tohelp address this problem. The SYNCFILES option causes a cachesynchronization operation to be carried out after every writeoperation (usually by the <b>fsync()</b> function call). On a fewolder NFS file systems, this operation may not work reliably. Thisoption has an impact on database performance, and should be usedonly when there is a possibility of losing important data.</p><h2><a name="FileIssues" id="FileIssues"></a>3.4 TAF File Issues onUNIX/Linux</h2><p><font size="2">As discussed elsewhere in this manual, lockmanagers are not involved in the locking of the TAF file. Insteadthis task is handled strictly by the runtime librarycode.</font></p><p><font size="2">On UNIX, the default method for locking the TAFfile is the UNIX OS <b>lockf()</b> function. On Linux,<b>flock()</b> is used. Its functionality is primarily provided bya daemon <b>rpc.lockd</b>, which runs on the file server. Thus,this function is capable of handling lock requests fromapplications on multiple machines for the same file shared via anetwork file system. As such, it is fully capable of working withapplications using the <b><i>db.*</i></b> network locking approachas implemented by the TCP lock manager. Historically, there havebeen significant correctness and reliability problems with<b>lockf()</b> and specifically <b>rpc.lockd</b>. In recent yearsthese problems have largely been corrected. However, sourcecustomers still have the option of compiling the runtime to use thepredecessor to <b>lockf()</b>, the <b>flock()</b> function<b>.</b>The locks for <b>flock()</b> are only visible on the local machine,but it has the advantage of being faster than <b>lockf()</b>(usually ) and not having the correctness problems seen in olderversions of <b>lockf()</b>. Be aware, however, that UNIX is phasingout <b>flock()</b> and the function is already not available onsome platforms.</font></p><p><font size="2">An alternate method of locking the TAF file thatis not dependent on OS functions (that may have bugs or are notavailable) is the "portable locking" option. This option isimplemented using a "guard file" strategy, and the code is enabledby calling the function <b>d_on_opt</b> with the PORTABLE constant.To lock the TAF file, a process will attempt to delete a file named<b>db.star.lfg</b>, which serves as the guard file. If the<b>unlink</b> succeeds, then the TAF file is considered locked bythat process. If the <b>unlink</b> fails, the lock is not grantedand the process will sleep for one second and try again. Theprocess that does succeed will re-create <b>db.star.lfg</b> afteraccessing the TAF file. When using this portable locking method itmay be necessary to create <b>db.star.lfg</b> before any processesbegin execution. If <b>db.star.taf</b> does not exist,<b><i>db.*</i></b> automatically creates both it and<b>db.star.lfg</b>.</font></p><p><a href="MU_Ch4.htm">Next Page</a></p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?