| 1 |
The ldirectord (Linux Director Daemon) is a stand-alone daemon to monitor |
| 2 |
services of real servers, currently http, https and ftp service. It is simple |
| 3 |
to install and can be started on its own or be started from the heartbeat |
| 4 |
daemon. It is very useful to manage real servers through ipvsadm. ipvsadm |
| 5 |
is part of the Linux Virtual Server (http://www.linuxvirtualserver.org/) |
| 6 |
Project and is used to redirect TCP- and UDP/IP traffic from a virtual |
| 7 |
server to many real servers. Thus LVS, heartbeat and ldirectord can be used |
| 8 |
to build up a redundant, fault-tolerant server farm of http-, https- and |
| 9 |
ftp-servers. Other types of services may be added in future or upon request. |
| 10 |
|
| 11 |
Installation and configuration guide: |
| 12 |
ldirectord is written in Perl, thus no compilation is neccessary. Two Perl- |
| 13 |
modules and one library must be installed so that ldirectord can monitor http- |
| 14 |
and https-servers. |
| 15 |
|
| 16 |
These are: |
| 17 |
libwww-perl from www.CPAN.org |
| 18 |
to check http service |
| 19 |
|
| 20 |
libnet-perl from www.CPAN.org |
| 21 |
to check ftp service |
| 22 |
|
| 23 |
Crypt-SSLeay from www.CPAN.org |
| 24 |
openssl from www.openssl.org |
| 25 |
to check https service |
| 26 |
|
| 27 |
If for any reason You don't need to check certain services, |
| 28 |
simply comment out the full function check_http, check_https |
| 29 |
or check_ftp in ldirectord. |
| 30 |
|
| 31 |
ldirectord is located in /etc/ha.d/resource.d/ldirectord |
| 32 |
If ldirectord often must be started manually it is useful to create a softlink. |
| 33 |
As root type 'ln -s /etc/ha.d/resource.d/ldirectord /usr/sbin/ldirectord' |
| 34 |
|
| 35 |
Create a file with any name and place it into /etc/ha.d/conf. This is a |
| 36 |
sample configuration to monitor two virtual servers with two real servers |
| 37 |
each: |
| 38 |
|
| 39 |
/etc/ha.d/conf/www |
| 40 |
------------------------------------------------- |
| 41 |
|
| 42 |
# config file for www.abc.com |
| 43 |
|
| 44 |
# the number of second until a real server is declared dead |
| 45 |
timeout = 30 |
| 46 |
|
| 47 |
# the number of second between server checks |
| 48 |
checkinterval = 10 |
| 49 |
|
| 50 |
# reload the configuration automatically after a file modification |
| 51 |
autoreload = yes |
| 52 |
|
| 53 |
# virtual = x.y.z.w:p |
| 54 |
# protocol = tcp|udp |
| 55 |
# scheduler = rr|wrr|lc|wlc |
| 56 |
# real = x.y.z.w:p gate|masq|ipip [weight] |
| 57 |
# ... |
| 58 |
# |
| 59 |
virtual = 204.202.136.32:80 |
| 60 |
real = 192.168.0.1:80 gate 5 |
| 61 |
real = 192.168.0.2:80 gate 10 |
| 62 |
service = http |
| 63 |
scheduler = wrr |
| 64 |
request = "/.testpage" |
| 65 |
receive = "test page" |
| 66 |
|
| 67 |
virtual = 204.202.136.33:443 |
| 68 |
real = 192.168.0.3:443 masq 1 |
| 69 |
real = 192.168.0.4:443 masq 1 |
| 70 |
service = https |
| 71 |
scheduler = wlc |
| 72 |
request = "/.testpage" |
| 73 |
receive = "test page" |
| 74 |
persistent = 1800 |
| 75 |
|
| 76 |
------------------------------------------------- |
| 77 |
|
| 78 |
You need to create the .testpage file at the DocumentRoot directory of |
| 79 |
each web server. |
| 80 |
|
| 81 |
echo "test page" > .testpage |
| 82 |
|
| 83 |
No You may test the configuration. Start the ldirectord as root with: |
| 84 |
ldirectord www start |
| 85 |
You may check if everything works fine. Type 'ipvsadm -l' and see |
| 86 |
if the network address translation shows the above configuration. |
| 87 |
Look at the logfile /var/log/ldirectord.log for details. |
| 88 |
|
| 89 |
If that works fine You may add the following entry to Your /etc/ha.d/haresources |
| 90 |
file: |
| 91 |
|
| 92 |
------------------------------------------------- |
| 93 |
node1 IPaddr::204.202.136.32 IPaddr::204.202.136.33 ldirectord::www |
| 94 |
------------------------------------------------- |
| 95 |
|
| 96 |
Restart heartbeat with |
| 97 |
/etc/rc.d/init.d/heartbeat restart |
| 98 |
and look if Your host takes the IP-addresses 204.202.136.32 and |
| 99 |
204.202.136.33 and if ipvsadm -l maps the virtual servers onto the real ones. |
| 100 |
|
| 101 |
Now install the files /etc/ha.d/conf/www and /etc/ha.d/haresources on Your second |
| 102 |
heartbeated host. Shutdown the first host and look if everything still works. |
| 103 |
|
| 104 |
----- Automatic reload and automatic transfer ----- |
| 105 |
This feature has been added since I often have to adopt my configuration files and |
| 106 |
I did not want to restart ldirectord and transfer the configuration files manually |
| 107 |
onto the second host. |
| 108 |
In order to automatically reload the configuration put the line |
| 109 |
------------------------------------------------- |
| 110 |
autoreload = yes |
| 111 |
------------------------------------------------- |
| 112 |
into the configuration file. After each checkinterval a checksum is built |
| 113 |
over the file, and if this changed ldirectord automatically reloads the |
| 114 |
configuration. |
| 115 |
|
| 116 |
To automatically transfer the configuration onto the second machine You |
| 117 |
must create a new user on both heartbeated hosts with their home directories |
| 118 |
located at /etc/ha.d/conf. Do this with |
| 119 |
|
| 120 |
useradd -u 123 -g daemon -c 'High Availability Daemon' -d /etc/ha.d/conf had |
| 121 |
chown -R had /etc/ha.d/conf |
| 122 |
|
| 123 |
The users 'had' must be able to remote copy files from one host to the other |
| 124 |
one without the need of a password. I prefer to use scp (secure copy) but You |
| 125 |
may also use rcp (remote copy) if You feel safe with that or if Your laws |
| 126 |
forbid to use ssh. |
| 127 |
If You use ssh put the name of the other host into the file /etc/shosts.equiv |
| 128 |
(/etc/hosts.equiv for rsh users), create keys with ssh-keygen on each host and |
| 129 |
exchange the public part of the keys by doing once a ssh connection from one host |
| 130 |
to the other and vice versa (rsh users can skip this step). Refer to the |
| 131 |
ssh or rsh manual pages for details. |
| 132 |
These lines must be set in the /etc/sshd_config files on both hosts: |
| 133 |
------------------------------------------------- |
| 134 |
RhostsRSAAuthentication yes |
| 135 |
RSAAuthentication yes |
| 136 |
------------------------------------------------- |
| 137 |
Now the user 'had' should be able to 'scp' any file into the directory |
| 138 |
/etc/ha.d/conf of the other host. Remember: For safty reasons the user root |
| 139 |
may not copy files without a password. If copying files onto the remote host |
| 140 |
works You may put the line: |
| 141 |
------------------------------------------------- |
| 142 |
callback = "/etc/ha.d/resource.d/putcfg" |
| 143 |
------------------------------------------------- |
| 144 |
into Your configuration file and create a shellscript named putcfg located |
| 145 |
in /etc/ha.d/resource.d. Remember to make the shellscript executable. |
| 146 |
/etc/ha.d/resource.d/putcfg: |
| 147 |
------------------------------------------------- |
| 148 |
#!/bin/sh |
| 149 |
chown had.daemon /etc/ha.d/conf/$1 |
| 150 |
su - had -c "scp -p -q /etc/ha.d/conf/$1 name-of-other-host:/etc/ha.d/conf" |
| 151 |
exit $? |
| 152 |
------------------------------------------------- |
| 153 |
|
| 154 |
Now You may safly modify You configuration files without having to manually update |
| 155 |
Your configurations by ftp or worry that they will not be up-to-date after a servercrash |
| 156 |
of the main loadbalancing host. |
| 157 |
|
| 158 |
There is more documentation about ldirectord. Just type ldirectord -h to read |
| 159 |
the online manual. |
| 160 |
|
| 161 |
For questions and suggestions refer to Jacob Rief <[email protected]> |
| 162 |
PGP-fingerprint: 2F 8E 63 FC 6C 35 64 4F 20 CA 68 F7 28 0A 18 2F |
| 163 |
|
| 164 |
|