NEXItaliano

NEX › Documentation › Printing and scanning on the cluster — the office printers and scanners for every node

Printing and scanning on the cluster — the office printers and scanners for every node

By Roberto Arato of aratoingegneria.it

The administrator adds a printer once, and every node of the cluster prints on it: from the terminal (lp, lpr), from the print dialog of GNOME and KDE, and from a program started on another node with nex run -X. Nobody configures printers node by node.

Behind this there is CUPS, the printing system of Linux, on two or three compute nodes, all with the same printers, and a virtual address, print.nex: if the node serving it shuts down, the address moves to another print server by itself. The PCs of the office find the printers of the cluster on the network too.

The normal case is driverless printers: those that speak IPP Everywhere or AirPrint, which means almost every network printer and multifunction made in recent years. An older printer that needs a driver is added together with its driver (see A printer that needs a driver).

Contents

  1. Turning printing on
  2. Adding a printer
  3. Printing
  4. Who may print
  5. The PCs of the office
  6. When a print server stops
  7. Commands
  8. How it works
  9. Scanners

1. Turning printing on

On two or three compute nodes that will serve printing (more than one, so that printing goes on if one of them stops):

sudo nex apt install cups --nodes node-a,node-b

Then, on the first of them, give a free address of the node network for print.nex (only the first time):

sudo nexctl print enable --ip 10.20.0.60/24

and on the others:

sudo nexctl print enable

Within a minute every node of the cluster prints through print.nex.

2. Adding a printer

Every printer needs a short name (lowercase letters, digits, - and _) and its address. A network printer usually has the address ipp://ADDRESS/ipp/print:

sudo nexctl print add office --uri ipp://192.168.1.50/ipp/print \
     --info "Office laser" --location "Corridor, first floor"
sudo nexctl print list

The printer must be on when it is added: the cluster asks it what it can do (paper sizes, colour, two-sided printing) and prepares the queue from that. Every print server prepares the same queue within a minute.

sudo nexctl print remove office

removes it from the whole cluster.

A USB printer

A printer connected with a USB cable to a node is added from that node. Almost every printer of recent years speaks IPP over the cable too (IPP over USB): the ipp-usb package shows it as a network printer, and from there the cluster uses it like the others.

sudo apt install ipp-usb                  # on the node of the printer
# plug the printer in and switch it on, then:
sudo nexctl print add laser --usb --info "USB laser" --location "Design office"

With several USB printers on the same node, nexctl lists their ports and one is chosen with --port. A USB printer works as long as its node is on: it is attached to it.

A printer that needs a driver

An older printer that does not speak IPP Everywhere (for example a laser that takes its jobs on port 9100) is added with its driver. There are two ways.

With an installed driver. Install the driver package on every print server, look up the name of the driver with lpinfo -m (it is the first column) and pass it with --driver. For example, for an HP laser:

nex apt install printer-driver-hpcups          # on every node of the cluster
lpinfo -m | grep -i laserjet_4250              # the name of the driver
sudo nexctl print add old-laser --uri socket://192.168.1.60:9100 \
     --driver drv:///hpcups.drv/hp-laserjet_4250.ppd --info "LaserJet 4250"

If a print server does not have the driver, that printer is not set up on it, and nexctl users apply (which runs by itself every minute) says so in its warnings. This is why the driver goes on every print server.

With the PPD file of the maker. Some makers provide a .ppd file for Linux:

sudo nexctl print add plotter --uri socket://192.168.1.70:9100 --ppd /path/to/plotter.ppd

The file is copied into the cluster filesystem (/nex/.nex/print), so every print server reads it. If the PPD asks for filters of the maker, those go on every server too.

With a driver the address can also be socket:// (port 9100) or lpd://, the ways of older printers.

3. Printing

Nothing to set up: on every node the printers of the cluster are already there.

