<?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>baalchina &#187; ha</title>
	<atom:link href="http://www.baalchina.net/tag/ha/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.baalchina.net</link>
	<description>baalchina技术日志</description>
	<lastBuildDate>Mon, 19 Jul 2010 08:30:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux集群的安装与配置（Part II，配置）</title>
		<link>http://www.baalchina.net/2009/08/heartbeat-configration-part-2/</link>
		<comments>http://www.baalchina.net/2009/08/heartbeat-configration-part-2/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 08:34:20 +0000</pubDate>
		<dc:creator>baalchina</dc:creator>
				<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ha]]></category>
		<category><![CDATA[heartbeat]]></category>

		<guid isPermaLink="false">http://www.baalchina.net/2009/08/linux%e9%9b%86%e7%be%a4%e7%9a%84%e5%ae%89%e8%a3%85%e4%b8%8e%e9%85%8d%e7%bd%ae%ef%bc%88part-ii%ef%bc%8c%e9%85%8d%e7%bd%ae%ef%bc%89/</guid>
		<description><![CDATA[Heartbeat的配置文件主要是3个，也就是前面我们cp到/etc/ha.d下面的ha.cf，haresources以及authkeys，作用可以理解为系统配置，资源配置，以及认证的设置。一个个搞定。
&#160;
ha.cf
配置比较简单，保证能跑起来
#logfile      debugfile /var/log/ha-debug       logfile /var/log/ha-log       logfacility&#160;&#160;&#160;&#160; local0 
#time setting      keepalive 2       deadtime 30       warntime 10       [...]]]></description>
			<content:encoded><![CDATA[<p>Heartbeat的配置文件主要是3个，也就是前面我们cp到/etc/ha.d下面的<strong>ha.cf</strong>，<strong>haresources</strong>以及<strong>authkeys</strong>，作用可以理解为系统配置，资源配置，以及认证的设置。一个个搞定。</p>
<p>&#160;</p>
<h3>ha.cf</h3>
<p>配置比较简单，保证能跑起来</p>
<blockquote><p>#logfile      <br />debugfile /var/log/ha-debug       <br />logfile /var/log/ha-log       <br />logfacility&#160;&#160;&#160;&#160; local0 </p>
<p>#time setting      <br />keepalive 2       <br />deadtime 30       <br />warntime 10       <br />initdead 120       </p>
<p>#network setting      <br />udpport 694       <br />bcast eth1       <br />ucast eth1 192.168.100.2 </p>
<p>#node setting      <br />auto_failback on       <br />node&#160;&#160;&#160; linux-ha-a       <br />node&#160;&#160;&#160; linux-ha-b</p>
</blockquote>
<p>我这边跑的是双网卡。其中eth1作为心跳线，配置了192.168.100.1/2两个地址。</p>
<h3>haresources</h3>
<p>最简配制的话其实就是一条：</p>
<p>&#160;</p>
<blockquote><p>#this is resource config      <br />linux-ha-a 210.28.92.233 httpd::start</p>
</blockquote>
<p>三段：</p>
<p>主机名，集群的ip，需要启动的服务::传递给这个服务的参数。</p>
<p>文件介绍上说两台设备的haresources要完全一样，你可别真的完全一样把主机名也一样了…哈。</p>
<p>&#160;</p>
<p>&#160;</p>
<h3>authkeys</h3>
<p>这个支持3种认证方式，sha1&gt;md5&gt;crc。其中前两种需要指定密钥。crc只做校验用，没认证的效果。这个文件需要保证600权限。</p>
<p>因为是测试就简单点了，用MD5，验证码用linux-ha的md5值（17bc50a13f1dd31c14f2a3f321e017dc）。实际上直接输入一个字符串就可以了，没必要输入md5的值。</p>
<p>&#160;</p>
<p>注意这个类似于eigrp的认证，是支持多个key-chain的。</p>
<blockquote><p>auth 1      <br />#1 crc       <br />#2 sha1 HI!       <br />1 md5 17bc50a13f1dd31c14f2a3f321e017dc</p>
</blockquote>
<p>注意auth 1必须对应下面的1 md5 key</p>
<p>&#160;</p>
<h3></h3>
<h3>检测效果/MAC切换机制</h3>
<p>全部配置完成之后可以打开虚拟ip地址，网页可以打开，然后再关掉server-a的接口，然后再刷新，看看可否看到页面？</p>
<p>我做的时候没自动切换，结果跑到交换机上#clea ip arp 才有效…郁闷…注意这个MAC地址：</p>
<p>MAC：</p>
<blockquote><p>210.xx.yy.231&#160;&#160; 0&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0050.56af.15fd arpa&#160;&#160; VL922      <br />210.xx.yy.232&#160;&#160; 0&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0050.56af.3842 arpa&#160;&#160; VL922       <br />210.xx.yy.233&#160;&#160; 0&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0050.56af.3842 arpa&#160;&#160; VL922</p>
</blockquote>
<p>这时候232这台设备生效。233为虚拟MAC。</p>
<p>可以看到的是，ha并没有诸如HSRP/VRRP那样的虚拟MAC机制。而是直接用的设备的MAC。</p>
<p>你ssh到233，其实就是连接到232。</p>
<h3>待解决</h3>
<p>如果跑的是http，那么就要考虑共享存储的问题。静态的还好，如果是动态的呢？</p>
<p>如果是数据库，同样要考虑存储。不过mysql本身的cluster应该可以解决--据说是不用共享存储的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.baalchina.net/2009/08/heartbeat-configration-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux集群的安装与配置（Part I，安装）</title>
		<link>http://www.baalchina.net/2009/08/heartbeat-configuration/</link>
		<comments>http://www.baalchina.net/2009/08/heartbeat-configuration/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 10:41:35 +0000</pubDate>
		<dc:creator>baalchina</dc:creator>
				<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ha]]></category>
		<category><![CDATA[heartbeat]]></category>

		<guid isPermaLink="false">http://www.baalchina.net/2009/08/heartbeat-configuration/</guid>
		<description><![CDATA[集群的作用有很多，比如HA(high availability)，比如负载均衡等。我这里只做HA，保证可用性。
&#160;
软件用的是开源的heartbeat，http://www.linux-ha.org
安装详解：
下载软件包：
#wget http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2

&#160;
解压编译并安装
&#160;
&#160;
#./ConfigureMe configure
#make
#make install

&#160;
可能会少很多软件包，一个个打上就行了。我的CentOS 5.3，安装的时候自定义只选择开发工具，需要以下的包：
#yum install libnet      #yum install glib2-devel       #yum install libxml2-devel(这个没说，但是后面是需要的) 
#yum install PyXML 

&#160;
另外需要注意的是，如果他告诉你缺某个包，你yum之后，重新make还是会报错的，需要重新./configure再make。这点比较诡异。
扫尾搞定配置文件
cp doc/ha.cf /etc/ha.d/      cp doc/haresources /etc/ha.d/       cp doc/authkeys /etc/ha.d/       cp [...]]]></description>
			<content:encoded><![CDATA[<p>集群的作用有很多，比如HA(high availability)，比如负载均衡等。我这里只做HA，保证可用性。</p>
<p>&#160;</p>
<p>软件用的是开源的heartbeat，<a title="http://www.linux-ha.org" href="http://www.linux-ha.org">http://www.linux-ha.org</a></p>
<h3>安装详解：</h3>
<p>下载软件包：</p>
<blockquote><p>#wget <a href="http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2">http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2</a></p>
</blockquote>
<p>&#160;</p>
<p>解压编译并安装</p>
<p>&#160;</p>
<p>&#160;</p>
<blockquote><p>#./ConfigureMe configure</p>
<p>#make</p>
<p>#make install</p>
</blockquote>
<p>&#160;</p>
<p>可能会少很多软件包，一个个打上就行了。我的CentOS 5.3，安装的时候自定义只选择开发工具，需要以下的包：</p>
<blockquote><p>#yum install libnet      <br />#yum install glib2-devel       <br />#yum install libxml2-devel(这个没说，但是后面是需要的) </p>
<p>#yum install PyXML </p>
</blockquote>
<p>&#160;</p>
<p><strong>另外需要注意的是，如果他告诉你缺某个包，你yum之后，重新make还是会报错的，需要重新./configure再make。</strong>这点比较诡异。</p>
<h3>扫尾搞定配置文件</h3>
<blockquote><p>cp doc/ha.cf /etc/ha.d/      <br />cp doc/haresources /etc/ha.d/       <br />cp doc/authkeys /etc/ha.d/       <br />cp ldirectord/ldirectord.cf /etc/ha.d/</p>
</blockquote>
<p>&#160;</p>
<h3>服务的启动、停止等</h3>
<p>&#160;</p>
<blockquote><p>/etc/rc.d/init.d/heartbeat start | stop | restert| status</p>
</blockquote>
<p>&#160;</p>
<h3>安装的Troubleshooting</h3>
<p>&#160;</p>
<blockquote><p>configure: WARNING: The following recommended components noted earlier are missing:      <br />&#160;&#160;&#160;&#160; uuid library, Python.h, security/pam_appl.h, gnutls/gnutls.h, gnutls/gnutls.h       <br />&#160;&#160;&#160; We will continue but you may have lost some non-critical functionality.       <br />configure: error: The following required components noted earlier are missing:       <br />&#160;&#160;&#160;&#160; glib2-devel, libnet       <br />&#160;&#160;&#160; Please supply them and try again. </p>
<p>./bootstrap exiting due to error (sorry!). </p>
</blockquote>
<p>这个是缺少包了。把几个包yum一下就行了。</p>
<h3>题外话：</h3>
<p>libnet也可以自己编译，这个比较诡异。</p>
<blockquote><p>wget <a href="http://ncu.dl.sourceforge.net/project/libnet/libnet/0.10.11/libnet-0.10.11.tar.gz">http://ncu.dl.sourceforge.net/project/libnet/libnet/0.10.11/libnet-0.10.11.tar.gz</a>       <br />cd libnet       <br />cp makfiles/linux.mak port.mak(注意是makfile不是makefile啊) </p>
</blockquote>
<p>&#160;</p>
<blockquote><p>#yum install hearbeat</p>
</blockquote>
<p>提示如下：</p>
<blockquote><p>Installing:      <br />heartbeat&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i386&#160;&#160;&#160;&#160;&#160;&#160; 2.1.3-3.el5.centos&#160;&#160;&#160;&#160;&#160;&#160; extras&#160;&#160;&#160;&#160;&#160;&#160; 1.7 M       <br />Installing for dependencies:       <br />PyXML&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i386&#160;&#160;&#160;&#160;&#160;&#160; 0.8.4-4&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; base&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1.1 M       <br />heartbeat-pils&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i386&#160;&#160;&#160;&#160;&#160;&#160; 2.1.3-3.el5.centos&#160;&#160;&#160;&#160;&#160;&#160; extras&#160;&#160;&#160;&#160;&#160;&#160; 213 k       <br />heartbeat-stonith&#160;&#160;&#160;&#160;&#160;&#160; i386&#160;&#160;&#160;&#160;&#160;&#160; 2.1.3-3.el5.centos&#160;&#160;&#160;&#160;&#160;&#160; extras&#160;&#160;&#160;&#160;&#160;&#160; 311 k </p>
</blockquote>
<p>原来是要PyXML这个包，注意大小写 </p>
<p>&#160;</p>
<p>接下来继续编译，安装    <br />make又错： </p>
<blockquote><p>cc1: warnings being treated as errors      <br />xml.c: In function 'write_xml_file':       <br />xml.c:635: warning: unused variable 'in'       <br />xml.c: In function 'get_message_xml':       <br />xml.c:775: error: 'BZ_OK' undeclared (first use in this function)       <br />xml.c:775: error: (Each undeclared identifier is reported only once       <br />xml.c:775: error: for each function it appears in.)       <br />xml.c:796: warning: implicit declaration of function 'BZ2_bzBuffToBuffDecompress'       <br />xml.c:799: error: 'BZ_OUTBUFF_FULL' undeclared (first use in this function)       <br />gmake[3]: *** [xml.lo] 错误 1       <br />gmake[3]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib/crm/common'       <br />gmake[2]: *** [all-recursive] 错误 1       <br />gmake[2]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib/crm'       <br />gmake[1]: *** [all-recursive] 错误 1       <br />gmake[1]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib'       <br />make: *** [all-recursive] 错误 1 </p>
</blockquote>
<p>这个应该是bz报错，bz是什么？bzip2？ </p>
<p>不管了</p>
<blockquote><p>yum install bzip2-devel </p>
</blockquote>
<p>继续    </p>
<p>编译完成之后有这个提示：</p>
<blockquote><p>chown hacluster /var/lib/heartbeat/cores/hacluster      <br />chown: “hacluster”: 无效的用户       <br />gmake[2]: [install-exec-local] 错误 1 (忽略)       <br />chmod 700 /var/lib/heartbeat/cores/hacluster       <br />cd /usr/lib/heartbeat;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; for file in `ls /usr/share/heartbeat`;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; do if [&#160; -d $file ]; then continue; fi; \       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rm -f $file &amp;&amp; ln -s /usr/share/heartbeat/$file .;&#160;&#160;&#160;&#160;&#160; \       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; done       <br />gmake[2]: Nothing to be done for `install-data-am'.       <br />gmake[2]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4'       <br />gmake[1]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4' </p>
</blockquote>
<p>注意用户问题哦。 </p>
<p>&#160;</p>
<p>&#160;</p>
<blockquote><p>[root@linux-ha-a ~]# /etc/rc.d/init.d/heartbeat start     <br />logd is already running      <br />Starting High-Availability services:       <br />[失败]      <br />heartbeat: udpport setting must precede media statementsheartbeat[20883]: 2009/08/13_06:26:00 ERROR: Invalid user id name [hacluster]      <br />heartbeat[20883]: 2009/08/13_06:26:00 ERROR: Bad uid list [hacluster]      <br />heartbeat[20883]: 2009/08/13_06:26:00 ERROR: Invalid apiauth directive [ipfail uid=hacluster]</p>
</blockquote>
<p>这个就是结果啦。</p>
<p>解决方法：</p>
<blockquote><p>useradd hacluster     <br />groupadd haclient </p>
<p>chown hacluster /var/lib/heartbeat/cores/hacluster      <br />chmod 700 /var/lib/heartbeat/cores/hacluster </p>
</blockquote>
<p>&#160;</p>
<p>这个报错：</p>
<blockquote><p>heartbeat: udpport setting must precede media statementsheartbeat[21237]: 2009/08/13_06:39:21 ERROR: Auth Key [1] not found in keyfile [/etc/ha.d/authkeys]      <br />heartbeat[21237]: 2009/08/13_06:39:21 ERROR: Authentication configuration error.      <br />heartbeat[21237]: 2009/08/13_06:39:21 ERROR: Configuration error, heartbeat not started. </p>
</blockquote>
<p>这个有点好玩，意思是udpport的设置必须在media设置之前。但是实际上是authkey报错造成的，解决方法就是正确配置authkey。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.baalchina.net/2009/08/heartbeat-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
