Set Up A Simple High-Availability Web Server For A Small Company Using Debian Lenny - Page 2
4. Configure heartbeat And ldirectordWe have to create 3 configuration files for heartbeat. lb01/lb02 pico /etc/ha.d/ha.cf logfacility local0 Important: As node we must use the output of uname -n on lb01 and lb02. lb01/lb02 pico /etc/ha.d/haresources lb01 \ The first word is the output of uname -n on lb01, no matter if you create the file on lb01 or lb02! After IPaddr2 we put our virtual IP address 10.253.66.200. lb01/lb02 pico /etc/ha.d/authkeys auth 3 secretstring is a password which the two heartbeat daemons on lb01 and lb02 use to authenticate against each other. Use your own string here. /etc/ha.d/authkeys should be readable by root only, therefore we do this: lb01/lb02 chmod 600 /etc/ha.d/authkeys ldirectord is the actual load balancer. We are going to configure our two load balancers (lb01.example.com and lb02.example.com) in an active/passive setup, which means we have one active load balancer, and the other one is a secondary and becomes active if the active one [Master] fails. To make it work, we must create the ldirectord configuration file /etc/ha.d/ldirectord.cf which again must be identical on lb01 and lb02. lb01/lb02 pico /etc/ha.d/ldirectord.cf checktimeout=10 In the virtual= line type your virtual IP address (10.253.66.200 in this tutorial). lb01/lb02 update-rc.d heartbeat start 75 2 3 4 5 . stop 05 0 1 6 . update-rc.d -f ldirectord remove Finally we start heartbeat (and with it ldirectord): lb01/lb02 /etc/init.d/ldirectord stop /etc/init.d/heartbeat start
5. Test The Load BalancersLet's check if both load balancers work as expected: lb01/lb02: ip addr sh eth0 The active load balancer [Master] should list the virtual IP address (10.253.66.200): 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 00:0c:29:b7:56:9c brd ff:ff:ff:ff:ff:ff inet 10.253.66.19/24 brd 10.253.66.255 scope global eth0 inet 10.253.66.200/24 brd 10.253.66.255 scope global secondary eth0 The secndary one[Backup] should show this: 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 00:0c:29:b7:56:9c brd ff:ff:ff:ff:ff:ff inet 10.253.66.19/24 brd 10.253.66.255 scope global eth0 lb01/lb02: ldirectord ldirectord.cf status Output on the active load balancer [Master]: ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 3728 Output on the secondary [Backup]: ldirectord is stopped for /etc/ha.d/ldirectord.cf lb01/lb02: ipvsadm -L -n Output on the active load balancer [Master]: IP Virtual Server version 1.2.1 (size=4096) Output on the secondary [Backup]: IP Virtual Server version 1.2.1 (size=4096) lb01/lb02: /etc/ha.d/resource.d/LVSSyncDaemonSwap master status Output on the active load balancer [Master]: master running (ipvs_syncmaster pid: 3815) Output on the secondary [Backup]: master stopped To test your virtual ip: ping -c 4 10.253.66.200 PING 10.253.66.200 (10.253.66.200) 56(84) bytes of data. 64 bytes from 10.253.66.200: icmp_seq=1 ttl=64 time=1.94 ms 64 bytes from 10.253.66.200: icmp_seq=2 ttl=64 time=0.110 ms 64 bytes from 10.253.66.200: icmp_seq=3 ttl=64 time=0.049 ms 64 bytes from 10.253.66.200: icmp_seq=4 ttl=64 time=0.048 ms --- 10.253.66.200 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3007ms rtt min/avg/max/mdev = 0.048/0.539/1.949/0.814 ms If your tests went fine, you can now configure the two Apache nodes.
6. Installation Of Apache + PHP With MySQL SupportInstalling the packages:If you do not have PHP installed already, use this to install the necessary packages: lb01/lb02: aptitude install apache2 php5 libapache2-mod-php5 php5-sqlite This will install PHP, the Apache webserver and the necessary dependencies onto your system.
aptitude install php5-mysql Start (or restart) apache by issuing one of these commands: /etc/init.d/apache2 start or /etc/init.d/apache2 restart
7. Testing the installation:Check that your Apache installation is working. Point a browser to http://10.253.66.200/. E.g. lynx http://10.253.66.200/ You should see a page displaying the words "It works!".
NoteTest your PHP installation by creating a phpinfo.php file in your Apache document root, e.g. by issuing the following command: echo '<?php phpinfo(); ?>' > /var/www/phpinfo.php Then fire up your browser and go to: lynx http://10.253.66.200/phpinfo.php You should see a phpinfo page with the correct version number (PHP) at the top. DONE!
|



Recent comments
15 hours 3 min ago
16 hours 39 min ago
20 hours 59 min ago
1 day 50 min ago
1 day 12 hours ago
1 day 18 hours ago
1 day 21 hours ago
1 day 22 hours ago
1 day 23 hours ago
1 day 23 hours ago