SUBSCRIBE To Our Mail List To Get This Article In PDF
An inexpensive way to prevent unscheduled downtime or data loss due to power problems is with a UPS or Uninterruptible Power Supply. However, a UPS by itself is not enough for proper operation. Hardware, software, and configuration together make up a UPS system that will recover from unexpected power loss or power fluctuations that can damage systems and peripherals.
Introduction
When considering data loss, system downtime and disaster recovery, backup methods are primarily discussed. There are many methods of preventing data loss, including clustering, backup, security and power conditioning. Proper power can prevent an initial disaster from ever occurring. Providing proper power can be in the form of an Uninterruptible Power Supply or UPS. A UPS has rechargeable batteries to supply emergency power in the event of immediate power loss. If the power loss is longer than the batteries can supply, then the UPS can signal the server to initiate a power down sequence to properly shutdown, preventing data loss. When power is returned the server can return to operation after having made a clean shutdown.
Other power related problems that occur can be minimized with the circuitry of a UPS. Voltage sags and spikes, brown outs and line noise (from other machinery like elevators, air conditioners or office equipment), can all be isolated by a UPS. These power related fluctuations can wreak havoc on systems and devices. For a relatively low cost a UPS can prevent downtime due to power anomalies.
Network UPS Tools
The Network UPS Tools (NUT) are a group of tools that are used to monitor and administer UPS hardware. NUT uses a layered scheme of equipment, drivers, server and clients. The equipment consists of the monitored UPS hardware. Drivers specific to the UPS hardware communicate or poll the UPS for status information in the form of variables. The driver programs talk directly to the UPS equipment and run on the same host as the server. The server upsdserves data from the drivers to the network. Clients talk to the upsdserver and initiate tasks with the status data.
As indicated by the name, Network UPS Tools, NUT is a network based UPS system that works with multiple UPSs and systems. One of the many features of NUT allows multiple systems to monitor a single UPS, not requiring special UPS sharing hardware connections. The master/slave relationship synchronizes shut-downs so the slaves can initiate power-down sequences before the master switches off UPS power.
This article details the installation and configuration of a single system with a UPS connected to the serial port of the system. This is the natural first step of getting NUT installed and configured. If the UPS will supply more than one system, the second and subsequent systems can be configured as slaves.
The NUT developers also have a different take on when the systems should be powered down. NUT will wait until the UPS is “on battery” and “low battery” before it considers the UPS “critical”. This philosophy gets the most out of the UPS batteries and will wait until the critical moment to initiate a power down sequence, just in case the power comes back on line. There is an option to override this behavior if desired with upssched, which can be found in the documentation. With the upssched utility, commands can be invoked based on UPS events.
In typical GNU/Linux fashion, NUT is not the only tool available for monitoring a UPS. Apcupsd is used for power management and control of APC model UPSs. There are also several graphical frontends for workstation class machines.
Preparing for installation
Prior to installing and using a UPS and its associated software, a few things must be in place. Since the system is going to be shutdown there must be a way to bring the system back up when power returns. The system BIOS needs to be configured correctly. Most modern BIOSes have an option to power-on when main power, now supplied by the UPS, is returned. Server system BIOSes will most likely support the “power on when power returns” option. If the BIOS does not support this option (more common with workstation class systems), a BIOS update may correct it. With servers configured headless, without a monitor or keyboard, there are also settings to ignore keyboard errors. Commonly these types of systems are administered via SSH or administration utilities like Webmin.
The UPS must also have the correct signal cable from the UPS to the system. With a USB type of UPS this is not a concern. A UPS that communicates via the serial port needs the correct signal cable that supports intelligent signaling between the UPS and system. See the UPS vendor for the correct cable or a custom cable can be built with information from the Network UPS Tools web site.
Installing NUT
The example system is running a basic install of Debian GNU/Linux V4.0 and utilizing an APC SmartUPS 700. Debian is an excellent, long term supported GNU/Linux, which is ideal for small enterprise deployments, as well as much larger environments. Different GNU/Linux distributions may install the software and configuration files in different directories. Since the server is configured without a GUI interface, all commands and configuration are done through the command line as the root user. Using the APT package tool, apt-get, the package nut can easily be installed:
# apt-get install nut
The package tool installs the NUT software, documentation, man pages and example configuration files. Debian specific documentation is found in the /usr/share/doc/nut/ directory.
Extensive NUT documentation can be found in/usr/share/doc/nut/docs/ and the example configuration files in /usr/share/doc/nut/examples/. Some of the documentation is compressed with gzip which can be uncompressed or viewed with the zcat utility.
# zcat /usr/share/doc/nut/README.Debian.gz | less
The configuration files exist in the /etc/nut/ directory.
Theups.conf configuration file contains the UPS definitions.
The UPS is defined with the [labsvr] entry.
The driver and port fields must be defined, the desc field is optional and describes the UPS. Additional UPS definitions can be configured in this file; however, this example is a single UPS and server configuration.
[labsvr]
driver = apcsmart
port = /dev/ttyS0
desc = "Lab Server"
The definition, between the square brackets, is user definable, with the exception of word
default
, since it is used by the Network UPS Tools. The correct driver name for your UPS can be found in the file/usr/share/nut/driver.list
. For proper permissions to use the serial port the nut
user must be added to the “dialout” group, and can be accomplished with the addgroup
command. To manually test the configuration and to verify the configuration is correct theupsdrvctl
(UPS driver controller) command is used. After verification the driver can be stopped.
# addgroup nut dialout
Adding user `nut' to group `dialout' ...
Done.
# /sbin/upsdrvctl start labsvr
Network UPS Tools - UPS driver controller 2.0.4
Network UPS Tools (version 2.0.4) - APC Smart protocol driver
Driver version 1.99.8, command table version 2.0
Detected SMART-UPS 700 [QS0331213446] on /dev/ttyS0
# /sbin/upsdrvctl stop labsvr
Network UPS Tools - UPS driver controller 2.0.4
Stopping UPS: labsvr
#
Since this example is a single server, the access control list for server communication is minimal. Configuring the access control lists is accomplished in the configuration file
upsd.conf
. The ACL (access control list) all
is defined with the netblock in CIDR format, the old style address/network
format can also be used. Additionally the ACL localhost
is defined. The ACCEPT
field allows communication to the server for localhost
and the REJECT
field blocks all other access. Similar to other access control lists, flow goes from the top down. The ACCEPT
is evaluated before theREJECT
, if the REJECT
line were before ACCEPT
, localhost
would meet the rule and not be allowed access.
ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32
ACCEPT localhost
REJECT all
The
upsd.users
configuration file is used to define users that have access to administrative commands. Here are defined the users and what access each user is allowed; each section begins with user names in brackets and continues to the next bracketed user or end of the file. The password
field defines the user’s password. Theallowfrom
field grants access based on the user’s source IP address, the values are defined in the ACL lists configuration fileupsd.conf
. The upsmon
field is set to either master
or slave
to allow the upsmon process to work.
[monmaster]
password = p455w0rd
allowfrom = localhost
upsmon = master
SUBSCRIBE To Our Mail List To Get This Article In PDF