Getting apcupsd Working on CentOS, and Probably Elsewhere
In order to provide proper resilience for any server, it needs to react well in power outages. This means using a UPS (Universal Power Supply) and shutting down gracefully when all battery power has been exhausted, coming back up automatically when power is restored.
In order to do this we need an application that is able to communicate with the UPS, detect that there is a power outage and when the batteries have run down to a certain level, gracefully shut the system down. There is a piece of open source software called apcupsd that does this. Download the RPM for Enterprise Linux 5 from here.
Install via the normal rpm -ivh method. It’s also possible to get apcupsd through the DAG extended repository for CentOS and Red Hat, via RPMforge. As this is a one off package, we’ll just install it manually.
However, if you’re installing on a system that uses LVM, or you have a /usr partition that is separate from / then some further work will be needed. Make sure that your / partition is not on LVM. When you test shut down the machine you will notice that apcupsd does not power off the UPS correctly because it cannot find certain components – namely libnetsnmp.so.10, libz.so.1 and the wall executable. We can fix this by making copies to the /lib64 directory (if you run a 64-bit system):
cp /usr/lib64/libnetsnmp.so.10 /lib64
cp /usr/lib64/libz.so.1.2.3 /lib64
ln -s /lib64/libnetsnmp.so.10.0.1 /lib64/libnetsnmp.so.10
ln -s /lib64/libz.so.1.2.3 /lib64/libz.so.1
In addition, the wall executable cannot be found, as it resides in /usr/bin. If you do a check on the dependencies for wall you will see the following:
ldd /usr/bin/wall
libc.so.6 => /lib64/libc.so.6 (0×0000003092200000)
/lib64/ld-linux-x86-64.so.2 (0×0000555555554000)
This is fine, and shows the dependencies are there in the / directory. All we need to do is make a copy of wall to the root bin directory:
cp /usr/bin/wall /bin/span>
apcupsd will now have all the dependencies it needs when shutting down the machine, and when shutting down the UPS when all but the / partition has been unmounted.

0 Comments:
Post a Comment
<< Home