当前随着网络的日益普及 , 计算机系统通过网络实现设备共享和资源共享已十分普遍。在一个公共的网络环境中 , 设置一台共享打印机不仅可以大大提高设备的利用率和网络效率 , 降低最少拥有成本 , 还省去了操作人员长期习惯于每打印一份作业便抱一台打印机连到自己电脑上的麻烦。 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 hosta
168.1.8.2 hostb
(2) 定义打印服务授权。修改文件 /etc/hosts.lpd 使之包含以下行 :
hosta
(3) 建立本地打印机 printer ( 如已存在先删除 ), 设为缺省并激活 :
#mkder lp
选 Configure- Add
其中
Printer name: printer
Connection: Direct
Device name: /dev/lp0
#/usr/lib/lpadmin -d printer
#enable printer
(4) 建立网络方式下的本地打印机 , 名称同上为 printer 。当询问是本地 (local) 还是远 程 (remote) 时 , 选择本地。
#mkdev rlp 提示如下 :
Remote printing configuration
Do you want to install
or remove remote printing_ (i/r/q)? : i
Installing Remote Line Printing
Creating directories /usr/lpd/remote and /usr/spool_
/lpd and file /etc/printcap.
Saving lp, cancel and lpstat commands to /usr/lpd_
/remote
Installing remote lp, cancel and lpstat commands
Do you wish to change the printer description file_
/etc/printcap? (y/n) y
Remote Printing Configuration
Enter information for remote printers or
local printers_ acceptingremote printing requests
Please enter the printer name (q to quit): printer
Is printer a remote printer or a local printer (r/l)? l
Please enter the the name of the device for printer_
: /dev/lp0
Printer printer uses device /dev/lp0
Is this correct? (y/n) y
Remote Printing Configuration
Enter information for remote printers or l
ocal printers_ accepting
remote printing requests
Please enter the printer name (q to quit): q
Do you want to start remote daemon now? (y/n) y
2. A 机端设置
以 root 用户进行注册 :
(1) 定义主机名。修改文件 /etc/hosts, 使包含以下行 :
168.1.8.1 hosta
168.1.8.2 hostb
(2) 建立网络方式下的远程打印机 , 远程主机名输 hostb, 远程打印机名输 printer, 询 问本地 (local) 还是远程 (remote) 时 , 选择远程。
#mkdev rlp
Remote printing configuration
Do you want to install or remove
remote printing_ (i/r/q)? : i
Installing Remote Line Printing
Creating directories /usr/lpd/remote and /usr/spool_
/lpd and file /etc/printcap.
S aving lp, cancel and lpstat commands to /usr/lpd_
/remote
Installing remote lp, cancel and lpstat commands
Do you wish to change the printer description file_
/etc/printcap? (y/n) y
Remote Printing Configuration
Enter information for remote printers
or local printers_ accepting
remote printing requests
Please enter the printer name (q to quit): printer
Is printer a remote printer or a local printer (r/l)? r
Please enter the the name of the remote
host that_ printer is attached to: hostb
Printer printer is connected to host hostb
Is this correct? (y/n) y
Would you like this to be the system
default printer? (y/n) y
make sure your host name appears in hostb's /etc_
/hosts.equiv
or /etc/hosts.lpd file
Make sure that printer appears in hostb's /etc_
/printcap file (BSD format)
Make sure that printer has a spool directory on_ hostb
Please hit to continue
Remote Printing Configuration
Enter information for remote printers or
local printers_ accepting
remote printing requests
Please enter the printer name (q to quit): q
Do you want to start remote daemon now? (y/n) y
(3) 测试。在 hosta 或 hostb 上以普通用户注册 , 输以下命令即可实现打印共享。
$ lp /etc/default/lpd
3. 日常维护
(1) 管理员或普通用户通过使用命令 lpstat 或 rlpstat 查看打印机状态 , 并使用命令 lp 进行日常打印。
(2) 设置远程打印机时将自动安装新的 lpstat 、 cancel 、 lppstat 命令 , 原命令存放在 /usr/lpd/remote 目录下
(3) 每次增加打印机前 , 最好删除原有的打印机。
【发表回复】【查看CU论坛原帖】【添加到收藏夹】【关闭】
秋意正浓 回复于:2004-01-02 20:29:46 |
不错嘛,收藏,说不定哪天就用上了。 |
studyingunix 回复于:2004-01-02 20:32:27 |
不错.挺实用.有机会要试试. |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/