<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>侧耳倾听</title>
	<link>http://www.yubo.org/blog</link>
	<description>Small is beautiful.</description>
	<pubDate>Fri, 31 Oct 2008 03:43:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>linux线程操作</title>
		<link>http://www.yubo.org/blog/?p=34</link>
		<comments>http://www.yubo.org/blog/?p=34#comments</comments>
		<pubDate>Fri, 31 Oct 2008 03:43:47 +0000</pubDate>
		<dc:creator>sew0359</dc:creator>
		
		<category><![CDATA[c]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=34</guid>
		<description><![CDATA[&#160;--------------------------线程的创建---------------------------
&#160; 
&#160;pthread_t mythread;
&#160;//线程句柄声明,用来存放tid
&#160; 
&#160;pthread_create( &#38;mythread, NULL, thread_function, NULL)
&#160;//创建新的线程
&#160;//参数一:线程句柄,存放tid
&#160;//参数二:线程函数返回值
&#160;//参数三:线程函数,由thread_function函数指针定义
&#160;//参数四:线程函数的参数
&#160; 
&#160;pthread_join ( mythread, NULL )
&#160;//等待mythread线程于主线程合并
&#160; 
&#160;fflush(stdout);
&#160;//清空标准输出缓冲区
&#160; 
&#160; 
&#160; 
&#160;--------------------------线程的同步(互斥锁)---------------------------
&#160;pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER;
&#160;//初始化mymutex互斥锁(使用宏的静态版本)
&#160; 
&#160; 
&#160;pthread_mutex_t mymutex;
&#160;pthread_mutex_init(&#38;mymutex,NULL);
&#160;//初始化mymutex互斥锁(动态版本)
&#160; 
&#160;pthread_mutex_lock(&#38;mymutex);
&#160;//mymutex上锁,当得不到互斥锁时,进入等待队列,直到得到为止
&#160; 
&#160;pthread_mutex_trylock(pthread_mutex_t *mutex)
&#160;//mymutex上锁,当得不到互斥锁时,立刻返回EBUSY
&#160; 
&#160;pthread_mutex_unlock(&#38;mymutex);
&#160;//mymutex解锁
&#160; 
&#160;pthread_mutex_destroy(&#38;mymutex)
&#160;//释放mymutex指针指向的资源(释放mymutex指针指向的内存,并不指针本身)
&#160; 
&#160; 
&#160;--------------------------线程的同步(等待)---------------------------
&#160;pthread_cond_t mycond;
&#160;//定义条件变量mycond
&#160; 
&#160;pthread_cond_init(&#38;mycond,NULL);
&#160;//初始化条件变量mycond
&#160; 
&#160;pthread_cond_destroy(&#38;mycond);
&#160;//释放mycond指针指向的资源
&#160; 
&#160;pthread_cond_wait(&#38;mycond, &#38;mymutex){
&#160;&#160; &#160; mymutex解锁;
&#160;&#160; &#160; while(1){
&#160;&#160; &#160; &#160; &#160; mycond休眠并等待被唤醒;
&#160;&#160; &#160; &#160; &#160; if(mycond被唤醒)
&#160;&#160; &#160; &#160; &#160; &#160; &#160; if(mymutex上锁成功) 
&#160;&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="hl-surround"><div class="hl-main"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li>&nbsp;<span style="color: Gray;">--------------------------线程的创建---------------------------</li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_t</span><span style="color: Gray;"> </span><span style="color: Blue;">mythread</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//线程句柄声明,用来存放tid</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_create</span><span style="color: Olive;">(</span><span style="color: Gray;"> &amp;</span><span style="color: Blue;">mythread</span><span style="color: Gray;">, </span><span >NULL</span><span style="color: Gray;">, </span><span style="color: Blue;">thread_function</span><span style="color: Gray;">, </span><span >NULL</span><span style="color: Olive;">)</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//创建新的线程</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//参数一:线程句柄,存放tid</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//参数二:线程函数返回值</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//参数三:线程函数,由thread_function函数指针定义</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//参数四:线程函数的参数</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_join</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Blue;">mythread</span><span style="color: Gray;">, </span><span >NULL</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//等待mythread线程于主线程合并</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">fflush</span><span style="color: Olive;">(</span><span style="color: Blue;">stdout</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//清空标准输出缓冲区</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp; </li>
<li>&nbsp; </li>
<li>&nbsp;--------------------------线程的同步</span><span style="color: Olive;">(</span><span style="color: Gray;">互斥锁</span><span style="color: Olive;">)</span><span style="color: Gray;">---------------------------</li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_t</span><span style="color: Gray;"> </span><span style="color: Blue;">mymutex</span><span style="color: Gray;">=</span><span style="color: Blue;">PTHREAD_MUTEX_INITIALIZER</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//初始化mymutex互斥锁(使用宏的静态版本)</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_t</span><span style="color: Gray;"> </span><span style="color: Blue;">mymutex</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_init</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mymutex</span><span style="color: Gray;">,</span><span >NULL</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//初始化mymutex互斥锁(动态版本)</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_lock</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mymutex</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//mymutex上锁,当得不到互斥锁时,进入等待队列,直到得到为止</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_trylock</span><span style="color: Olive;">(</span><span style="color: Blue;">pthread_mutex_t</span><span style="color: Gray;"> *</span><span style="color: Blue;">mutex</span><span style="color: Olive;">)</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//mymutex上锁,当得不到互斥锁时,立刻返回EBUSY</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_unlock</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mymutex</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//mymutex解锁</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_mutex_destroy</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mymutex</span><span style="color: Olive;">)</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//释放mymutex指针指向的资源(释放mymutex指针指向的内存,并不指针本身)</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp; </li>
<li>&nbsp;--------------------------线程的同步</span><span style="color: Olive;">(</span><span style="color: Gray;">等待</span><span style="color: Olive;">)</span><span style="color: Gray;">---------------------------</li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_t</span><span style="color: Gray;"> </span><span style="color: Blue;">mycond</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//定义条件变量mycond</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_init</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mycond</span><span style="color: Gray;">,</span><span >NULL</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//初始化条件变量mycond</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_destroy</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mycond</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//释放mycond指针指向的资源</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_wait</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mycond</span><span style="color: Gray;">, &amp;</span><span style="color: Blue;">mymutex</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span><span style="color: Gray;"></li>
<li>&nbsp;&nbsp; &nbsp; </span><span style="color: Blue;">mymutex</span><span style="color: Gray;">解锁;</li>
<li>&nbsp;&nbsp; &nbsp; </span><span style="color: Green;">while</span><span style="color: Olive;">(</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Olive;">{</span><span style="color: Gray;"></li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">mycond</span><span style="color: Gray;">休眠并等待被唤醒;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">mycond</span><span style="color: Gray;">被唤醒</span><span style="color: Olive;">)</span><span style="color: Gray;"></li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">mymutex</span><span style="color: Gray;">上锁成功</span><span style="color: Olive;">)</span><span style="color: Gray;"> </li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Maroon;">0</span><span style="color: Gray;">;</li>
<li>&nbsp;&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"></li>
<li>&nbsp;</span><span style="color: #ffa500;">//等待mycond得到信号被唤醒</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_broadcast</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mycond</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//对mycond广播唤醒信号</span><span style="color: Gray;"></li>
<li>&nbsp; </li>
<li>&nbsp;</span><span style="color: Blue;">pthread_cond_signal</span><span style="color: Olive;">(</span><span style="color: Gray;">&amp;</span><span style="color: Blue;">mycond</span><span style="color: Olive;">)</span><span style="color: Gray;">;</li>
<li>&nbsp;</span><span style="color: #ffa500;">//对mycond单播唤醒信号(通常是下一个)</span></li></ol></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=34</wfw:commentRss>
		</item>
		<item>
		<title>MOSIX-2.24.2.2/linux-2.6.26集群(三)&#8211;应用测试</title>
		<link>http://www.yubo.org/blog/?p=33</link>
		<comments>http://www.yubo.org/blog/?p=33#comments</comments>
		<pubDate>Tue, 09 Sep 2008 08:25:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<category><![CDATA[mosix]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=33</guid>
		<description><![CDATA[#先在rehl5和slave上各开启一个终端,运行mon命令,检查
[root@rhel5 ~]# mon

#2个节点上应该都是闲置的吧
#为了能出些效果,做点费cpu的脚本,还必须是多线程的,
#mosix能够迁移的最小单位是进程,而不是指令或者函数,
#所以单进程负载再高也没意义
[root@rhel5 ~]# cat a.sh &#60;&#60; EOFawk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;awk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;awk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;awk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;awk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;awk 'BEGIN {for(i=0;i&#60;100000;i++)for(j=0;j&#60;100000;j++);}'&#160; &#38;EOF[root@rhel5 ~]# chmod +x a.sh
#在rhel5上运行a.sh,也就是产生6个进程了
[root@rhel5 ~]# mosrun -e ./a.sh
#开始观察2个节点上的mon画面,刚开始rhel负载很高,然后slave的负载也起来了,能够看到

#能够看到在rhel5上,awk的6个进程还在,但是只有3个在运行,还有3个的状态是T(stop),哈哈,应该是迁移了
[root@rhel5 ~]# ps -aux &#124; grep awkWarning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQroot&#160; &#160; &#160;25648&#160; 0.6&#160; 0.0&#160; &#160; &#160; 0&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>#先在rehl5和slave上各开启一个终端,运行mon命令,检查<br />
[root@rhel5 ~]# mon</p>
<p><img border="0"  src="http://www.yubo.org/images/mosix/2.jpg"  /></p>
<p>#2个节点上应该都是闲置的吧</p>
<p>#为了能出些效果,做点费cpu的脚本,还必须是多线程的,<br />
#mosix能够迁移的最小单位是进程,而不是指令或者函数,<br />
#所以单进程负载再高也没意义</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# cat a.sh &lt;&lt; EOF<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />awk 'BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}'&nbsp; &amp;<br />EOF<br /><br />[root@rhel5 ~]# chmod +x a.sh</div></div>
<p>#在rhel5上运行a.sh,也就是产生6个进程了</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# mosrun -e ./a.sh</div></div>
<p>#开始观察2个节点上的mon画面,刚开始rhel负载很高,然后slave的负载也起来了,能够看到</p>
<p><img border="0"  src="http://www.yubo.org/images/mosix/3.jpg"  /></p>
<p>#能够看到在rhel5上,awk的6个进程还在,但是只有3个在运行,还有3个的状态是T(stop),哈哈,应该是迁移了</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# ps -aux | grep awk<br />Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ<br />root&nbsp; &nbsp; &nbsp;25648&nbsp; 0.6&nbsp; 0.0&nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp;0 pts/0&nbsp; &nbsp; T&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:00 [awk]<br />root&nbsp; &nbsp; &nbsp;25650&nbsp; 0.4&nbsp; 0.0&nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp;0 pts/0&nbsp; &nbsp; T&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:00 [awk]<br />root&nbsp; &nbsp; &nbsp;25652 32.0&nbsp; 0.7&nbsp; &nbsp;4168&nbsp; 3812 pts/0&nbsp; &nbsp; R&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:37 awk BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}<br />root&nbsp; &nbsp; &nbsp;25654 32.0&nbsp; 0.7&nbsp; &nbsp;4168&nbsp; 3816 pts/0&nbsp; &nbsp; R&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:37 awk BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}<br />root&nbsp; &nbsp; &nbsp;25656 32.0&nbsp; 0.7&nbsp; &nbsp;4168&nbsp; 3816 pts/0&nbsp; &nbsp; R&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:37 awk BEGIN {for(i=0;i&lt;100000;i++)for(j=0;j&lt;100000;j++);}<br />root&nbsp; &nbsp; &nbsp;25658&nbsp; 1.4&nbsp; 0.0&nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp;0 pts/0&nbsp; &nbsp; T&nbsp; &nbsp; 16:16&nbsp; &nbsp;0:01 [awk]<br />root&nbsp; &nbsp; &nbsp;25665&nbsp; 0.0&nbsp; 0.1&nbsp; &nbsp;3860&nbsp; &nbsp;624 pts/0&nbsp; &nbsp; R+&nbsp; &nbsp;16:18&nbsp; &nbsp;0:00 grep awk</div></div>
<p>#到slave上top看看吧,明显看到有3个叫remoted的进程占用了cpu,这个就是迁移过来的状态吧</p>
<div class="hl-surround"><div class="hl-main">top - 16:19:19 up&nbsp; 3:10,&nbsp; 3 users,&nbsp; load average: 2.78, 1.18, 0.44<br />Tasks:&nbsp; 99 total,&nbsp; &nbsp;5 running,&nbsp; 94 sleeping,&nbsp; &nbsp;0 stopped,&nbsp; &nbsp;0 zombie<br />Cpu(s): 99.3%us,&nbsp; 0.3%sy,&nbsp; 0.0%ni,&nbsp; 0.0%id,&nbsp; 0.0%wa,&nbsp; 0.0%hi,&nbsp; 0.3%si<br />Mem:&nbsp; &nbsp; 515376k total,&nbsp; &nbsp;423576k used,&nbsp; &nbsp; 91800k free,&nbsp; &nbsp;107980k buff<br />Swap:&nbsp; 1048568k total,&nbsp; &nbsp; &nbsp; &nbsp; 0k used,&nbsp; 1048568k free,&nbsp; &nbsp;234028k cach<br /><br />&nbsp; PID USER&nbsp; &nbsp; &nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp; &nbsp; TIME+&nbsp; COMMAND <br />16929 root&nbsp; &nbsp; &nbsp; 20&nbsp; &nbsp;0&nbsp; 4168 3936&nbsp; &nbsp; 0 R 33.2&nbsp; 0.8&nbsp; &nbsp;0:48.13 remoted <br />16925 root&nbsp; &nbsp; &nbsp; 20&nbsp; &nbsp;0&nbsp; 4168 3932&nbsp; &nbsp; 0 R 32.9&nbsp; 0.8&nbsp; &nbsp;0:50.57 remoted <br />16927 root&nbsp; &nbsp; &nbsp; 20&nbsp; &nbsp;0&nbsp; 4168 3932&nbsp; &nbsp; 0 R 32.9&nbsp; 0.8&nbsp; &nbsp;0:50.13 remoted <br />&nbsp;&nbsp; &nbsp;1 root&nbsp; &nbsp; &nbsp; 20&nbsp; &nbsp;0&nbsp; 2036&nbsp; 664&nbsp; 572 S&nbsp; 0.0&nbsp; 0.1&nbsp; &nbsp;0:01.36 init&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;2 root&nbsp; &nbsp; &nbsp; 15&nbsp; -5&nbsp; &nbsp; &nbsp;0&nbsp; &nbsp; 0&nbsp; &nbsp; 0 S&nbsp; 0.0&nbsp; 0.0&nbsp; &nbsp;0:00.00 kthreadd<br />&nbsp;&nbsp; &nbsp;3 root&nbsp; &nbsp; &nbsp; RT&nbsp; -5&nbsp; &nbsp; &nbsp;0&nbsp; &nbsp; 0&nbsp; &nbsp; 0 S&nbsp; 0.0&nbsp; 0.0&nbsp; &nbsp;0:00.00 migratio<br />&nbsp;&nbsp; &nbsp;4 root&nbsp; &nbsp; &nbsp; 15&nbsp; -5&nbsp; &nbsp; &nbsp;0&nbsp; &nbsp; 0&nbsp; &nbsp; 0 S&nbsp; 0.0&nbsp; 0.0&nbsp; &nbsp;0:02.00 ksoftirq</div></div>
<p>##############THE END############</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>MOSIX-2.24.2.2/linux-2.6.26集群(二)&#8211;配置</title>
		<link>http://www.yubo.org/blog/?p=32</link>
		<comments>http://www.yubo.org/blog/?p=32#comments</comments>
		<pubDate>Tue, 09 Sep 2008 08:25:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[mosix]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=32</guid>
		<description><![CDATA[将rhel5和slave开启,开机的时候,在grub界面按回车,然后选择2.6.26内核启动

slave启动以后,把ip地址,机器名改好(应为是由rhel5克隆得到的嘛)
[reel5]
#配置mosix
[root@rhel5 ~]# mosconfMOSIX CONFIGURATION===================If this is your cluster's file-server and you want to configure MOSIXfor a set of nodes with a common root, please type their common rootdirectory. Otherwise, if you want to configure the node that you arerunning on, just press &#60;ENTER&#62; :-What would you like to configure?=================================1. Which nodes are in this cluster&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>将rhel5和slave开启,开机的时候,在grub界面按回车,然后选择2.6.26内核启动<br />
<img border="0"  src="http://www.yubo.org/images/mosix/1.jpg"  /></p>
<p>slave启动以后,把ip地址,机器名改好(应为是由rhel5克隆得到的嘛)</p>
<p>[reel5]</p>
<p>#配置mosix</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# mosconf<br />MOSIX CONFIGURATION<br />===================<br /><br />If this is your cluster's file-server and you want to configure MOSIX<br />for a set of nodes with a common root, please type their common root<br />directory. Otherwise, if you want to configure the node that you are<br />running on, just press &lt;ENTER&gt; :-<br /><br />What would you like to configure?<br />=================================<br />1. Which nodes are in this cluster&nbsp; &nbsp; &nbsp; (ESSENTIAL)<br />2. Authentication&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(ESSENTIAL)<br />3. Logical node numbering&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(recommended)<br />4. Queueing policies&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (recommended)<br />5. Freezing policies<br />6. Miscellaneous policies<br />7. Become part of a multi-cluster organizational Grid<br /><br />Configure what :- 1<br /><br />There are no nodes in your cluster yet:<br />=======================================<br /><br />To add a new set of nodes to your cluster, type 'n'.<br />To turn on advanced options, type '+'.<br />For help, type 'h'.<br />To save and exit, type 'q'.&nbsp; (to abandon all changes and exit, type 'Q')<br /><br />Option :- n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;==添加节点<br /><br />Adding new node(s) to the cluster:<br /><br />First host-name or IP address :- 192.168.1.5&nbsp; &nbsp; &lt;==节点ip<br />Number of nodes :- 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;==节点数<br /><br />Nodes in your cluster:<br />======================<br />1. 192.168.1.5<br /><br />To add a new set of nodes to your cluster, type 'n'.<br />To modify an entry, type its number.<br />To delete an entry, type 'd' followed by that entry-number (eg. d1).<br />To turn on advanced options, type '+'.<br />For help, type 'h'.<br />To save and exit, type 'q'.&nbsp; (to abandon all changes and exit, type 'Q')<br /><br />Option :- n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;==添加节点<br /><br />Adding new node(s) to the cluster:<br /><br />First host-name or IP address :- 192.168.1.6&nbsp; &nbsp; &lt;==节点ip<br />Number of nodes :- 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;==节点数<br /><br />Nodes in your cluster:<br />======================<br />1. 192.168.1.5<br />2. 192.168.1.6<br /><br />To add a new set of nodes to your cluster, type 'n'.<br />To modify an entry, type its number.<br />To delete an entry, type 'd' followed by that entry-number (eg. d2).<br />To turn on advanced options, type '+'.<br />For help, type 'h'.<br />To save and exit, type 'q'.&nbsp; (to abandon all changes and exit, type 'Q')<br /><br />Option :- q&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;==保存退出<br /><br />Cluster configuration was saved.<br /><br /><br />OK to also update the logical node numbers [Y/n]? y<br /><br />Suggesting to assign '192.168.1.5'<br />as the central queue manager for the cluster<br />(but be cautious if you mix 32-bit and 64-bit nodes in the same cluster)<br />OK to update it now [Y/n]? <br /><br />What would you like to configure next?<br />======================================<br />1. Which nodes are in this cluster<br />2. Authentication&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(ESSENTIAL)<br />3. Logical node numbering<br />4. Queueing policies<br />5. Freezing policies<br />6. Miscellaneous policies<br />7. Become part of a multi-cluster organizational Grid<br />q. Exit<br /><br />Configure what :- 2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;==设置密码<br /><br />MOSIX Authentication:<br />=====================<br /><br />To protect your MOSIX cluster from abuse, preventing unauthorized<br />persons from gaining control over your computers, you need to set<br />up a secret cluster-protection key. This key can include any<br />characters, but must be identical throughout your cluster.<br /><br />Your secret cluster-protection key: xxxx&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;==输入密码<br />Your key is 5 characters long.<br />(in the future, please consider a longer one)<br /><br />To allow your users to send batch-jobs to other nodes in the cluster,<br />you must set up a secret batch-client key. This key can include any<br />characters, but must match the 'batch-server' key on the node(s) that<br />can receive batch-jobs from this node.<br /><br />Your secret batch-client key: xxxx&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;==输入密码<br />Your key is 5 characters long.<br />(in the future, please consider a longer one)<br /><br />For this node to accept batch jobs,<br />you must set up a secret batch-server key. This key can include any<br />characters, but must match the 'batch-client' key on the sending nodes.<br /><br />To make your batch-server key the same as your batch-client key, type '+'.<br />Your secret batch-server key: xxxx&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;==输入密码<br />Your key is 5 characters long.<br />(in the future, please consider a longer one)<br /><br />#保持退出</div></div>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# service mosix restart</div></div>
<div class="hl-surround"><div class="hl-main">[root@slave ~]# mosconf<br />....</div></div>
<p>#操作同rhel5一样</p>
<p>#重启服务</p>
<div class="hl-surround"><div class="hl-main">[root@slave ~]# service mosix restart</div></div>
<p>#看看状态吧</p>
<div class="hl-surround"><div class="hl-main">[root@slave ~]# service mosix status<br />This MOSIX node is: 192.168.1.6 (no features)<br /><br />Nodes in cluster:<br />=================<br />192.168.1.5: proximate<br />192.168.1.6: proximate<br /><br />Status: Running Normally (32-bits)<br />Load:&nbsp; &nbsp;0.01 (equivalent to about 0.0066 CPU processes)<br />Speed:&nbsp; 6650 units<br />CPUS:&nbsp; &nbsp;1<br />Frozen: 0<br />Util:&nbsp; &nbsp;100%<br />Avail:&nbsp; YES<br />Procs:&nbsp; Running 0 MOSIX processes<br />Accept: Yes, will welcome processes from here<br />Memory: Available 461MB/503MB<br />Swap:&nbsp; &nbsp;Available 0.9GB/0.9GB<br />Daemons:<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Master Daemon: Up<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MOSIX Daemon : Up<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Queue Manager: Up<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Remote Daemon: Up<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Postal Daemon: Up<br />Guest processes from other clusters in the grid: 0/8</div></div>
<p>#我比较喜欢看看端口是不是起来了<br />
#TCP/IP ports 249-253 and UDP/IP ports 249-250 must be available for MOSIX</p>
<div class="hl-surround"><div class="hl-main">[root@slave ~]# netstat -antu | grep -E &quot;24|25&quot;<br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:2401&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:249&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 127.0.0.1:25&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:250&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:251&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />tcp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:252&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTEN&nbsp; &nbsp; &nbsp; <br />udp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:249&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />udp&nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 0.0.0.0:250&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:*</div></div>
<p>#好了,装完了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>MOSIX集群(一)&#8211;安装</title>
		<link>http://www.yubo.org/blog/?p=31</link>
		<comments>http://www.yubo.org/blog/?p=31#comments</comments>
		<pubDate>Tue, 09 Sep 2008 08:24:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<category><![CDATA[mosix]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=31</guid>
		<description><![CDATA[目的: 集群节点内进程能根据负载情况自动迁移
用vmware安装一台rhel5(192.168.1.5)
# 下载MOSIX和kernel代码,准备编译
# 解压到指定目录
[root@rhel5 ~]# tar xjvf MOSIX-2.24.2.2.tbz&#160; -C /usr/src/[root@rhel5 ~]# tar xzvf linux-2.6.26.tar.gz&#160; -C /usr/src/
#进入源代码所在目录
[root@rhel5 ~]# cd /usr/src/
#由于other/patch-2.6.26的目标路径是linux-2.6.26.1,做个连接吧(可能是mosix没有为2.6.26单独写patch&#8230;,不过还是支持的)
[root@rhel5 src]# ln -s linux-2.6.26/ ./linux-2.6.26.1
#给kernel打上mosix补丁
[root@rhel5 src]# patch -p0 &#60; /usr/src/mosix-2.24.2.2/other/patch-2.6.26
#进入源代码目录,开始编译
[root@rhel5 src]# cd linux-2.6.26
#生成配置文件
[root@rhel5 linux-2.6.26]# make menuconfig
#生成依赖关系
[root@rhel5 linux-2.6.26]# make dep
#编译内核
[root@rhel5 linux-2.6.26]# make bzImage
#编译内核模块
[root@rhel5 linux-2.6.26]# make modules
#安装内核模块
[root@rhel5 linux-2.6.26]# make modules_install
#安装内核
[root@rhel5 linux-2.6.26]# make install
#进入mosix目录
[root@rhel5 mosix-2.24.2.2]# cd ../mosix-2.24.2.2
#安装mosix,一路回车,只用安装,记得把你常用级别的mosix服务打开就可以了.配置以后再说
[root@rhel5 mosix-2.24.2.2]# ./mosix.install
关机以后,用rhel5(192.168.1.5)克隆出slave(192.168.1.6)
安装完成
]]></description>
			<content:encoded><![CDATA[<p>目的: 集群节点内进程能根据负载情况自动迁移</p>
<p>用vmware安装一台rhel5(192.168.1.5)</p>
<p># 下载MOSIX和kernel代码,准备编译<br />
# 解压到指定目录</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# tar xjvf MOSIX-2.24.2.2.tbz&nbsp; -C /usr/src/<br />[root@rhel5 ~]# tar xzvf linux-2.6.26.tar.gz&nbsp; -C /usr/src/</div></div>
<p>#进入源代码所在目录</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 ~]# cd /usr/src/</div></div>
<p>#由于other/patch-2.6.26的目标路径是linux-2.6.26.1,做个连接吧(可能是mosix没有为2.6.26单独写patch&#8230;,不过还是支持的)</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 src]# ln -s linux-2.6.26/ ./linux-2.6.26.1</div></div>
<p>#给kernel打上mosix补丁</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 src]# patch -p0 &lt; /usr/src/mosix-2.24.2.2/other/patch-2.6.26</div></div>
<p>#进入源代码目录,开始编译</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 src]# cd linux-2.6.26</div></div>
<p>#生成配置文件</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make menuconfig</div></div>
<p>#生成依赖关系</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make dep</div></div>
<p>#编译内核</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make bzImage</div></div>
<p>#编译内核模块</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make modules</div></div>
<p>#安装内核模块</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make modules_install</div></div>
<p>#安装内核</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 linux-2.6.26]# make install</div></div>
<p>#进入mosix目录</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 mosix-2.24.2.2]# cd ../mosix-2.24.2.2</div></div>
<p>#安装mosix,一路回车,只用安装,记得把你常用级别的mosix服务打开就可以了.配置以后再说</p>
<div class="hl-surround"><div class="hl-main">[root@rhel5 mosix-2.24.2.2]# ./mosix.install</div></div>
<p>关机以后,用rhel5(192.168.1.5)克隆出slave(192.168.1.6)</p>
<p>安装完成</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=31</wfw:commentRss>
		</item>
		<item>
		<title>iscsi+clvm+gfs2+xen+Cluster(四)&#8211;clvm+gfs2的配置</title>
		<link>http://www.yubo.org/blog/?p=30</link>
		<comments>http://www.yubo.org/blog/?p=30#comments</comments>
		<pubDate>Fri, 05 Sep 2008 08:57:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<category><![CDATA[clvm]]></category>

		<category><![CDATA[gfs]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=30</guid>
		<description><![CDATA[刚才的iscsi将服务器上的磁盘共享出来,在cluster中,往往会使用添加共享磁盘的方式扩大共享空间,我们可以使用clvm技术,将多块共享磁盘合并成一个磁盘(卷组volume goup).也便于以后的磁盘添加
卷组的分区和硬盘的分区不一样,我们叫他为逻辑卷(logical volume)
逻辑卷用什么格式呢?我这里选择的是gfs2
现在p1上设置clvmd,用来识别lvm
[root@p2 ~]# lvmconf --enable-cluster[root@p2 ~]# chkconfig --level 35 clvmd on
我是在iscsi这台机器上用Conga Cluster and Storage Management System对整个集群进行设置的,相当方便
那么先初始化Conga服务吧
[root@iscsi ~]# luci_admin initInitializing the Luci serverCreating the 'admin' userEnter password: Confirm password: Please wait...The admin password has been successfully set.Generating SSL certificates...Luci server has been successfully initializedRestart the Luci server for changes to take effecteg. service luci restart
然后重启服务
[root@iscsi [...]]]></description>
			<content:encoded><![CDATA[<p>刚才的iscsi将服务器上的磁盘共享出来,在cluster中,往往会使用添加共享磁盘的方式扩大共享空间,我们可以使用clvm技术,将多块共享磁盘合并成一个磁盘(卷组volume goup).也便于以后的磁盘添加<br />
卷组的分区和硬盘的分区不一样,我们叫他为逻辑卷(logical volume)<br />
逻辑卷用什么格式呢?我这里选择的是gfs2</p>
<p>现在p1上设置clvmd,用来识别lvm</p>
<div class="hl-surround"><div class="hl-main">[root@p2 ~]# lvmconf --enable-cluster<br />[root@p2 ~]# chkconfig --level 35 clvmd on</div></div>
<p>我是在iscsi这台机器上用Conga Cluster and Storage Management System对整个集群进行设置的,相当方便<br />
那么先初始化Conga服务吧</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# luci_admin init<br />Initializing the Luci server<br /><br /><br />Creating the 'admin' user<br /><br />Enter password: <br />Confirm password: <br /><br />Please wait...<br />The admin password has been successfully set.<br />Generating SSL certificates...<br />Luci server has been successfully initialized<br /><br /><br />Restart the Luci server for changes to take effect<br />eg. service luci restart</div></div>
<p>然后重启服务</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# service luci restart<br />Shutting down luci: [&nbsp; OK&nbsp; ]<br />Starting luci: [&nbsp; OK&nbsp; ]<br /><br />Point your web browser to https://iscsi.yubo.org:8084 to access luci</div></div>
<p>先建立一个集群吧,至于为什么这样做,请参照&lt;iscsi+clvm+gfs2+xen+Cluster(五)&#8211;能自动迁移的virtual server&gt;<br />
<img src="http://www.yubo.org/images/clvm-install/1.jpg" /></p>
<p>点击submit后<br />
<img src="http://www.yubo.org/images/clvm-install/2.jpg" /></p>
<p>cluster成员经历安装-重启-配置-结合4个步骤<br />
<img src="http://www.yubo.org/images/clvm-install/3.jpg" /></p>
<p>现在应该能看到<br />
<img src="http://www.yubo.org/images/clvm-install/4.jpg" /></p>
<p>如果还是不放心,想进一步确认是不是正常的话,好吧,点击上面那个图上的p1.yubo.org<br />
<img src="http://www.yubo.org/images/clvm-install/5.jpg" /></p>
<p>现在总该放心了吧,那么进入正题,storage-&gt;system list-&gt;p1.yubo.org-&gt;Volume Groups-&gt;New Volume Group<br />
将p1上的3个共享硬盘做成一个卷组,名字就叫vg1吧<br />
<img src="http://www.yubo.org/images/clvm-install/6.jpg" /><br />
<img src="http://www.yubo.org/images/clvm-install/7.jpg" /></p>
<p>添加完成之后,点击vg1上面的蓝条,建立逻辑卷<br />
<img src="http://www.yubo.org/images/clvm-install/8.jpg" /></p>
<p>p1.yubo.org上的gfs2也就配置完成了<br />
p2.yubo.org按道理刷新后应该跟p1一样,毕竟是一个cluster,而且3个硬盘的scsi id都是一样的<br />
不过我做试验的时候p2看上去没有任何变化,那么硬着头皮再配置一遍吧<br />
进入p2的配置页面,创建卷组(心想这样重新创建的vg跟p1的vg1不一致怎么办)<br />
果然报错了<br />
刷新以后,p1的配置更新到p2上来了&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=30</wfw:commentRss>
		</item>
		<item>
		<title>iscsi+clvm+gfs2+xen+Cluster(三)&#8211;iscsi的配置</title>
		<link>http://www.yubo.org/blog/?p=29</link>
		<comments>http://www.yubo.org/blog/?p=29#comments</comments>
		<pubDate>Fri, 05 Sep 2008 06:48:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<category><![CDATA[iscsi]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=29</guid>
		<description><![CDATA[我的目的就是让p1,p2这2台机器能使用到iscsi共享的磁盘,那么开始把
domain:yubo.org&#160;&#160; &#160; &#160; &#160; iscsi:192.168.1.100&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#160;&#160; &#160; __________&#124;___________&#160;&#160; &#160;&#124;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#160;p1:192.168.1.101&#160; &#160; &#160; p2:192.168.1.102(v1:192.168.1.111)&#160; &#160; (v2:192.168.1.112)
#########################服务端##########################
[iscsi.yubo.org]
在iscsi上加装一块12G的scsi硬盘,作为共享磁盘(sdb)
分3个区吧,让共享磁盘看上去多一点,到后面做clvm直观些
分区之后:
[root@iscsi ~]# fdisk -l /dev/sdb Disk /dev/sdb: 12.8 GB, 12884901888 bytes255 heads, 63 sectors/track, 1566 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>我的目的就是让p1,p2这2台机器能使用到iscsi共享的磁盘,那么开始把</p>
<div class="hl-surround"><div class="hl-main">domain:yubo.org<br /><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; iscsi:192.168.1.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; __________|___________<br />&nbsp;&nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;p1:192.168.1.101&nbsp; &nbsp; &nbsp; p2:192.168.1.102<br />(v1:192.168.1.111)&nbsp; &nbsp; (v2:192.168.1.112)</div></div>
<p>#########################服务端##########################</p>
<p>[iscsi.yubo.org]<br />
在iscsi上加装一块12G的scsi硬盘,作为共享磁盘(sdb)<br />
分3个区吧,让共享磁盘看上去多一点,到后面做clvm直观些<br />
分区之后:</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# fdisk -l /dev/sdb <br /><br />Disk /dev/sdb: 12.8 GB, 12884901888 bytes<br />255 heads, 63 sectors/track, 1566 cylinders<br />Units = cylinders of 16065 * 512 = 8225280 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sdb1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;499&nbsp; &nbsp; &nbsp;4008186&nbsp; &nbsp;83&nbsp; Linux<br />/dev/sdb2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;500&nbsp; &nbsp; &nbsp; &nbsp; 1000&nbsp; &nbsp; &nbsp;4024282+&nbsp; 83&nbsp; Linux<br />/dev/sdb3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1001&nbsp; &nbsp; &nbsp; &nbsp; 1566&nbsp; &nbsp; &nbsp;4546395&nbsp; &nbsp;83&nbsp; Linux</div></div>
<p>#为了使sdb1,sdb2,sdb3共享出去<br />
#先开启相应的tgtd(SCSI Target Administration)服务吧</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# service tgtd start</div></div>
<p>#使用tgtadm 定义iscsi target 的qualified 名字：</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# tgtadm --lld iscsi --op new --mode target --tid=1 --targetname org.yubo.disk1<br />[root@iscsi ~]# tgtadm --lld iscsi --op new --mode target --tid=2 --targetname org.yubo.disk2<br />[root@iscsi ~]# tgtadm --lld iscsi --op new --mode target --tid=3 --targetname org.yubo.disk3</div></div>
<p>#使用 tgtadm 为上一步创建的目标增加分区：</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1<br />[root@iscsi ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 -b /dev/sdb2<br />[root@iscsi ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 3 --lun 1 -b /dev/sdb3</div></div>
<p>#使用tgtadm 允许客户端访问这三个目标逻辑卷：</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL<br />[root@iscsi ~]# tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL<br />[root@iscsi ~]# tgtadm --lld iscsi --op bind --mode target --tid 3 -I ALL</div></div>
<p>#使用tatadm 验证所有的目标逻辑卷定义正确：</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# tgtadm --lld iscsi --op show --mode target |grep Target</div></div>
<p>#为了使这个配置永远生效</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# chkconfig --level 35 tgtd on<br />[root@iscsi ~]# cat &gt;&gt; /etc/rc.local &lt;&lt;EOF<br />tgtadm --lld iscsi --op new --mode target --tid=1 --targetname org.yubo.disk1<br />tgtadm --lld iscsi --op new --mode target --tid=2 --targetname org.yubo.disk2<br />tgtadm --lld iscsi --op new --mode target --tid=3 --targetname org.yubo.disk3<br />tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1<br />tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 -b /dev/sdb2<br />tgtadm --lld iscsi --op new --mode logicalunit --tid 3 --lun 1 -b /dev/sdb3<br />tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL<br />tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL<br />tgtadm --lld iscsi --op bind --mode target --tid 3 -I ALL<br />EOF</div></div>
<p>#############################客户端#########################<br />
[p1.yubo.org]<br />
确认iscsid/iscsi是开启的(默认是开启的</p>
<p>运行下面命令，discovery iscsitarget上的逻辑卷：</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.100<br />192.168.1.100:3260,1 org.yubo.disk1<br />192.168.1.100:3260,1 org.yubo.disk2<br />192.168.1.100:3260,1 org.yubo.disk3</div></div>
<p>说明iscsi 上共享的逻辑卷已经成功识别。</p>
<p>使用 iscsiadm 登录目标服务器(iscsi):</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# iscsiadm -m node -T org.yubo.disk1 -p 192.168.1.100 -l<br />Login session [iface: default, target: org.yubo.disk1, portal: 192.168.1.100,3260]<br />[root@p1 ~]# iscsiadm -m node -T org.yubo.disk2 -p 192.168.1.100 -l<br />Login session [iface: default, target: org.yubo.disk2, portal: 192.168.1.100,3260]<br />[root@p1 ~]# iscsiadm -m node -T org.yubo.disk3 -p 192.168.1.100 -l<br />Login session [iface: default, target: org.yubo.disk3, portal: 192.168.1.100,3260]</div></div>
<p>#用fdisk查看吧</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# fdisk -l<br /><br />Disk /dev/sda: 21.4 GB, 21474836480 bytes<br />255 heads, 63 sectors/track, 2610 cylinders<br />Units = cylinders of 16065 * 512 = 8225280 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sda1&nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; 2295&nbsp; &nbsp; 18434556&nbsp; &nbsp;83&nbsp; Linux<br />/dev/sda2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2296&nbsp; &nbsp; &nbsp; &nbsp; 2360&nbsp; &nbsp; &nbsp; 522112+&nbsp; 82&nbsp; Linux swap / Solaris<br /><br />Disk /dev/sdb: 4104 MB, 4104382464 bytes<br />127 heads, 62 sectors/track, 1018 cylinders<br />Units = cylinders of 7874 * 512 = 4031488 bytes<br /><br />Disk /dev/sdb doesn't contain a valid partition table<br /><br />Disk /dev/sdc: 4120 MB, 4120865280 bytes<br />127 heads, 62 sectors/track, 1022 cylinders<br />Units = cylinders of 7874 * 512 = 4031488 bytes<br /><br />Disk /dev/sdc doesn't contain a valid partition table<br /><br />Disk /dev/sdd: 4655 MB, 4655508480 bytes<br />144 heads, 62 sectors/track, 1018 cylinders<br />Units = cylinders of 8928 * 512 = 4571136 bytes<br /><br />Disk /dev/sdd doesn't contain a valid partition table</div></div>
<p>#从上面看出， iscsi.yubo.org 上的三个逻辑卷， 分别被识别成了本地磁盘/dev/sdb,/dev/sdc,/dev/sdd 三个本地磁盘。<br />
#以上用iscsiadm命令所登陆到的目标服务器信息,会被自动保存到/var/lib/iscsi/目录,所以不用担心重启丢失的问题</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# ls /var/lib/iscsi/nodes/<br />org.yubo.disk1&nbsp; org.yubo.disk2&nbsp; org.yubo.disk3</div></div>
<p>#接着在这三个磁盘上，分别建立一个分区，建立成功后的结果应为：</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# fdisk -l<br /><br />Disk /dev/sda: 21.4 GB, 21474836480 bytes<br />255 heads, 63 sectors/track, 2610 cylinders<br />Units = cylinders of 16065 * 512 = 8225280 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sda1&nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; 2295&nbsp; &nbsp; 18434556&nbsp; &nbsp;83&nbsp; Linux<br />/dev/sda2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2296&nbsp; &nbsp; &nbsp; &nbsp; 2360&nbsp; &nbsp; &nbsp; 522112+&nbsp; 82&nbsp; Linux swap / Solaris<br /><br />Disk /dev/sdb: 4104 MB, 4104382464 bytes<br />127 heads, 62 sectors/track, 1018 cylinders<br />Units = cylinders of 7874 * 512 = 4031488 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sdb1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; 1000&nbsp; &nbsp; &nbsp;3936969&nbsp; &nbsp;83&nbsp; Linux<br /><br />Disk /dev/sdc: 4120 MB, 4120865280 bytes<br />127 heads, 62 sectors/track, 1022 cylinders<br />Units = cylinders of 7874 * 512 = 4031488 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sdc1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; 1000&nbsp; &nbsp; &nbsp;3936969&nbsp; &nbsp;83&nbsp; Linux<br /><br />Disk /dev/sdd: 4655 MB, 4655508480 bytes<br />144 heads, 62 sectors/track, 1018 cylinders<br />Units = cylinders of 8928 * 512 = 4571136 bytes<br /><br />&nbsp;&nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System<br />/dev/sdd1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; 1000&nbsp; &nbsp; &nbsp;4463969&nbsp; &nbsp;83&nbsp; Linux</div></div>
<p>#运行下面命令，discovery iscsitarget上的逻辑卷：</p>
<div class="hl-surround"><div class="hl-main">[root@p1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.100<br />192.168.1.100:3260,1 org.yubo.disk1<br />192.168.1.100:3260,1 org.yubo.disk2<br />192.168.1.100:3260,1 org.yubo.disk3</div></div>
<p>说明iscsi 上共享的逻辑卷已经成功识别。</p>
<p>p2上也做相应的配置,只是登陆到目标服务器以后,不用分区了</p>
<p>iscsi配置也就完成了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>iscsi+clvm+gfs2+xen+Cluster(二)&#8211;xen虚拟机的安装</title>
		<link>http://www.yubo.org/blog/?p=28</link>
		<comments>http://www.yubo.org/blog/?p=28#comments</comments>
		<pubDate>Fri, 05 Sep 2008 06:40:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=28</guid>
		<description><![CDATA[[dhcp.yubo.org]
#修改为用来安装虚拟机的ks文件
[root@dhcp ~]# cat /var/www/html/ks.cfg &#60;&#60; EOF
key 4c10c9d64c6b34c9
lang en_US.UTF-8
keyboard us
xconfig --startxonboot
network --device eth0 --bootproto static --ip 192.168.1.111 --hostname v1.yubo.org --netmask 255.255.255.0 --gateway 192.168.1.254 --nameserver 202.103.24.68
rootpw mario
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append=&#34;rhgb quiet&#34;
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you [...]]]></description>
			<content:encoded><![CDATA[<p>[dhcp.yubo.org]</p>
<p>#修改为用来安装虚拟机的ks文件</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@dhcp ~]# cat /var/www/html/ks.cfg &lt;&lt; EOF</li>
<li>key 4c10c9d64c6b34c9</li>
<li>lang en_US.UTF-8</li>
<li>keyboard us</li>
<li>xconfig --startxonboot</li>
<li>network --device eth0 --bootproto static --ip 192.168.1.111 --hostname v1.yubo.org --netmask 255.255.255.0 --gateway 192.168.1.254 --nameserver 202.103.24.68</li>
<li>rootpw mario</li>
<li>firewall --disabled</li>
<li>authconfig --enableshadow --enablemd5</li>
<li>selinux --disabled</li>
<li>timezone Asia/Shanghai</li>
<li>bootloader --location=mbr --driveorder=sda --append=&quot;rhgb quiet&quot;</li>
<li># The following is the partition information you requested</li>
<li># Note that any partitions you deleted are not expressed</li>
<li># here so unless you clear all partitions first, this is</li>
<li># not guaranteed to work</li>
<li>clearpart --linux</li>
<li>part / --fstype ext3 --size=3584</li>
<li>part swap --size=256</li>
<li>%packages</li>
<li>@cluster-storage</li>
<li>@admin-tools</li>
<li>@editors</li>
<li>@text-internet</li>
<li>@gnome-desktop</li>
<li>@core</li>
<li>@base</li>
<li>@clustering</li>
<li>@java</li>
<li>@base-x</li>
<li>@graphics</li>
<li>@graphical-internet</li>
<li>scsi-target-utils</li>
<li>iscsi-initiator-utils</li>
<li>kexec-tools</li>
<li>bridge-utils</li>
<li>device-mapper-multipath</li>
<li>xorg-x11-utils</li>
<li>xorg-x11-server-Xnest</li>
<li>libsane-hpaio</li>
<li>-sysreport</li>
<li>EOF</li></ol></div>
<p>将rhel5的iso插入dhcp.yubo.org的光驱-&gt;挂载-&gt;共享到apache的DocumentRoot目录,给v1用来远程安装</p>
<div class="hl-surround"><div class="hl-main">[root@dhcp ~]# mkdir /mnt/cdrom<br />[root@dhcp ~]# mount /dev/cdrom /mnt/cdrom<br />[root@dhcp ~]# ln -s /mnt/cdrom /var/www/html/cdrom</div></div>
<p>[p1.yubo.oirg]<br />
进入图形界面,执行<br />
[root@iscsi ~]# virt-manager<br />
一路forward,途中填入</p>
<div class="hl-surround"><div class="hl-main">system Name:v1<br />Paravirtualized<br />Install Medai URL: http://192.168.1.5/cdrom<br />Kickstart URL: http://192.168.1.5/ks.cfg<br />Simple File-&amp;gt;File Location: /var/lib/xen/images/v1.img<br />Shared physical device -&amp;gt; Device: xenbr0<br />VM Max Memory(MB): 252<br />VM Startup Memory(MB): 252<br />VCPUs:1</div></div>
<p>等待一段时间后,v1.yubo.org就安装完成了,下面是过程的截图</p>
<p><img src="http://www.yubo.org/images/xen-install/1.jpg" /> <br />
<img src="http://www.yubo.org/images/xen-install/2.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/3.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/4.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/5.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/6.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/7.jpg" /><br />
<img src="http://www.yubo.org/images/xen-install/8.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=28</wfw:commentRss>
		</item>
		<item>
		<title>iscsi+clvm+gfs2+xen+Cluster(一)&#8212;环境的搭建</title>
		<link>http://www.yubo.org/blog/?p=27</link>
		<comments>http://www.yubo.org/blog/?p=27#comments</comments>
		<pubDate>Fri, 05 Sep 2008 06:33:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=27</guid>
		<description><![CDATA[根据史应生先生的&#60;基于红帽企业版Linux RHEL5U2 GFS2＋ISCSI＋虚拟化XEN＋Cluster 的高可用性（HA）解决方案&#62;一文的做了相应的实验,下面是自己的试验笔记,其中有些与原文有些不一致.
试验条件所限,全部试验机器在vmware(rhel5)上完成
hw: thinkpadT61/CPU:7300/RAM:3G
OS: windowXP
拓扑图
domain:yubo.org&#160;&#160; &#160; &#160; &#160; iscsi:192.168.1.100&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#160;&#160; &#160; __________&#124;___________&#160;&#160; &#160;&#124;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#160;p1:192.168.1.101&#160; &#160; &#160; p2:192.168.1.102(v1:192.168.1.111)&#160; &#160; (v2:192.168.1.112)
先用一个临时的192.168.1.5(dhcp.yubo.org)搭建dhcpd/apache用来以ks方式安装rehl5
[安装iscsi.yubo.org]
vmware-&#62;新建一个rhel5,ram分了500MB
在dhcp上
[root@dhcp ~]# cat /var/www/html/ks.cfg &#60;&#60; EOF
key 4c10c9d64c6b34c9
lang en_US.UTF-8
keyboard us
xconfig --startxonboot
network --device eth0 --bootproto static --ip 192.168.1.100 --hostname iscsitarget.yubo.org --netmask 255.255.255.0 [...]]]></description>
			<content:encoded><![CDATA[<p>根据史应生先生的&lt;基于红帽企业版Linux RHEL5U2 GFS2＋ISCSI＋虚拟化XEN＋Cluster 的高可用性（HA）解决方案&gt;一文的做了相应的实验,下面是自己的试验笔记,其中有些与原文有些不一致.</p>
<p>试验条件所限,全部试验机器在vmware(rhel5)上完成<br />
hw: thinkpadT61/CPU:7300/RAM:3G<br />
OS: windowXP</p>
<p>拓扑图</p>
<div class="hl-surround"><div class="hl-main">domain:yubo.org<br /><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; iscsi:192.168.1.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; __________|___________<br />&nbsp;&nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;p1:192.168.1.101&nbsp; &nbsp; &nbsp; p2:192.168.1.102<br />(v1:192.168.1.111)&nbsp; &nbsp; (v2:192.168.1.112)</div></div>
<p>先用一个临时的192.168.1.5(dhcp.yubo.org)搭建dhcpd/apache用来以ks方式安装rehl5</p>
<p>[安装iscsi.yubo.org]</p>
<p>vmware-&gt;新建一个rhel5,ram分了500MB</p>
<p>在dhcp上</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@dhcp ~]# cat /var/www/html/ks.cfg &lt;&lt; EOF</li>
<li>key 4c10c9d64c6b34c9</li>
<li>lang en_US.UTF-8</li>
<li>keyboard us</li>
<li>xconfig --startxonboot</li>
<li>network --device eth0 --bootproto static --ip 192.168.1.100 --hostname iscsitarget.yubo.org --netmask 255.255.255.0 --gateway 192.168.1.254 --nameserver 202.103.24.68</li>
<li>rootpw mario</li>
<li>firewall --disabled</li>
<li>authconfig --enableshadow --enablemd5</li>
<li>selinux --disabled</li>
<li>timezone Asia/Shanghai</li>
<li>bootloader --location=mbr --driveorder=sda --append=&quot;rhgb quiet&quot;</li>
<li># The following is the partition information you requested</li>
<li># Note that any partitions you deleted are not expressed</li>
<li># here so unless you clear all partitions first, this is</li>
<li># not guaranteed to work</li>
<li>clearpart --linux --drives=sda</li>
<li>part / --fstype ext3 --size=18000</li>
<li>part swap --size=512</li>
<li>%packages</li>
<li>@cluster-storage</li>
<li>@admin-tools</li>
<li>@editors</li>
<li>@virtualization</li>
<li>@gnome-desktop</li>
<li>@core</li>
<li>@base</li>
<li>@clustering</li>
<li>@base-x</li>
<li>@graphical-internet</li>
<li>scsi-target-utils</li>
<li>iscsi-initiator-utils</li>
<li>kexec-tools</li>
<li>bridge-utils</li>
<li>device-mapper-multipath</li>
<li>xorg-x11-utils</li>
<li>xorg-x11-server-Xnest</li>
<li>libsane-hpaio</li>
<li>-sysreport</li>
<li>EOF</li></ol></div>
<p>开启dhcpd/httpd服务</p>
<p>[iscsi.yubo.org]<br />
插入rhel5的iso,用以下命令从光盘启动</p>
<div class="hl-surround"><div class="hl-main">#linux fs=http://192.168.1.5/fs.conf</div></div>
<p>安装完成之后,修改hostname和hosts文件</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# cat /var/www/html/ks.cfg &lt;&lt; EOF<br />127.0.0.1&nbsp; &nbsp; &nbsp; &nbsp;localhost.localdomain&nbsp; &nbsp;localhost<br />192.168.1.5&nbsp; &nbsp; &nbsp;dhcp.yubo.org<br />192.168.1.100&nbsp; &nbsp;iscsi.yubo.org<br />192.168.1.101&nbsp; &nbsp;p1.yubo.org<br />192.168.1.102&nbsp; &nbsp;p2.yubo.org<br />192.168.1.111&nbsp; &nbsp;v1.yubo.org<br />192.168.1.112&nbsp; &nbsp;v2.yubo.org</div></div>
<p>关机</p>
<div class="hl-surround"><div class="hl-main">[root@iscsi ~]# init 0</div></div>
<p>[p1.yubo.org]<br />
用iscsi克隆出p1,p1的ram调至1G,启动后,修改hostname/ip地址/网卡的mac地址<br />
在p1上安装用xen安装虚拟机v1.yubo.org(具体步骤请参照&lt;iscsi+clvm+gfs2+xen+Cluster(二)&gt;)</p>
<p>[p2.yubo.org]<br />
用p1克隆出p2,启动后,将p2,v2的hostname/ip地址/网卡的mac地址做相应修改<br />
将5台机器相应的ip,netmask设置正确后,将不必要的服务全部关了,运行级别都调到3,这样速度快点</p>
<p>保证5台机器之间通过机器名能互相访问到,到此为止,试验环境也就搭建完成</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=27</wfw:commentRss>
		</item>
		<item>
		<title>RHEL5/Cluster(TUN部分)</title>
		<link>http://www.yubo.org/blog/?p=26</link>
		<comments>http://www.yubo.org/blog/?p=26#comments</comments>
		<pubDate>Sat, 16 Aug 2008 13:19:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=26</guid>
		<description><![CDATA[RHEL5中的Cluster组件是基于章文嵩先生创立的LVS(Linux Virtual Server) 制作而成,
关于lvs的工作原理请参照《Linux 服务器集群系统》
Virtual Server via IP Tunneling（VS/TUN）
采用NAT技术时，由于请求和响应报文都必须经过调度器地址重写，当客户请求越来越多时，调度器的处理能力将成为瓶颈。为了解决这个问题，调度器把请求报文通过IP隧道转发至真实服务器，而真实服务器将响应直接返回给客户，所以调度器只处理请求报文。由于一般网络服务应答比请求报文大许多，采用VS/TUN技术后，集群系统的最大吞吐量可以提高10倍。 
Cluster(TUN部分)实验
TUN类型的httpd负载均衡集群.网络拓扑为
eth0&#160; &#160;192.168.1.100&#160; eth0&#160; &#160;192.168.1.200tunl0&#160; 10.0.0.50&#160; &#160; &#160; tunl0&#160; 10.0.0.50gw&#160; &#160; &#160;192.168.1.10&#160; &#160;gw&#160; &#160; &#160;192.168.1.10&#160;______________&#160; &#160; &#160; ______________&#124;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#160; &#160; &#124;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#124;&#124; realserver 1 &#124;&#160; &#160; &#124; realserver 2 &#124;&#124;______________&#124;&#160; &#160; &#124;______________&#124;&#160;&#160; &#160; &#160; &#160;&#124;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>RHEL5中的Cluster组件是基于章文嵩先生创立的LVS(Linux Virtual Server) 制作而成,</p>
<p>关于lvs的工作原理请参照<a href="http://www.ibm.com/developerworks/cn/linux/theme/cluster.html">《Linux 服务器集群系统》</a></p>
<p>Virtual Server via IP Tunneling（VS/TUN）<br />
采用NAT技术时，由于请求和响应报文都必须经过调度器地址重写，当客户请求越来越多时，调度器的处理能力将成为瓶颈。为了解决这个问题，调度器把请求报文通过IP隧道转发至真实服务器，而真实服务器将响应直接返回给客户，所以调度器只处理请求报文。由于一般网络服务应答比请求报文大许多，采用VS/TUN技术后，集群系统的最大吞吐量可以提高10倍。 </p>
<p>Cluster(TUN部分)实验</p>
<p>TUN类型的httpd负载均衡集群.网络拓扑为</p>
<div class="hl-surround"><div class="hl-main">eth0&nbsp; &nbsp;192.168.1.100&nbsp; eth0&nbsp; &nbsp;192.168.1.200<br />tunl0&nbsp; 10.0.0.50&nbsp; &nbsp; &nbsp; tunl0&nbsp; 10.0.0.50<br />gw&nbsp; &nbsp; &nbsp;192.168.1.10&nbsp; &nbsp;gw&nbsp; &nbsp; &nbsp;192.168.1.10<br />&nbsp;______________&nbsp; &nbsp; &nbsp; ______________<br />|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />| realserver 1 |&nbsp; &nbsp; | realserver 2 |<br />|______________|&nbsp; &nbsp; |______________|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;|___________________|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eth0 192.168.1.10<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ________<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp;gw&nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|________|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eth1&nbsp; 10.0.0.10&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; VIP(eth0:1)=10.0.0.50&nbsp; &nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ _ _ _ _&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; director&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |_ _ _ _ _ |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;----------------------------------------<br />&nbsp;&nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp; eth0 10.0.0.1&nbsp; &nbsp;eth0 10.0.0.2&nbsp; &nbsp; &nbsp;eth0 10.0.0.3<br />&nbsp; gw&nbsp; &nbsp;10.0.0.10&nbsp; gw&nbsp; &nbsp;10.0.0.10&nbsp; &nbsp; gw&nbsp; &nbsp;10.0.0.10<br />&nbsp;______________&nbsp; &nbsp; ______________&nbsp; &nbsp; ______________<br />|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />|&nbsp; &nbsp; router&nbsp; &nbsp; |&nbsp; | router backup|&nbsp; |&nbsp; &nbsp; &nbsp;clinet&nbsp; &nbsp;|<br />|______________|&nbsp; |______________|&nbsp; |______________|</div></div>
<div class="hl-surround"><div class="hl-main">[client]&nbsp; &nbsp; <br />os:windwows xp<br /><br />[gw]&nbsp; &nbsp; &nbsp; &nbsp; <br />os:rhel5&nbsp; &nbsp;<br />hostname:gw<br /><br />[router/router backup]<br />os:rhel5&nbsp; &nbsp; <br />hostname:vs/vs_bk&nbsp; &nbsp; <br />software: ipvsadm piranha httpd php<br /><br /><br />[realserver1/realserver2]<br />os:rhel5&nbsp; &nbsp; <br />hostname:rs1/rs2&nbsp; &nbsp; <br />software:httpd<br /><br />[director]<br />&nbsp;&nbsp; &nbsp;为router或者router backup中的一台虚拟出来</div></div>
<p>配置如下</p>
<p>[gw]</p>
<div class="hl-surround"><div class="hl-main">#打开路由转发<br />[root@gw ~]# echo 1 &gt; /proc/sys/net/ipv4/ip_forward</div></div>
<p>[router]</p>
<div class="hl-surround"><div class="hl-main">#设置piranha密码<br />piranha-passwd</div></div>
<div class="hl-surround"><div class="hl-main">#开启服务<br />service piranha-gui start</div></div>
<div class="hl-surround"><div class="hl-main">#访问配置页面<br />http://10.0.0.1:3636/</div></div>
<div class="hl-surround"><div class="hl-main">#配置以后的文件<br />[root@vs ~]# cat /etc/sysconfig/ha/lvs.cf <br />serial_no = 53<br />primary = 10.0.0.1<br />service = lvs<br />backup_active = 1<br />backup = 10.0.0.2<br />heartbeat = 1<br />heartbeat_port = 539<br />keepalive = 6<br />deadtime = 18<br />network = tunnel<br />nat_nmask = 255.255.255.0<br />debug_level = NONE<br />monitor_links = 0<br />virtual HTTP {<br />&nbsp;&nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; address = 10.0.0.50 eth0:1<br />&nbsp;&nbsp; &nbsp; vip_nmask = 255.255.0.0<br />&nbsp;&nbsp; &nbsp; port = 80<br />&nbsp;&nbsp; &nbsp; send = &quot;GET / HTTP/1.0\r\n\r\n&quot;<br />&nbsp;&nbsp; &nbsp; expect = &quot;HTTP&quot;<br />&nbsp;&nbsp; &nbsp; use_regex = 0<br />&nbsp;&nbsp; &nbsp; load_monitor = none<br />&nbsp;&nbsp; &nbsp; scheduler = wlc<br />&nbsp;&nbsp; &nbsp; protocol = tcp<br />&nbsp;&nbsp; &nbsp; timeout = 6<br />&nbsp;&nbsp; &nbsp; reentry = 15<br />&nbsp;&nbsp; &nbsp; quiesce_server = 0<br />&nbsp;&nbsp; &nbsp; server rs1.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 192.168.1.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />&nbsp;&nbsp; &nbsp; server rs2.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 192.168.1.200<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />}</div></div>
<div class="hl-surround"><div class="hl-main">#重启服务<br />service pulse restart</div></div>
<p>[router backup]</p>
<div class="hl-surround"><div class="hl-main">#设置piranha密码<br />piranha-passwd</div></div>
<div class="hl-surround"><div class="hl-main">#开启服务<br />service piranha-gui start</div></div>
<div class="hl-surround"><div class="hl-main">#访问配置页面<br />http://10.0.0.2:3636/</div></div>
<div class="hl-surround"><div class="hl-main">#配置以后的文件<br />[root@vs_bk ~]# cat /etc/sysconfig/ha/lvs.cf <br />serial_no = 48<br />primary = 10.0.0.2<br />service = lvs<br />backup_active = 1<br />backup = 10.0.0.1<br />heartbeat = 1<br />heartbeat_port = 539<br />keepalive = 6<br />deadtime = 18<br />network = tunnel<br />nat_nmask = 255.255.0.0<br />debug_level = NONE<br />monitor_links = 0<br />virtual HTTP {<br />&nbsp;&nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; address = 10.0.0.50 eth0:1<br />&nbsp;&nbsp; &nbsp; vip_nmask = 255.255.0.0<br />&nbsp;&nbsp; &nbsp; port = 80<br />&nbsp;&nbsp; &nbsp; send = &quot;GET / HTTP/1.0\r\n\r\n&quot;<br />&nbsp;&nbsp; &nbsp; expect = &quot;HTTP&quot;<br />&nbsp;&nbsp; &nbsp; use_regex = 0<br />&nbsp;&nbsp; &nbsp; load_monitor = none<br />&nbsp;&nbsp; &nbsp; scheduler = wlc<br />&nbsp;&nbsp; &nbsp; protocol = tcp<br />&nbsp;&nbsp; &nbsp; timeout = 6<br />&nbsp;&nbsp; &nbsp; reentry = 15<br />&nbsp;&nbsp; &nbsp; quiesce_server = 0<br />&nbsp;&nbsp; &nbsp; server rs1.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 192.168.1.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />&nbsp;&nbsp; &nbsp; server rs2.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 192.168.1.200<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />}</div></div>
<div class="hl-surround"><div class="hl-main">#重启服务<br />service pulse restart</div></div>
<p>[realserver1/realserver2]<br />
封装到达realserver的包,目的地址是vip的地址,而不是rs的ip地址,如果不做处理,会被拒绝,加上一个虚拟设备就解决问题了tunl0</p>
<div class="hl-surround"><div class="hl-main">ifconfig tunl0 10.0.0.50 netmask 255.255.255.255</div></div>
<p>之后开启rs1,rs2的httpd服务,为了使得便于观察</p>
<div class="hl-surround"><div class="hl-main">[root@rs1 ~]# echo &quot;rs1.yubo.org&quot; &gt; /var/www/html/index.html <br />[root@rs2 ~]# echo &quot;rs2.yubo.org&quot; &gt; /var/www/html/index.html</div></div>
<p>client频繁访问http://10.0.0.50时,会发现显示内容在&#8221;rs2.yubo.org&#8221;和&#8221;rs1.yubo.org&#8221;之间切换</p>
<p>试验完成以后,不要忘记保存配置,以免启动以后无法使用</p>
<p>[vs/vs_bk]</p>
<div class="hl-surround"><div class="hl-main">chkconfig --level 2345 piranha-gui on<br />chkconfig --level 2345 pulse on</div></div>
<p>[rs1/rs2]</p>
<div class="hl-surround"><div class="hl-main">echo &quot;ifconfig tunl0 10.0.0.50 netmask 255.255.255.255&quot; &gt;&gt; /etc/rc.local</div></div>
<p>[注意]<br />
route 和 route backup 互为备份,没有主次之分(注意每个配置文件的backup和backup_private)<br />
route backup 是route的备份<br />
route 是route backup的备份<br />
10.0.0.50个虚拟ip地址同一时刻只出现在1个router上,当前router当机以后,这个ip地址会被另一台备份机器接管</p>
<p>[其他]</p>
<div class="hl-surround"><div class="hl-main">[root@vs_bk ~]# ipvsadm --save -n<br />-A -t 10.0.0.50:80 -s wlc<br />-a -t 10.0.0.50:80 -r 192.168.1.200:80 -i -w 1<br />-a -t 10.0.0.50:80 -r 192.168.1.100:80 -i -w 1</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=26</wfw:commentRss>
		</item>
		<item>
		<title>RHEL5/Cluster(DR部分)</title>
		<link>http://www.yubo.org/blog/?p=25</link>
		<comments>http://www.yubo.org/blog/?p=25#comments</comments>
		<pubDate>Sat, 16 Aug 2008 09:18:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[cluster]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.yubo.org/blog/?p=25</guid>
		<description><![CDATA[RHEL5中的Cluster组件是基于章文嵩先生创立的LVS(Linux Virtual Server) 制作而成,
关于lvs的工作原理请参照《Linux 服务器集群系统》
Virtual Server via Direct Routing（VS/DR）
VS/DR通过改写请求报文的MAC地址，将请求发送到真实服务器，而真实服务器将响应直接返回给客户。同VS/TUN技术一样，VS/DR技术可极大地提高集群系统的伸缩性。这种方法没有IP隧道的开销，对集群中的真实服务器也没有必须支持IP隧道协议的要求，但是要求调度器与真实服务器都有一块网卡连在同一物理网段上。 
Cluster(DR部分)实验

应为DR使基于MAC改写的,为了使试验简单明了,假设client,router,realserver都在一个网段上,
DR类型的httpd负载均衡集群.网络拓扑为
*当然,实际使用中,还需要考虑网关,路由等
#拓扑图&#160;&#160; &#160; &#160; &#160; &#160; &#160; ________&#160;&#160; &#160; &#160; &#160; &#160; &#160;&#124;&#160; &#160; &#160; &#160; &#124;&#160;&#160; &#160; &#160; &#160; &#160; &#160;&#124; client &#124;&#160;&#160; &#160; &#160; &#160; &#160; &#160;&#124;________&#124;&#160;&#160; &#160; &#160; &#160; &#160; &#160; 10.0.0.10&#160; &#160; &#160; &#160; &#160; &#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#124;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>RHEL5中的Cluster组件是基于章文嵩先生创立的LVS(Linux Virtual Server) 制作而成,</p>
<p>关于lvs的工作原理请参照<a href="http://www.ibm.com/developerworks/cn/linux/theme/cluster.html">《Linux 服务器集群系统》</a></p>
<p>Virtual Server via Direct Routing（VS/DR）<br />
VS/DR通过改写请求报文的MAC地址，将请求发送到真实服务器，而真实服务器将响应直接返回给客户。同VS/TUN技术一样，VS/DR技术可极大地提高集群系统的伸缩性。这种方法没有IP隧道的开销，对集群中的真实服务器也没有必须支持IP隧道协议的要求，但是要求调度器与真实服务器都有一块网卡连在同一物理网段上。 </p>
<p>Cluster(DR部分)实验</p>
<p><img border="0"  src="http://www.yubo.org/images/cluster/lvs-direct-routing.png"  /></p>
<p>应为DR使基于MAC改写的,为了使试验简单明了,假设client,router,realserver都在一个网段上,<br />
DR类型的httpd负载均衡集群.网络拓扑为<br />
*当然,实际使用中,还需要考虑网关,路由等</p>
<div class="hl-surround"><div class="hl-main">#拓扑图<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ________<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| client |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|________|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10.0.0.10&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eth0 10.0.0.1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_____________<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; VIP(eth0:1)=10.0.0.50&nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; router&nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ _ _ _ _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |_____________|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; director&nbsp; ---------------+<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |_ _ _ _ _ |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eth0 10.0.0.2<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;______________<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-----------------&nbsp; &nbsp; &nbsp; &nbsp; | router backup|<br />&nbsp;&nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp;|______________|<br />&nbsp;&nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; eth0 10.0.0.100&nbsp; &nbsp;eth0 10.0.0.200<br />&nbsp;______________&nbsp; &nbsp; ______________<br />|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />| realserver1&nbsp; |&nbsp; | realserver2&nbsp; |<br />|______________|&nbsp; |______________|</div></div>
<div class="hl-surround"><div class="hl-main">[client]<br />&nbsp;&nbsp; &nbsp;os<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;windwows xp<br /><br />[router]<br />&nbsp;&nbsp; &nbsp;os<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rhel5<br />&nbsp;&nbsp; &nbsp;hostname<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;vs<br />&nbsp;&nbsp; &nbsp;software<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ipvsadm piranha httpd php<br /><br />[router backup]<br />&nbsp;&nbsp; &nbsp;os<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rhel5<br />&nbsp;&nbsp; &nbsp;hostname<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;vs_bk<br />&nbsp;&nbsp; &nbsp;software<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ipvsadm piranha httpd php<br /><br />[real server 1]<br />&nbsp;&nbsp; &nbsp;os<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rhel5<br />&nbsp;&nbsp; &nbsp;hostname<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rs1<br />&nbsp;&nbsp; &nbsp;software<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;httpd<br />&nbsp;<br />[real server B]<br />&nbsp;&nbsp; &nbsp;os<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rhel5<br />&nbsp;&nbsp; &nbsp;hostname<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rs2<br />&nbsp;&nbsp; &nbsp;software<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;httpd<br /><br />[director]<br />&nbsp;&nbsp; &nbsp;为router或者router backup中的一台虚拟出来</div></div>
<p>配置如下<br />
[router]</p>
<div class="hl-surround"><div class="hl-main">#设置piranha密码<br />piranha-passwd</div></div>
<div class="hl-surround"><div class="hl-main">#开启服务<br />service piranha-gui start</div></div>
<div class="hl-surround"><div class="hl-main">#访问配置页面<br />http://10.0.0.1:3636/</div></div>
<div class="hl-surround"><div class="hl-main">#配置以后的文件<br />[root@vs ~]# cat /etc/sysconfig/ha/lvs.cf <br />serial_no = 51<br />primary = 10.0.0.1<br />service = lvs<br />backup_active = 1<br />backup = 10.0.0.2<br />heartbeat = 1<br />heartbeat_port = 539<br />keepalive = 6<br />deadtime = 18<br />network = direct<br />nat_nmask = 255.255.255.0<br />debug_level = NONE<br />monitor_links = 0<br />virtual HTTP {<br />&nbsp;&nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; address = 10.0.0.50 eth0:1<br />&nbsp;&nbsp; &nbsp; vip_nmask = 255.255.0.0<br />&nbsp;&nbsp; &nbsp; port = 80<br />&nbsp;&nbsp; &nbsp; send = &quot;GET / HTTP/1.0\r\n\r\n&quot;<br />&nbsp;&nbsp; &nbsp; expect = &quot;HTTP&quot;<br />&nbsp;&nbsp; &nbsp; use_regex = 0<br />&nbsp;&nbsp; &nbsp; load_monitor = none<br />&nbsp;&nbsp; &nbsp; scheduler = wlc<br />&nbsp;&nbsp; &nbsp; protocol = tcp<br />&nbsp;&nbsp; &nbsp; timeout = 6<br />&nbsp;&nbsp; &nbsp; reentry = 15<br />&nbsp;&nbsp; &nbsp; quiesce_server = 0<br />&nbsp;&nbsp; &nbsp; server rs1.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 10.0.0.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />&nbsp;&nbsp; &nbsp; server rs2.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 10.0.0.200<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />}</div></div>
<div class="hl-surround"><div class="hl-main">#重启服务<br />service pulse restart</div></div>
<p>[router backup]</p>
<div class="hl-surround"><div class="hl-main">#设置piranha密码<br />piranha-passwd</div></div>
<div class="hl-surround"><div class="hl-main">#开启服务<br />service piranha-gui start</div></div>
<div class="hl-surround"><div class="hl-main">#访问配置页面<br />http://10.0.0.2:3636/</div></div>
<div class="hl-surround"><div class="hl-main">#配置以后的文件<br />[root@vs_bk ~]# cat /etc/sysconfig/ha/lvs.cf <br />serial_no = 46<br />primary = 10.0.0.2<br />service = lvs<br />backup_active = 1<br />backup = 10.0.0.1<br />heartbeat = 1<br />heartbeat_port = 539<br />keepalive = 6<br />deadtime = 18<br />network = direct<br />nat_nmask = 255.255.0.0<br />debug_level = NONE<br />monitor_links = 0<br />virtual HTTP {<br />&nbsp;&nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; address = 10.0.0.50 eth0:1<br />&nbsp;&nbsp; &nbsp; vip_nmask = 255.255.0.0<br />&nbsp;&nbsp; &nbsp; port = 80<br />&nbsp;&nbsp; &nbsp; send = &quot;GET / HTTP/1.0\r\n\r\n&quot;<br />&nbsp;&nbsp; &nbsp; expect = &quot;HTTP&quot;<br />&nbsp;&nbsp; &nbsp; use_regex = 0<br />&nbsp;&nbsp; &nbsp; load_monitor = none<br />&nbsp;&nbsp; &nbsp; scheduler = wlc<br />&nbsp;&nbsp; &nbsp; protocol = tcp<br />&nbsp;&nbsp; &nbsp; timeout = 6<br />&nbsp;&nbsp; &nbsp; reentry = 15<br />&nbsp;&nbsp; &nbsp; quiesce_server = 0<br />&nbsp;&nbsp; &nbsp; server rs1.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 10.0.0.100<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />&nbsp;&nbsp; &nbsp; server rs2.yubo.com {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; address = 10.0.0.200<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; active = 1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; weight = 1<br />&nbsp;&nbsp; &nbsp; }<br />}</div></div>
<div class="hl-surround"><div class="hl-main">#重启服务<br />service pulse restart</div></div>
<p>[realserver1/realserver2]<br />
修改mac地址,但是到达realserver的包,目的地址使vip的地址,而不是rs的ip地址,如果不做处理,会被拒绝,有arptables_jf/iptables 两种方法,我用的使iptables<br />
2台rs都要做</p>
<div class="hl-surround"><div class="hl-main">iptables -t nat -A PREROUTING -p tcp -d 1 --dport 80 -j REDIRECT</div></div>
<p>之后开启rs1,rs2的httpd服务,为了使得便于观察</p>
<div class="hl-surround"><div class="hl-main">[root@rs1 ~]# echo &quot;rs1.yubo.org&quot; &gt; /var/www/html/index.html <br />[root@rs2 ~]# echo &quot;rs2.yubo.org&quot; &gt; /var/www/html/index.html</div></div>
<p>client频繁访问http://10.0.0.50时,会发现显示内容在&#8221;rs2.yubo.org&#8221;和&#8221;rs1.yubo.org&#8221;之间切换</p>
<p>试验完成以后,不要忘记保存配置,以免启动以后无法使用</p>
<p>[vs/vs_bk]</p>
<div class="hl-surround"><div class="hl-main">chkconfig --level 2345 piranha-gui on<br />chkconfig --level 2345 pulse on</div></div>
<p>[rs1/rs2]</p>
<div class="hl-surround"><div class="hl-main">service iptables save<br />chkconfig --level 2345 iptables on</div></div>
<p>[注意]<br />
route 和 route backup 互为备份,没有主次之分(注意每个配置文件的backup和backup_private)<br />
route backup 是route的备份<br />
route 是route backup的备份<br />
10.0.0.50个虚拟ip地址同一时刻只出现在1个router上,当前router当机以后,这个ip地址会被另一台备份机器接管</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yubo.org/blog/?feed=rss2&amp;p=25</wfw:commentRss>
		</item>
	</channel>
</rss>
