<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technical Diary &#187; apache</title>
	<atom:link href="http://andriigrytsenko.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:02:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HA cluster for production utilization</title>
		<link>http://andriigrytsenko.net/2009/07/ha-cluster-for-production-utilization/</link>
		<comments>http://andriigrytsenko.net/2009/07/ha-cluster-for-production-utilization/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 14:41:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[clusters]]></category>
		<category><![CDATA[ha cluster]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=171</guid>
		<description><![CDATA[It&#8217;s more difficult and reliability solution in comparison with my previous one. And it&#8217;s suits for production.

From wikipedia we know that:
High-availability clusters (also known as HA Clusters or Failover Clusters) are computer clusters that are implemented primarily for the purpose of providing high availability of services which the cluster provides. They operate by having redundant [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s more difficult and reliability solution in comparison with my previous one. And it&#8217;s suits for production.</p>
<p><span id="more-171"></span></p>
<p>From wikipedia we know that:<br />
<em>High-availability clusters (also known as HA Clusters or Failover Clusters) are computer clusters that are implemented primarily for the purpose of providing high availability of services which the cluster provides. They operate by having redundant computers or nodes which are then used to provide service when system components fail. Normally, if a server with a particular application crashes, the application will be unavailable until someone fixes the crashed server.  </em></p>
<p>We try to make cluster for production system which provide web services and consisted of 2 nodes. Let&#8217;s call it srv1 and srv2 as hostnames.</p>
<p>There is ifconfig for srv1 :</p>
<pre>eth0      Link encap:Ethernet  HWaddr 08:00:27:7B:7E:40
          inet addr:10.0.30.1  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::a00:27ff:fe7b:7e03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:347 errors:1 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:86003 (83.9 KiB)  TX bytes:8214 (8.0 KiB)
          Interrupt:11 Base address:0xc020</pre>
<pre>
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)</pre>
<p>and for srv2:</p>
<pre>eth0      Link encap:Ethernet  HWaddr 08:00:27:7B:7E:03
          inet addr:10.0.30.2  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::a00:27ff:fe7b:7e03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:347 errors:1 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:86003 (83.9 KiB)  TX bytes:8214 (8.0 KiB)
          Interrupt:11 Base address:0xc020</pre>
<pre>
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)</pre>
<p>As you can see there is no virtual interfaces for now. Let&#8217;s look at hosts file it should be the same for both of nodes: </p>
<pre>cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               srv2 localhost.localdomain localhost
10.0.30.1       srv1
10.0.30.2       srv2</pre>
<p>Ok now we have to installed heartbeat.<br />
The centos, fedora core and RH users able to use this command:</p>
<pre>yum install heartbeat </pre>
<p>For debian users this one :</p>
<pre>apt-get install heartbeat</pre>
<p>For other distros you can do it according to your distros package manager documentation or compile from sources. The sources are always available at <a href="http://linux-ha.org/DownloadSoftware">official site</a> of the project.</p>
<p>Copy configuration files from examples into your work directory(default for heartbeat is /etc/ha.d): </p>
<pre>cp /usr/share/doc/heartbeat*/hareshare /etc/ha.d/
cp /usr/share/doc/ha.cf /hareshare /etc/ha.d/
cp /usr/share/doc/heartbeat*/authkeys /etc/ha.d/</pre>
<p>And edit it like this :</p>
<pre>cat /etc/ha.d/ha.cf
debugfile /var/log/ha-debug</pre>
<p> # set debug log</p>
<pre>logfile /var/log/ha-log</pre>
<p> # set common log </p>
<pre>logfacility     local0 </pre>
<p># set syslog channel </p>
<pre>keepalive 2 </pre>
<p># time between checks</p>
<pre>udpport 694 </pre>
<p># port where heartbeat will be listened on</p>
<pre>bcast   eth0</pre>
<p>   # interface for broadcast message</p>
<pre>auto_failback on </pre>
<p>#listing of node. Keep in mind that names of node should be as `uname -n` for each nodes</p>
<pre>node srv1 </pre>
<pre>node srv2</pre>
<p>All configuration files is pretty documented by developing team. Therefore I will not  describe it&#8217;s so deeply. Next config file is haresources:</p>
<pre>cat /etc/ha.d/haresources
active            10.0.30.3 httpd script1 script2</pre>
<p>this consist of three main fields:<br />
1-st  &#8211; It&#8217;s still not clear for me. (As I understand any name can be used here as well).<br />
2-nd  &#8211; the ip address for virtual interface<br />
3-rd  &#8211; the name of scripts or script located at /etc/init.d which should be brought up in case of crash active node. </p>
<p>Unfortunately in the event of crashing one of the defined services heartbeat doesn&#8217;t migrate cluster group to another node:( In other words if your web site is goes down the current node will stay active. Maybe this feature is available, but I have found nothing in official documentation about this issue. </p>
<p>And last one config file. It has quite simple configuration which consist of 2 lines. And uses for determine which encryption has to be used. </p>
<pre>cat /etc/ha.d/authkeys
auth 1
1 sha1 "HI!"
</pre>
<p>&#8220;sha1&#8243; provide connection with encryption as well as the &#8220;md5&#8243;. To switch off encryption set &#8220;crc&#8221; instead of &#8220;sha1&#8243;. </p>
<p>Now try to start it: </p>
<pre>/etc/init.d/heartbeat start </pre>
<p>If it&#8217;s start without any errors you able run it at second node. Copy your edited config files:</p>
<pre>scp /etc/hosts 10.0.30.2:/etc/
scp /etc/ha.d/ha* 10.0.30.2:/etc/ha.d/
scp /etc/ha.d/authkeys 10.0.30.2:/etc/ha.d/</pre>
<p>And go to the second node to start heartbeat there:</p>
<pre>srv2:#/etc/init.d/heartbeat start </pre>
<p>If you done everything right -> one of the your node should be has
<pre>eth0:0</pre>
<p> interface which indicate active node. Its looks like this:</p>
<pre>srv1:# ifconfig eth0:0
          eth0:0    Link encap:Ethernet  HWaddr 08:00:27:7B:7E:03
          inet addr:10.0.30.3  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:11 Base address:0xc020
</pre>
<p>The last one step in our configuration is checking the cluster. Go to active node and run: </p>
<pre>reboot</pre>
<p>In several seconds you will see that httpd processes were started and
<pre>eth0:0</pre>
<p> interface is appears at another node. </p>
<pre>srv2:# ifconfig eth0:0
          eth0:0    Link encap:Ethernet  HWaddr 08:00:27:7B:7E:03
          inet addr:10.0.30.3  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:11 Base address:0xc020</pre>
<pre>ps uax | grep http | grep -v grep
root      2300  0.0  3.6  23004  9424 ?        Ss   02:37   0:01 /usr/sbin/httpd
apache    2323  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2324  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2325  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2326  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2327  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2328  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2331  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd
apache    2332  0.0  1.8  23004  4780 ?        S    02:37   0:00 /usr/sbin/httpd</pre>
<p>Looks like everything done well. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/ha-cluster-for-production-utilization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make redirection from one web site to another via htaccess</title>
		<link>http://andriigrytsenko.net/2009/06/make-rediraction-from-one-domain-to-another-via-htaccess/</link>
		<comments>http://andriigrytsenko.net/2009/06/make-rediraction-from-one-domain-to-another-via-htaccess/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 13:01:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[httpd]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=86</guid>
		<description><![CDATA[Here is some example how to redirect web users from one domain to another one.

In the event of you have 2 domains and you want to use one of this as general one. And redirect all requests from one domain to another one.  For example redirect requests from test.com.ua to test.com you need to [...]]]></description>
			<content:encoded><![CDATA[<p>Here is some example how to redirect web users from one domain to another one.<br />
<span id="more-86"></span><br />
In the event of you have 2 domains and you want to use one of this as general one. And redirect all requests from one domain to another one.  For example redirect requests from test.com.ua to test.com you need to install apache with mod_rewrite module. For debian you have to make next command(as root): </p>
<pre>
#cd /etc/apache2/mods-enabled
# ln -s ../mods-available/rewrite.load  rewrite.load
</pre>
<p>For another distros you able to compile apache from sources with option &#8220;&#8211;enable-module=rewrite&#8221;. </p>
<p>Also you should put or change some lines in the apache configuration file (apache2.conf OR httpd.conf). In main section: </p>
<pre>
AccessFileName .htaccess
</pre>
<p>In the Directory section : </p>
<pre>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</pre>
<p>After that restart apache server: </p>
<pre>
# /etc/init.d/apache2 restart</pre>
<p>Now you are ready to make your .htaccess file. Go to the your web directory: </p>
<pre># cd /var/www/
# cat > .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test\.com\.ua$
RewriteRule (.*) http://test.ua/$1 [L,R]</pre>
<p>Check your web site via browser. If you have done everything describe above in proper way you will be redirected from test.com.ua to test.ua. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/06/make-rediraction-from-one-domain-to-another-via-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