lpstat -p                       # the printers and their state
lp -d office report.pdf         # print a file
lp -d office -n 2 report.pdf    # two copies
lpstat -o                       # my jobs in the queue
cancel office-12                # cancel a job

In the programs (LibreOffice, a PDF viewer, the browser) the printers of the cluster appear in the usual print dialog.

4. Who may print

At first everyone may print on every printer. To keep a printer for a group of the cluster, or for some users:

sudo nexctl print allow plotter --users @design
sudo nexctl print allow plotter --users anna,@design
sudo nexctl print allow plotter --users all

Someone outside the list gets "Not allowed to print".

5. The PCs of the office

The server that holds print.nex announces the printers on the office network, so Windows PCs, Macs and phones find them by themselves, with the name and location given with --info and --location. Only one server announces, so every printer appears once.

On a Windows PC a printer can also be added by address: http://10.20.0.60:631/printers/office (the address of print.nex).

To stop the announcement:

sudo nexctl print announce off

6. When a print server stops

If the server holding print.nex stops, the address moves to another print server within seconds, and printing goes on. Two things to know:

  • a print sent in the moment of the move may be refused: send it again;
  • a job already accepted by the server that stopped, but not yet printed, stays on that server and prints when it comes back.

7. Commands

Command What it does
nexctl print enable [--ip IP/PREFIX] this node serves printing; --ip the first time
nexctl print disable [--cluster] this node no longer serves; --cluster turns printing off for the whole cluster
nexctl print add NAME --uri URI [--info TEXT] [--location TEXT] [--users ...] a printer for the whole cluster
nexctl print add NAME --usb [--port N] [...] a USB printer of this node, for the whole cluster
nexctl print add NAME --uri URI --driver MODEL\|--ppd FILE [...] a printer that needs a driver
nexctl print remove NAME removes it
nexctl print allow NAME --users all\|USER,@GROUP,... who may print
nexctl print announce on\|off announcement on the office network
nexctl print list the printers
nexctl print status printing of the cluster and of this node

All but list and status need root. See also man nexctl.

8. How it works

  • The printers are kept in the control store of the cluster, and every print server creates the same queues from it every minute: there is no "main" server.
  • Every node finds the printers through /etc/cups/client.conf (ServerName print.nex), written by NEX.
  • The print jobs are prepared on the print server and sent to the printer with IPP; the spool stays on the disk of the server.
  • The state of the printers and the jobs waiting are shown in the dashboard, Devices page (see dashboard.md). Who has jobs waiting is visible from every node, the document title is not.

9. Scanners

Scanning has no queue: the program (Simple Scan, XSane, scanimage) runs on your node and talks to the scanner while you look at the preview. So there is no scan server: NEX tells every node where the scanners are, and every node uses them directly. Install the scanning software on the nodes where people scan:

sudo nex apt install sane-utils sane-airscan simple-scan

A network scanner or multifunction (eSCL, also called AirScan, or WSD):

sudo nexctl scan add office --uri http://192.168.1.50/eSCL --info "Office scanner"
sudo nexctl scan add old-mfp --uri http://192.168.1.51:5358/WSDScanner --wsd

The eSCL address is usually http://ADDRESS/eSCL; the manual of the scanner, or airscan-discover on a node in the same network, tells it.

A USB multifunction with IPP over USB (most recent ones), from the node where it is plugged in, as for a USB printer:

sudo apt install ipp-usb
sudo nexctl scan add office-usb --usb --info "USB multifunction"

The same device can be both a printer (nexctl print add ... --usb) and a scanner.

Older USB scanners that work only with a SANE driver: on the node where the scanner is plugged in

sudo apt install sane-utils
sudo nexctl scan share

and within a minute every node sees it as net:NODE.nex:.... Only the nodes of the cluster can reach it. sudo nexctl scan unshare stops sharing.

scanimage -L                        # the scanners this node sees
nexctl scan list                    # the scanners of the cluster
sudo nexctl scan remove office

The scanners also appear in the dashboard, Devices page.