This article demonstrates the use of Wake-on-LAN feature available on most commodity computer machines, and simulates a cluster to run 24x7 through daisy chain method. This allows both High Availability and High Performance, alongside providing Big Data storage and processing.
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Â
Redefining High Availability on Linux Systems with Wake-on-LAN
1. Redefining High Availability on Linux Systems with Wake-on-LAN
Goals
- To extend life of our commodity machines
- Consuming lesser power
- Reduce chances for errors
Today there several HA (High Availability) solutions that ensure fault tolerant services running 24x7
without any interruption to the end user. Several IT companies provide readymade solutions and
there are several available through open source too.
This article presents a simple setup of two Linux machines running RHEL 6.2, that with the help of
CRON and Wake-on-LAN technology, can provide 100% system uptime. The logic here is simple, just
like many other production jobs, one wakes up, and lets the other one sleep after handing over all
updated operations.
In production workloads, services are rendered for long durations before a failover takes place. Here
our node would render services considering the fact that a hardware component, OS, and application
does not crash. This design is made to prolong the life of our commodity hardware like desktops or
laptops, so that they continue to run at scheduled times with the help of Wake-on-LAN technology.
We also make use of CRON scheduling to accomplish this.
Setting up is a fairly simple task. Given below are the tasks needed to be performed.
Step 1 – Install RHEL 6.2 on both the machine, named Node1 and Node2 here
Machine 1 Configuration
Hostname node1.virtorg.net
IP Address 192.168.1.101
MAC Address 44:87:FC:7F:6D:75
Subnet mask 255.255.255.0
Gateway 192.168.1.1
Machine 2 Configuration
Hostname node2.virtorg.net
IP Address 192.168.1.102
MAC Address 44:87:FC:7E:91:DD
Subnet mask 255.255.255.0
Gateway 192.168.1.1
2. Step 2 – Enable Wake-on-LAN service on both the nodes
Most of desktop and laptop grade machines come with Wake-on-LAN technology these days, also
referred to as WOL in short. The benefit Wake-on-LAN or WOL gives us is powering up and down
machines with a magic packet sent over the ethernet LAN. Some Wi-Fi adapters also allow a variation
called Wake-on-Wireless-LAN. Let us get the WOL configured on both the nodes and test powering up
each other thereafter.
[root@node1 ~]# cd /etc/init.d
[root@node1 init.d]# vi wol
#!/bin/bash
#
# wol Wake-on-LAN configuration script
#
# chkconfig: - 99 01
# description: Wake-on-LAN allows a machine to be started using a WoL network packet.
# This script configured WoL on interfaces listed in $NIC.
# processname: -
# config: -
# pidfile: -
# Source function library.
. /etc/rc.d/init.d/functions
# List of NICs to configure for WoL.
# Note: on Xen hosts, use peth0 instead of eth0.
NIC=.eth0.
if [ "$1" != "start" ]; then
exit 0
fi
echo -n .Enabling Wake-on-LAN for:.
for nic in ${NIC};
do
echo -n . ${nic}.
[ -x /sbin/ethtool ] && /sbin/ethtool -s ${nic} wol g >/dev/null 2>&1
done
# Note: no error checking . ethtool does not return a useful exit code
success
echo
# EOF
[root@node1 ~]# chkconfig wol on
[root@node1 ~]# chkconfig --add wol
[root@node1 ~]# service wol start
3. Repeat the above procedure for node2 also. Once Wake-on-LAN has been set up on both our nodes,
we can manually test the command "ether-wake" to wake up one node from shutdown state to a
running state as given below. The command here will power up the machine having the given MAC
address.
[root@node1 ~]# /sbin/ether-wake -i eth0 44:87:fc:7e:91:dd
Step 3 – Here is how CRON is configured on both the nodes
Node 1
======
[root@node1 ~]# crontab -l
15 * * * * /sbin/ether-wake -i eth0 44:87:fc:7e:91:dd
20 * * * * /sbin/poweroff
45 * * * * /sbin/ether-wake -i eth0 44:87:fc:7e:91:dd
50 * * * * /sbin/poweroff
Node 2
======
[root@node2 ~]# crontab -l
30 * * * * /sbin/ether-wake -i eth0 44:87:fc:7f:6d:75
35 * * * * /sbin/poweroff
00 * * * * /sbin/ether-wake -i eth0 44:87:fc:7f:6d:75
05 * * * * /sbin/poweroff
With the above configuration, at every 15th and 45th minute, node1 powers on node2, and shuts
down after 5 minutes. Likewise node2 powers up node1 at 30th and 00th minute and powers itself off
after 5 minutes. This cycle continues every hour, and chronologically at 00th minute, node1 is up, at
15th minute, node2 is up, at 30th minute, again node1 is up, and at 45 minute, node2 is up, thereby
repowering up node1 at 00th minute.
Why such a design ? What are the advantages ?
This type of design can be used in many kinds of services. Some examples are highly available Web
server, HADOOP clusters, MySQL database server with replication and so forth. Tutorials on setting up
an HA cluster using Heartbeat are available separately. For now, this is the first step to extend our
commodity infrastructure's life.
Written on 3rd Dec, 2013
Author : Manish Chopra