unix大杂烩--基础型二( 七 )



在 SCO Unix 网络中设置共享打印机当前随着网络的日益普及 , 计算机系统通过网络实现设备共享和资源共享已十分普遍 。在一个公共的网络环境中 , 设置一台共享打印机不仅可以大大提高设备的利用率和网络效率 , 降低最少拥有成本 , 还省去了操作人员长期习惯于每打印一份作业便抱一台打印机连到自己电脑上的麻烦 。DOS 、 Windows 、 NetWare 系统下共享打印机设置比较简单 , 无需多言 。SCO Unix 作为金融系统和其他大行业首选的操作系统 , 近年来组网非常广泛 , 应用也非常普及 , 但设置共享打印机比较麻烦 , 这方面的文章也不多见 。笔者经过多次试验 , 终获成功 , 示于大家仅供参考 。
一、工作原理共享打印机是按一定拓扑结构连接到网络上的打印机 , 通过网络协议 (TCP/IP 、 NetBEUI 、 IPX/SPX 等 ) 而被网络用户所共享 。其连接主要有以下三种方式 :1. 打印机本身带网卡 ( 又称网络打印机 ), 直接连到网络中供用户共享 。2. 打印机连接到专用的打印服务器上 , 并通过其网络接口连到网络中供用户共享。3. 使用网络上的一台 PC 或服务器兼做打印服务器 , 连上打印机供用户共享。比较而言 , 前两种方式需购置专用设备 , 同时 Unix 下还需设置 Bootp 或 Rarp 服务 , 以自动提供 IP 地址 。而第三种方式无需购置专用设备 , 且不影响计算机的正常使用 , 经济实用 , 简单方便 , 大大节约运行成本 , 也是下面所要介绍的 。二、实现过程以网络中有两台主机 A 、 B 为例, 操作系统为 SCO Openserver 3.0 或 5.0, 打印机连到兼做打印服务器的一台主机上 , 供两台主机所支持的客户端共享 。设主机 A 名为 hosta,IP 地址为 168.1.8.1; 主机 B 名为 hostb,IP 地址为 168.1.8.2;打印机名为 printer。调整 Unix 核心系统参数 Nregion: A 机不低于 800,B 机不低于 1000, 并连接核心重新引导系统 。1. B 机端设置以 root 用户进行注册 :(1) 定义主机名 。修改文件 /etc/hosts 使之包含以下行 :168.1.8.1 hosta168.1.8.2 hostb(2) 定义打印服务授权 。修改文件 /etc/hosts.lpd 使之包含以下行 :hosta(3) 建立本地打印机 printer ( 如已存在先删除 ), 设为缺省并激活 :#mkder lp选 Configure- Add其中Printer name: printerConnection: DirectDevice name: /dev/lp0#/usr/lib/lpadmin -d printer#enable printer(4) 建立网络方式下的本地打印机 , 名称同上为 printer。当询问是本地 (local) 还是远 程 (remote) 时 , 选择本地 。#mkdev rlp 提示如下 :Remote printing configurationDo you want to installor remove remote printing_ (i/r/q)? : iInstalling Remote Line PrintingCreating directories /usr/lpd/remote and /usr/spool_/lpd and file /etc/printcap.Saving lp, cancel and lpstat commands to /usr/lpd_/remoteInstalling remote lp, cancel and lpstat commandsDo you wish to change the printer description file_/etc/printcap? (y/n) yRemote Printing ConfigurationEnter information for remote printers orlocal printers_ acceptingremote printing requestsPlease enter the printer name (q to quit): printerIs printer a remote printer or a local printer (r/l)? lPlease enter the the name of the device for printer_: /dev/lp0Printer printer uses device /dev/lp0Is this correct? (y/n) yRemote Printing ConfigurationEnter information for remote printers or local printers_ acceptingremote printing requestsPlease enter the printer name (q to quit): qDo you want to start remote daemon now? (y/n) y2. A 机端设置以 root 用户进行注册 :(1) 定义主机名 。修改文件 /etc/hosts, 使包含以下行 :168.1.8.1 hosta168.1.8.2 hostb(2) 建立网络方式下的远程打印机 , 远程主机名输 hostb, 远程打印机名输 printer, 询 问本地 (local) 还是远程 (remote) 时 , 选择远程 。#mkdev rlpRemote printing configurationDo you want to install or removeremote printing_ (i/r/q)? : iInstalling Remote Line PrintingCreating directories /usr/lpd/remote and /usr/spool_/lpd and file /etc/printcap.S aving lp, cancel and lpstat commands to /usr/lpd_/remoteInstalling remote lp, cancel and lpstat commandsDo you wish to change the printer description file_/etc/printcap? (y/n) yRemote Printing ConfigurationEnter information for remote printersor local printers_ acceptingremote printing requestsPlease enter the printer name (q to quit): printerIs printer a remote printer or a local printer (r/l)? rPlease enter the the name of the remotehost that_ printer is attached to: hostbPrinter printer is connected to host hostbIs this correct? (y/n) yWould you like this to be the systemdefault printer? (y/n) ymake sure your host name appears in hostb"s /etc_/hosts.equivor /etc/hosts.lpd fileMake sure that printer appears in hostb"s /etc_/printcap file (BSD format)Make sure that printer has a spool directory on_ hostbPlease hit to continueRemote Printing ConfigurationEnter information for remote printers orlocal printers_ acceptingremote printing requestsPlease enter the printer name (q to quit): qDo you want to start remote daemon now? (y/n) y(3) 测试 。在 hosta 或 hostb 上以普通用户注册 , 输以下命令即可实现打印共享 。$ lp /etc/default/lpd3. 日常维护(1) 管理员或普通用户通过使用命令 lpstat 或 rlpstat 查看打印机状态 , 并使用命令 lp 进行日常打印 。(2) 设置远程打印机时将自动安装新的 lpstat 、 cancel 、 lppstat 命令 , 原命令存放在 /usr/lpd/remote 目录下(3) 每次增加打印机前 , 最好删除原有的打印机 。

推荐阅读