⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mu_ch4.htm

📁 db.* (pronounced dee-be star) is an advanced, high performance, small footprint embedded database fo
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 97"><title>db.* Multi-User Guide Chapter 4</title></head><body><h1><a name="Reference" id="Reference"></a>Chapter 4<br>Lock Manager Reference</h1><h2><a name="Introduction" id="Introduction"></a>4.1Introduction</h2><p><font size="2">For ease of reference, all lock manager-related<b><i>db.*</i></b> utilities and functions are collected in thischapter. Section 4.2 details the operation of lock manager-relatedprograms. Section 4.3 covers several key lock manager-relatedfunctions provided by the <b><i>db.*</i></b> runtimelibrary.</font></p><h2><a name="Utilities" id="Utilities"></a>4.2 Lock Managers andUtilities</h2><h3><a name="console" id="console"></a>console</h3><p><font size="2">Lock manager remote console</font></p><h4>Prototype</h4><pre><font color="#0000FF">console [-m<i>type</i>] [-a <i>name</i>] [-h] [-s] [-r#] </font></pre><h4>Description</h4><p><font size="2">This program allows you to monitor thefunctioning of the lock manager and control its behavior. You canrun a console wherever a <b><i>db.*</i></b> application canrun.</font></p><p>Console programs poll the lock manager often, requiringcomputation and using network bandwidth. Consoles may degrade thelock manager's performance.</p><h4>Options</h4><p><font size="2">-m<i>type</i><br>Selects a lock manager type. For <i>type</i>, use one of the valueslisted below. For UNIX or QNX:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNIX domain socket lock manager(LMC_IP)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCP lock manager(LMC_TCP)</font></p><p>-a <i>name</i><br>Specifies the name given to the lock manager you are attempting tomonitor. The default name is <b>lockmgr</b>.</p><p>-h<br>Provides help information.</p><p>-s<br>Sends a shutdown command to the lock manager (for batch files).</p><p>-r#<br>Specifies the number of seconds between refreshes of the data. Thedefault is 2 and the maximum is 59.</p><h4>Commands</h4><p><font size="2">Within the remote console program and thededicated lock manager are several commands you can enter todisplay different data or to control the lock manager. The commandsare listed below.</font></p><p><b>FILE</b> &lt;<i>num</i>&gt;<br>Displays detailed information on the specified file.</p><p><b>FILES<br></b>For each file that is open, displays the fileidentifier, the type of lock held and how many users have the lock,the first user that has the file locked, and users with pendinglock requests.</p><p><b>HELP</b><br>Displays the commands available within the program.</p><p><b>KILL</b>&lt;<i>user</i>&gt;<br>Disconnects the user from the lock manager and frees all locks andfiles held by that user. If the user is still active, all further<b><i>db.*</i></b> calls accessing the lock manager will returnS_LMCERROR.</p><p><b>EXIT</b> &amp; <b>QUIT<br></b>Logs out of the lock managerand terminates the console program. The lock manager is leftrunning.</p><p><b>SHUTDOWN<br></b>Shuts down the attached lock manager andterminates the console program. If any users are still active, allfurther <b><i>db.*</i></b> calls accessing the lock manager willreturn S_LMCERROR.</p><p><b>STATUS</b><br>Displays main status screen showing lock statistics, operationalparameters, and logged-in users.</p><p><b>USER</b> &lt;<i>name</i>&gt;<br>Displays detailed information on the specified user.</p><p><b>USERS</b><br>For each logged-in user, displays a protocol-specific connectionidentifier, the number of queued lock requests, the lock time-outvalue, the user status, and the log file name.</p><p>The <b>kill</b> command forces the lock manager to remove a userand to clean up. Cleanup involves removing entries from the lockmanager's internal tables, releasing locks, and deleting certainfiles.</p><p>Normally this cleanup is carried out as the result of a call to<b>d_close</b> by an <b><i>db.*</i></b> application. If this doesnot happen, use the <b>kill</b> command.</p><p>Several situations might cause an application to lose contactwith the lock manager without calling <b>d_close</b>. Some possiblecauses are power failure, protection faults, unhandled exceptions,and physical network failure. If <b>d_close</b> is not called, thelock manager must rely on the network protocol to inform it of thelost connection. Network transports vary in their ability toreliably perform this function.</p><p>The OS services used by the UNIX and Linux lock managers attemptto detect abnormal application termination. However, for each lockmanager type there are certain failure modes that cannot bedetected.</p><p>You can test your own network's ability to report abnormaldisconnections by inducing different sorts of failure and watchingthe console. If the user does not disappear from the user list, thelock manager is unaware that the connection has been lost. Usingthe <b>kill</b> command will perform the necessary cleanup.</p><hr><h3><a name="lm" id="lm"></a>lm</h3><p><font size="2">Lock manager</font></p><h4>Prototype</h4><pre><font color="#0000FF">lm [-m<i>type</i>] [-a <i>name</i>] [-f <i>ddd</i>] [-l [<i>logfile</i>]] [-n] [-q <i>ddd</i>] [-u <i>ddd</i>] [-z <i>dir</i>]</font></pre><h4>Description</h4><p><font size="2">The lock manager supports TCP/IP Internet domainsockets for network and local connections (the mt option), and UNIXdomain sockets for local connections only (the mp option). Use ofInternet domain (TCP) sockets enables locking of databases onnetwork file systems (usually NFS) by applications that are not onthe same system as the lock manager. Thus, if the mt option isused, it is possible to have the lock manager on the same system asall, some, or none of its client applications.</font></p><p>Files are identified in the lock manager by a "pathname" whichincludes the NFS host name and mount path along with the<b>i-node</b> numbers (where applicable) rather than by the actualnames, since on UNIX/Linux NFS file systems, one file can bereferenced by different names.</p><p>The runtime will initially attempt to connect to <b>lm</b> usingUNIX domain sockets since they provide superior performance overTCP. However, a TCP connection can be forced by using the host:portlock manager name syntax.</p><p>It is possible to serve a set of heterogeneous clients with asingle <b>lm</b> instance. This is straightforward when theheterogeneous systems have the same byte ordering (for example, SunSPARC and HP or SCO and QNX). In cases where the byte ordering isdifferent (as with HP and SCO), the lock manager is capable ofresolving the byte ordering issues in locking messages, but it isthe application's responsibility to deal with these issues in thedatabase itself. In most cases, such configurations are notpractical since they would require modifications to the runtimesource on one of the platforms.</p><h4>Termination</h4><p><font size="2">With <b>lm</b> you can terminate cleanly from theconsole, using <b>lmclear</b>, or you c an send the SIGINT signalwith the <b>interrupt</b> command (or the keyboard equivalent whenthe lock manager is not running in the background). In the event ofan abnormal termination, it may be necessary to remove UNIX domainsocket files from DBTMP manually or by using <b>lmclear</b>.Failure to perform this cleanup could cause a subsequent restart ofthe lock manager to fail.</font></p><h4>Performance</h4><p><font size="2">TCP connections will typically perform morepoorly than UNIX domain socket connections, although local TCPconnections are naturally slightly faster than networkconnections.</font></p><h4>Options</h4><p><font size="2">Each option is preceded by a dash and most take aparameter. For those that take a numerical parameter, the defaultis noted and the maximum is constrained by available resources andthus is hardware, OS, and OS configuration specific. Theseparameters should not normally be set below their defaultvalues.</font></p><p>-a <i>name</i><br>Specifies a runtime name for the lock manager. The default name is<b>lockmgr</b>. For more details on lock manager naming, seeChapter 2.</p><p>-f <i>ddd</i><br>Sets the maximum number of files. The lock manager maintains atable of all database files that have been opened by its clients.The value following this switch is the maximum number of files thatcan be opened by this lock manager. The default is 256.</p><p>-l <i>[logfile]</i><br>Turns on error logging. If no <i>logfile</i> is specified thedefault is "lockmgr.log". This option can significantly degradelock manager performance and is only available on lock managersbuilt with the MONITOR flag.</p><p>-m<i>type</i><br>Selects a lock manager <i>type</i>. Use one of the values listedbelow.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNIX domain socket lock manager<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCP lock manager</p><p>-n<br>Do not daemonize the lock manager (run it as a background process)on startup.</p><p>-q <i>ddd</i><br>Sets the maximum number of entries in a lock request queue. If alock request cannot be immediately granted, it is placed in thelock request queue. Note that there is one queue entry for eachlock requested for each file. Thus, it is possible for a singlelock manager "user" to have multiple entries in the queue at thesame time even if they were submitted as one logical request. Thedefault is 128.</p><p>-u <i>ddd</i><br>Sets the maximum number of users. The lock manager maintains atable of active users. The value following this switch is themaximum number of users that can log into this lock manager. Thedefault is 20.</p><p>-z <i>dir</i><br>Sets the DBTMP directory to <i>dir</i>.</p><hr><h3><a name="lmclear" id="lmclear"></a>lmclear</h3><p><font size="2">Clears lock manager session (allplatforms)</font></p><h4>Prototype</h4><pre><font color="#0000FF">lmclear [-l] [-s] [-a <i>name</i>] [-u <i>userid</i>] [-m<i>type</i>]</font></pre><h4>Description</h4><p><font size="2">The <b>lmclear</b> utility has three main uses.The first clears a user with whom communication has been lost, andthis is unknown to the lock manager. (Clearing a user means to freelocks and get ready for transaction recovery.) This use isequivalent to the <b>kill</b> command in the lock manger<b>console</b>. The second use is to obtain a status report on thelock manager, equivalent to the <b>console</b> command USER. Thefinal use of <b>lmclear</b> is to shut down the lock manager,equivalent to issuing the SHUTDOWN command from the<b>console</b>.</font></p><p>See the entry for <b>console</b> in this chapter for morecommand details.</p><h4>Options</h4><p><font size="2">-l<br>Equivalent to the console's SHUTDOWN command.</font></p><p>-s<br>Prints status report for all users.</p><p>-a <i>name</i><br>The <b>-</b>a <i>name</i> option specifies the lock manager name tobe accessed. This option is not necessary if the environmentvariable LOCKMGR specifies the name.</p><p>-u <i>userid<br></i>Instructs the lock manager to clear the userspecified by <i>userid</i>. This option is not necessary if theenvironment variable DBUSERID specifies the user.</p><p>-m<i>type</i><br>Selects a lock manager type. The -m<i>type</i> option is present tosupport the need to call <b>d_lockcomm</b> before <b>d_open</b>.For <i>type</i>, use one of the following values.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNIX domain socket lock manager<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCP lock manager</p><h2><a name="Functions" id="Functions"></a>4.3 Lock Manager-Relatedd_ Functions</h2><p><font size="2">The functions documented in the following sectionare designed to work with the lock manager from within<b><i>db.*</i></b> applications.</font></p><hr><h3><a name="lmclear" id="lmclear"></a>d_lmclear</h3><p><font size="2">Clears a user from the lock manager's usertable</font></p><h4>Prototype</h4><pre><font color="#0000FF">d_lmclear(const char *<i>username</i>, const char <i>*lockmgr</i>, LMC_AVAIL_FCN *<i>avail, </i>DB_TASK *<i>task</i>) </font></pre><h4>Parameters</h4><p><font size="2">username<br>The name of the user to be removed from the lock manager's usertable.</font></p><p><font size="2">lockmgr<br>The lock manager name.</font></p><p><font size="2">avail<br>The address of a function to check the availability of a particulartransport. This function can be hard coded, or can be "found" withthe function psp_lmcFind().</font></p><p><font size="2">task<br>A pointer to the application's task variable.</font></p><h4>Description</h4><p><font size="2">This function provides the same functionality asthe program <b>lmclear.exe</b>. Function <b>d_lmclear</b> clearsthe specified user from the lock manager's user table. It can becalled any time, either before or after opening adatabase.</font></p><h4>Currency Changes</h4><p><font size="2">None.</font></p><h4>Locking Requirements</h4><p><font size="2">None.</font></p>

⌨️ 快捷键说明

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