|
| 以 PDF 格式下載這本書 (2106 KB)
Chapter 8 LP Print Service (Reference)This chapter provides background information on the LP print service. Where to Find Printer Tasks
The LP Print ServiceThe LP print service is a set of software utilities that allows users to print files while users continue to work. Originally, the print service was called the LP spooler. (LP stood for line printer, but its meaning now includes many other types of printers, such as laser printers. Spool is an acronym for system peripheral operation off-line.) The print service consists of the LP print service software, any print filters you might provide, and the hardware, such as the printer, system, and network connections. The Structure of the LP Print ServiceThis section describes the directory structure, files, logs, and commands of the LP print service. LP Print Service DirectoriesThe files of the LP print service are distributed among seven directories, as shown in the following table. Table 8–1 Directories for the LP Print Service
LP Print Service Configuration FilesThe lpsched daemon stores configuration information in the /etc/lp directory, as described in the following table. The configuration files listed in this table are private interfaces, and are subject to change in future releases. You should not build software that relies on these files being in their current locations or that relies on the data being in the format currently used. Table 8–2 Contents of the /etc/lp Directory
These configuration files serve a similar function to the /etc/printcap file on lpd-based print servers. Note – You can check the contents of the configuration files, but you should not edit these files directly. Instead, use the lpadmin command to make configuration changes. Your changes will be written to the configuration files in the /etc/lp directory. The lpsched daemon administers and updates the configuration files. The /etc/lp/printers directory has a subdirectory for each local printer known to the system. The following example shows the /etc/lp/printers subdirectories of printers sparc1 and luna.
The following table describes the files within each of the printer-specific directories.
The configuration file for the printer luna, /etc/lp/printers/luna/configuration, would typically appear as follows:
The terminfo DatabaseThe /usr/share/lib directory contains the terminfo database directory, which contains definitions for many types of terminals and printers. The LP print service uses information in the terminfo database to initialize a printer, to establish a selected page size, character pitch, line pitch, and character set, as well as to communicate the sequence of codes to a printer. Each printer is identified in the terminfo database with a short name. For a description of the structure of the terminfo database, see Printer Type. If necessary, you can add entries to the terminfo database, but doing so is a tedious and time-consuming process. For more information, see Adding a terminfo Entry for an Unsupported Printer. Daemons and LP Internal FilesThe /usr/lib/lp directory contains daemons and files used by the LP print service, as described in the following table. Table 8–3 Contents of the /usr/lib/lp Directory
LP Print Service Log FilesThe LP print service maintains two sets of log files that are described in the following table.
Print Queue LogsThe scheduler for each system keeps a log of print requests in the /var/spool/lp/tmp/system and /var/spool/lp/requests/system directories. Each print request has two files, one in each directory, that contain information about the request. The information in the /var/spool/lp/requests/system directory can be accessed only by root or lp. The information in the /var/spool/lp/tmp/system directory can be accessed only by the user who submitted the request, root, or lp. The following example shows the contents of the /var/spool/lp/tmp/starbug directory:
These files remain in their directories only as long as the print request is in the queue. Once the request is finished, the information in the files is combined and appended to the /var/lp/logs/requests file. This file is described in the next section. Use the information in the /var/spool/lp/logs directory if you need to track the status of a print request that is currently in the queue. History LogsThe LP print service records a history of printing services in two log files, lpsched and requests. These log files are located in the /var/lp/logs directory. You can use the information in these logs to diagnose and troubleshoot printing problems. An example of the contents of the /var/lp/logs directory is as follows:
The two most important log files for troubleshooting is the lpsched log, which contains information about local printing requests and the requests log, which contains information about print requests that are completed and no longer in the print queue. The requests log has a simple structure, so that you can extract data using common UNIX shell commands. Requests are listed in the order they are printed, and are separated by lines showing their request IDs. Each line below the separator line, the line that starts with =, is marked with a single letter that identifies the kind of information contained in that line. Each letter is separated from the data by a single space. The following example shows the contents of a requests log:
The following table shows the letter codes and the content of their corresponding lines in the LP requests log. Table 8–4 Letter Codes in the LP requests Log
The following table shows the outcome codes in the LP requests log and their descriptions. Table 8–5 Outcome Codes in the LP requests Log
Spooling DirectoriesFiles queued for printing are stored in the /var/spool/lp directory until they are printed, which might be only seconds. The following table shows the contents of the /var/spool/lp directory. Table 8–6 Contents of the /var/spool/lp Directory
LP Print Service CommandsThe following table lists frequently used LP print service commands. You must be root, lp, or assume an equivalent role to use the 1M commands. Table 8–7 Quick Reference to LP Print Service Commands
Functions of the LP Print ServiceThe LP print service performs the following functions:
How LP Administers Files and Schedules Local Print RequestsThe LP print service has a scheduler daemon called lpsched. The scheduler daemon updates the LP system files with information about printer setup and configuration. The lpsched daemon schedules all local print requests on a print server, as shown in the following figure, whether users issue the requests from an application or from the command line. Also, the scheduler tracks the status of printers and filters on the print server. When a printer finishes a request, the scheduler schedules the next request, if one exists, in the queue on the print server. Figure 8–1 The lpsched Daemon Schedules Local Print Requests
Each print server must have only one LP scheduler running. The scheduler is started when a system is booted, or enters run level 2, by the /etc/rc2.d/S80lp control script. Without rebooting the systems, you can stop the scheduler with the /etc/init.d/lp stop command and restart the scheduler with the /etc/init.d/lp start command. The scheduler for each system manages requests issued to the system by the lp commands. Scheduling Network Print RequestsEach print client communicates directly with a print sever over the network. The communication is done between the requesting command, such as lp, lpstat, cancel, lpr, lpq, or lprm, and the print service on the print server. Doing so, reduces the print system overhead on client only systems, improving scalability, performance and accuracy of data. Print servers listen for print request with the Internet services daemon (inetd). Upon hearing a request for print service from the network, the inetd daemon starts a program called the “protocol adaptor” (in.lpd). The protocol adaptor translates the print request and communicates it to the print spooler, and returns the results to the requester. This protocol adaptor starts on demand and exits when it has serviced the network request. This process eliminates idle system overhead for printing. This process also eliminates any additional system configuration for network printing support as was the case in previous versions of Solaris printing. Filtering Print FilesPrint filters are programs on the print server that convert the content of a queued file from one format to another format. A print filter can be as simple or as complex as needed. The SunOS release provides print filters in the /usr/lib/lp/postscript directory that cover most situations where the destination printer requires the data to be in PostScript format. If you need filters for non-PostScript printers, you have to create the filters and add them to the systems that need filters. A set of print filter descriptor files are provided in the /etc/lp/fd directory. These descriptor files describe the characteristics of the filter (for example, fast or slow filter), and point to the filter program (for example, /usr/lib/lp/postscript/postdaisy). What the Printer Interface Program DoesThe LP print service interacts with other parts of the operating system. The print service uses a standard printer interface program to do the following:
The LP print service uses the standard interface program, found in the /usr/lib/lp/model directory, unless you specify a different program. You can create custom interface programs, but you must make sure that the custom program does not terminate the connection to the printer or interfere with proper printer initialization. How the lpsched Daemon Tracks the Status of Print RequestsThe lpsched daemon keeps a log of each print request that it processes and notes any errors that occur during the printing process. This log is kept in the /var/lp/logs/lpsched file. Every night, the lp cron job renames the /var/lp/logs/lpsched file to a new lpsched.n file and starts a new log file. If errors occur or jobs disappear from the print queue, you can use the log files to determine what the lpsched daemon has done with a printing job. Cleaning Out Log FilesThe lpsched and requests log files in the /var/lp/logs directory grow as information is appended. The LP print service uses a default cron job to clean out the log files. The lp cron job is located in the /var/spool/cron/crontabs/lp file. The cron job periodically moves the contents of the log files. The contents of log are moved to log.1, and the contents of log.1 are moved to log.2. The contents of log.2 are lost (that is, replaced by the former contents of log.1) when log.2 gets overwritten. How to Change Frequency of Printer Request Log RotationThe requests log file on the printer server is rotated weekly rather than daily. You can change the rotation interval back to daily if the printer server is busy.
How Local Printing WorksThe print request follows the same path it would if the client and server were separate systems. Requests always flow from client to server following the same path. The following figure shows what happens when a user submits a request to print a PostScript file on a local printer, which is a printer connected to the user's system. The lpsched daemon on the local system does all processing, which might include matching the printer and content type, identifying the default printer, filtering the request, and starting the specified printer interface program. The printer interface program does the following:
Figure 8–2 The Local Printing Process
How Remote Printing WorksThe following figure shows what happens when a user on a Solaris print client submits a print request to an lpd-based print server. The command opens a connection and handles it's own communications with the print server directly. Figure 8–3 Printing Between a Solaris Print Client and a lpd-based Print Server
The following figure shows a lpd-based print client submitting a print request to a Solaris print server. The lpd daemon handles the local part of the print request and the connection to the print server. On the print server, the inetd process waits for network printing requests and starts a protocol adaptor to service the request. The protocol adaptor communicates with the lpsched daemon, which processes the request on the print server. Figure 8–4 Printing Between a lpd-based Print Client and a Solaris Print Server
The following figure shows what happens when a user on a Solaris print client submits a print request to a Solaris print server. The print command on the print client handles the local part of each print request by communicating directly with the print server. The inetd process on the print server monitors network printing requests and starts a protocol adaptor to communicate with the lpsched daemon on the print server, which processes the print request. Figure 8–5 Printing Between a Solaris Print Client and a Solaris Print Server
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||